2023-10-08 06:10:29 -04:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import venv
|
|
|
|
|
|
|
|
def deps_exists():
|
|
|
|
return os.path.exists('deps')
|
|
|
|
|
|
|
|
def create_venv():
|
|
|
|
venv.create('venv', with_pip=True)
|
|
|
|
# Create activation scripts
|
|
|
|
with open("venv.ps1", "w") as f:
|
|
|
|
f.write("venv\\Scripts\\Activate.ps1")
|
|
|
|
|
|
|
|
with open("venv.bat", "w") as f:
|
|
|
|
f.write("venv\\Scripts\\activate")
|
|
|
|
|
|
|
|
def upgrade_pip():
|
2023-10-08 07:23:27 -04:00
|
|
|
subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', 'pip'])
|
2023-10-08 06:10:29 -04:00
|
|
|
|
|
|
|
def install_wheel():
|
|
|
|
subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', 'wheel'])
|
|
|
|
|
|
|
|
def install_requirements_in_venv():
|
|
|
|
# Use the full path to the wheel file
|
|
|
|
wheel_path = os.path.join('src', 'cod_api-2.0.1-py3-none-any.whl')
|
2023-10-08 07:23:27 -04:00
|
|
|
subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', wheel_path])
|
|
|
|
|
|
|
|
def install_build_dependencies():
|
|
|
|
subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', 'pyinstaller'])
|
|
|
|
subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'uninstall', 'enum34', '-y'])
|
2023-10-08 06:10:29 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if not deps_exists():
|
|
|
|
print("Error: 'deps' directory does not exist!")
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
print("Creating virtual environment...")
|
|
|
|
create_venv()
|
|
|
|
print("Upgrading pip...")
|
|
|
|
upgrade_pip()
|
|
|
|
print("Installing wheel...")
|
|
|
|
install_wheel()
|
|
|
|
print("Installing packages in the virtual environment...")
|
|
|
|
install_requirements_in_venv() # Call the function to install the requirements
|
2023-10-08 07:23:27 -04:00
|
|
|
print("Installing build dependencies...")
|
|
|
|
install_build_dependencies()
|
2023-10-08 06:10:29 -04:00
|
|
|
print("Setup complete.")
|