| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dd8ee4f commit a262a06
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,8 @@ | |||
| 10 | 10 | import logging | |
| 11 | 11 | import os | |
| 12 | 12 | import os.path as osp | |
| 13 | + import subprocess | ||
| 14 | + import sys | ||
| 13 | 15 | import tempfile | |
| 14 | 16 | import textwrap | |
| 15 | 17 | import time | |
@@ -403,13 +405,20 @@ class VirtualEnvironment: | |||
| 403 | 405 | ||
| 404 | 406 | __slots__ = ("_env_dir",) | |
| 405 | 407 | ||
| 406 | - def __init__(self, env_dir, *, need_pip): | ||
| 408 | + def __init__(self, env_dir, *, with_pip): | ||
| 407 | 409 | if os.name == "nt": | |
| 408 | 410 | self._env_dir = osp.realpath(env_dir) | |
| 409 | - venv.create(self.env_dir, symlinks=False, with_pip=need_pip, upgrade_deps=need_pip) | ||
| 411 | + venv.create(self.env_dir, symlinks=False, with_pip=with_pip) | ||
| 410 | 412 | else: | |
| 411 | 413 | self._env_dir = env_dir | |
| 412 | - venv.create(self.env_dir, symlinks=True, with_pip=need_pip, upgrade_deps=need_pip) | ||
| 414 | + venv.create(self.env_dir, symlinks=True, with_pip=with_pip) | ||
| 415 | + | ||
| 416 | + if with_pip: | ||
| 417 | + # The upgrade_deps parameter to venv.create is 3.9+ only, so do it this way. | ||
| 418 | + command = [self.python, "-m", "pip", "install", "--upgrade", "pip"] | ||
| 419 | + if sys.version_info < (3, 12): | ||
| 420 | + command.append("setuptools") | ||
| 421 | + subprocess.check_output(command) | ||
| 413 | 422 | ||
| 414 | 423 | @property | |
| 415 | 424 | def env_dir(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1060,7 +1060,7 @@ def test_hook_uses_shell_not_from_cwd(self, rw_dir, case): | |||
| 1060 | 1060 | # from a venv may not run when copied outside of it, and a global interpreter | |
| 1061 | 1061 | # won't run when copied to a different location if it was installed from the | |
| 1062 | 1062 | # Microsoft Store. So we make a new venv in rw_dir and use its interpreter. | |
| 1063 | - venv = VirtualEnvironment(rw_dir, need_pip=False) | ||
| 1063 | + venv = VirtualEnvironment(rw_dir, with_pip=False) | ||
| 1064 | 1064 | shutil.copy(venv.python, Path(rw_dir, shell_name)) | |
| 1065 | 1065 | shutil.copy(fixture_path("polyglot"), hook_path("polyglot", repo.git_dir)) | |
| 1066 | 1066 | payload = Path(rw_dir, "payload.txt") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,7 +64,7 @@ def test_installation(self, rw_dir): | |||
| 64 | 64 | ||
| 65 | 65 | @staticmethod | |
| 66 | 66 | def _set_up_venv(rw_dir): | |
| 67 | - venv = VirtualEnvironment(rw_dir, need_pip=True) | ||
| 67 | + venv = VirtualEnvironment(rw_dir, with_pip=True) | ||
| 68 | 68 | os.symlink( | |
| 69 | 69 | os.path.dirname(os.path.dirname(__file__)), | |
| 70 | 70 | venv.sources, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments