@@ -159,7 +159,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(
159
159
m .assert_called_with (
160
160
Path (tmp_dir ) / "{}-py3.7" .format (venv_name ),
161
161
executable = "python3.7" ,
162
- flags = {"always-copy" : False },
162
+ flags = {"always-copy" : False , "system-site-packages" : False },
163
163
)
164
164
165
165
envs_file = TOMLFile (Path (tmp_dir ) / "envs.toml" )
@@ -279,7 +279,7 @@ def test_activate_activates_different_virtualenv_with_envs_file(
279
279
m .assert_called_with (
280
280
Path (tmp_dir ) / "{}-py3.6" .format (venv_name ),
281
281
executable = "python3.6" ,
282
- flags = {"always-copy" : False },
282
+ flags = {"always-copy" : False , "system-site-packages" : False },
283
283
)
284
284
285
285
assert envs_file .exists ()
@@ -333,7 +333,7 @@ def test_activate_activates_recreates_for_different_patch(
333
333
build_venv_m .assert_called_with (
334
334
Path (tmp_dir ) / "{}-py3.7" .format (venv_name ),
335
335
executable = "python3.7" ,
336
- flags = {"always-copy" : False },
336
+ flags = {"always-copy" : False , "system-site-packages" : False },
337
337
)
338
338
remove_venv_m .assert_called_with (Path (tmp_dir ) / "{}-py3.7" .format (venv_name ))
339
339
@@ -661,7 +661,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_generic_
661
661
m .assert_called_with (
662
662
config_virtualenvs_path / "{}-py3.7" .format (venv_name ),
663
663
executable = "python3" ,
664
- flags = {"always-copy" : False },
664
+ flags = {"always-copy" : False , "system-site-packages" : False },
665
665
)
666
666
667
667
@@ -685,7 +685,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
685
685
m .assert_called_with (
686
686
config_virtualenvs_path / "{}-py3.9" .format (venv_name ),
687
687
executable = "python3.9" ,
688
- flags = {"always-copy" : False },
688
+ flags = {"always-copy" : False , "system-site-packages" : False },
689
689
)
690
690
691
691
@@ -769,7 +769,7 @@ def test_create_venv_uses_patch_version_to_detect_compatibility(
769
769
config_virtualenvs_path
770
770
/ "{}-py{}.{}" .format (venv_name , version .major , version .minor ),
771
771
executable = None ,
772
- flags = {"always-copy" : False },
772
+ flags = {"always-copy" : False , "system-site-packages" : False },
773
773
)
774
774
775
775
@@ -804,7 +804,7 @@ def test_create_venv_uses_patch_version_to_detect_compatibility_with_executable(
804
804
config_virtualenvs_path
805
805
/ "{}-py{}.{}" .format (venv_name , version .major , version .minor - 1 ),
806
806
executable = "python{}.{}" .format (version .major , version .minor - 1 ),
807
- flags = {"always-copy" : False },
807
+ flags = {"always-copy" : False , "system-site-packages" : False },
808
808
)
809
809
810
810
@@ -838,7 +838,7 @@ def test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir(
838
838
m .assert_called_with (
839
839
poetry .file .parent / ".venv" ,
840
840
executable = "python3.7" ,
841
- flags = {"always-copy" : False },
841
+ flags = {"always-copy" : False , "system-site-packages" : False },
842
842
)
843
843
844
844
envs_file = TOMLFile (Path (tmp_dir ) / "virtualenvs" / "envs.toml" )
@@ -875,3 +875,17 @@ def test_venv_has_correct_paths(tmp_venv):
875
875
assert paths .get ("platlib" ) is not None
876
876
assert paths .get ("scripts" ) is not None
877
877
assert tmp_venv .site_packages .path == Path (paths ["purelib" ])
878
+
879
+
880
+ def test_env_system_packages (tmp_path , config ):
881
+ venv_path = tmp_path / "venv"
882
+ pyvenv_cfg = venv_path / "pyvenv.cfg"
883
+
884
+ EnvManager (config ).build_venv (path = venv_path , flags = {"system-site-packages" : True })
885
+
886
+ if sys .version_info >= (3 , 3 ):
887
+ assert "include-system-site-packages = true" in pyvenv_cfg .read_text ()
888
+ elif (2 , 6 ) < sys .version_info < (3 , 0 ):
889
+ assert not venv_path .joinpath (
890
+ "lib" , "python2.7" , "no-global-site-packages.txt"
891
+ ).exists ()
0 commit comments