|
7 | 7 | import platform
|
8 | 8 |
|
9 | 9 | def delete_older_directories(directory):
|
10 |
| - # Delete the specified directory if it exists |
11 | 10 | if os.path.exists(directory):
|
12 | 11 | shutil.rmtree(directory)
|
13 | 12 | print(f"Deleted directory: {directory}")
|
14 | 13 | else:
|
15 | 14 | print(f"Directory not found: {directory}")
|
16 | 15 |
|
17 | 16 | def find_and_delete_dist_and_build(cwd):
|
18 |
| - # Delete 'dist' and 'build' directories |
19 | 17 | delete_older_directories(os.path.join(cwd, 'dist'))
|
20 | 18 | delete_older_directories(os.path.join(cwd, 'build'))
|
21 | 19 |
|
22 | 20 | def find_and_activate_venv():
|
23 |
| - # Get the current working directory |
24 | 21 | cwd = os.getcwd()
|
25 | 22 |
|
26 |
| - # Delete 'dist' and 'build' directories |
27 | 23 | find_and_delete_dist_and_build(cwd)
|
28 | 24 |
|
29 |
| - # Walk through the current directory and its subdirectories |
30 | 25 | for root, dirs, files in os.walk(cwd):
|
31 |
| - # Check if the directory contains a virtual environment |
32 | 26 | if 'Scripts' in dirs or 'bin' in dirs:
|
33 | 27 | scripts_path = os.path.join(root, 'Scripts' if platform.system() == 'Windows' else 'bin')
|
34 | 28 | required_files = {'activate.bat' if platform.system() == 'Windows' else 'activate'}
|
35 | 29 |
|
36 |
| - # Check if the required activation file is present in the Scripts/bin directory |
37 | 30 | if required_files.issubset(set(os.listdir(scripts_path))):
|
38 | 31 | print(f"Virtual environment found and activated at: {root}")
|
39 | 32 |
|
40 |
| - # Activate the virtual environment, upgrade pip, and check pip version |
41 | 33 | if platform.system() == 'Windows':
|
42 | 34 | activate_command = f'cmd /k ""{os.path.join(scripts_path, "activate.bat")}" && python.exe -m pip install --upgrade pip && pyinstaller -F -c main.py"'
|
43 | 35 | else:
|
|
0 commit comments