File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -21,17 +21,18 @@ def inherit_site_packages(venv_path):
21
21
len (target_venv_glob_matches ) == 1
22
22
), f"{ __file__ } expected to find one supported python version in venv { venv_path } but found: { target_venv_glob_matches } "
23
23
24
- # Create sitecustomize.py in target venv site-packages directory
25
- # Ref: https://docs.python.org/3/library/site.html#module-sitecustomize
26
- with open (os .path .join (target_venv_glob_matches [0 ], "sitecustomize.py" ), "w" ) as f :
27
- f .write ("import site\n \n " )
24
+ # Create a .pth file with site-packages directories to inherit, in the target venv site-packages directory
25
+ # Ref: https://docs.python.org/3/library/site.html#module-site
26
+ with open (
27
+ os .path .join (target_venv_glob_matches [0 ], "inherited-site-packages.pth" ), "w"
28
+ ) as f :
28
29
for site_packages_dir in site .getsitepackages ():
29
- f .write (f'site.addsitedir( "{ site_packages_dir } ") \n ' )
30
+ f .write (f"{ site_packages_dir } \n " )
30
31
print (site_packages_dir )
31
32
32
33
33
34
if __name__ == "__main__" :
34
35
assert (
35
36
len (sys .argv ) == 2
36
- ), f"{ __file__ } expects one argument: path to venv that should inherit site-packages of the current venv but got { sys .argv } "
37
+ ), f"{ __file__ } expects one argument: path to venv that should inherit site-packages of the current environment but got { sys .argv } "
37
38
inherit_site_packages (sys .argv [1 ])
You can’t perform that action at this time.
0 commit comments