diff --git a/.gitignore b/.gitignore index 75f5670..2328ee9 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ article/* db_folder/* runtime/Scripts/* runtime/Lib/* +runtime/pip/* chrome117.exe html/* excel/* diff --git a/install.py b/install.py new file mode 100644 index 0000000..eba2361 --- /dev/null +++ b/install.py @@ -0,0 +1,39 @@ +import tarfile +import os +import subprocess +import shutil + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +PYTHON_PATH = os.path.join(BASE_DIR, 'runtime/python.exe') +pip_folder = 'pip-23.3' +extract_dir = os.path.join(BASE_DIR, 'runtime/pip') +# Open the tar.gz file +with tarfile.open(f'./runtime/{pip_folder}.tar.gz', 'r:gz') as tar: + tar.extractall(path=extract_dir) + print("Extraction completed.") + print("Extracted to directory:", extract_dir) + +pip_install_path = os.path.join(BASE_DIR, 'runtime/pip', pip_folder) +setup_py_path = os.path.join(pip_install_path, 'setup.py') +# 构建安装命令 +install_command = [PYTHON_PATH, setup_py_path, 'install'] + +# 打印执行的命令 +print("Executing command:", ' '.join(install_command)) +subprocess.check_call(install_command, cwd=pip_install_path) +print("pip has been installed successfully.") + +# 开始安装包 +install_command_2 = [PYTHON_PATH, '-m', 'pip', 'install', '-r', 'requirements.txt', '-i', 'https://pypi.tuna.tsinghua.edu.cn/simple'] + +# 打印执行的命令 +print("Executing command:", ' '.join(install_command)) +subprocess.check_call(install_command_2) +print("package has been installed successfully.") + +# 现在删除解压的文件夹 +try: + shutil.rmtree(extract_dir) + print(f"Successfully removed the extracted folder: {extract_dir}") +except Exception as e: + print(f"Error removing the extracted folder: {e}") \ No newline at end of file diff --git a/runtime/pip-23.3.tar.gz b/runtime/pip-23.3.tar.gz new file mode 100644 index 0000000..b1c37de Binary files /dev/null and b/runtime/pip-23.3.tar.gz differ