File tree 1 file changed +3
-5
lines changed
1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change
1
+ # Script Developer: Gabriel Mihai Sandu
2
+ # GitHub Profile: https://github.com/Gabrieliam42
3
+
1
4
import os
2
5
import subprocess
3
6
import platform
4
7
5
8
def find_and_activate_venv ():
6
- # Get the current working directory
7
9
cwd = os .getcwd ()
8
10
9
- # Walk through the current directory and its subdirectories
10
11
for root , dirs , files in os .walk (cwd ):
11
- # Check if the directory contains a virtual environment
12
12
if 'Scripts' in dirs or 'bin' in dirs :
13
13
scripts_path = os .path .join (root , 'Scripts' if platform .system () == 'Windows' else 'bin' )
14
14
required_files = {'activate.bat' if platform .system () == 'Windows' else 'activate' }
15
15
16
- # Check if the required activation file is present in the Scripts/bin directory
17
16
if required_files .issubset (set (os .listdir (scripts_path ))):
18
17
print (f"Virtual environment found and activated at: { root } " )
19
18
20
- # Activate the virtual environment and upgrade pip
21
19
if platform .system () == 'Windows' :
22
20
activate_command = f'cmd /k ""{ os .path .join (scripts_path , "activate.bat" )} " && python.exe -m pip install --upgrade pip"'
23
21
else :
You can’t perform that action at this time.
0 commit comments