summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages/python_venv.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-06-14 09:11:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-06-14 09:11:24 +0000
commit1312af87e5908ac252c0659a60216e96ec5b23bd (patch)
tree7621ad7267ffb9ecd8339983fd83150abc99082f /pre_commit/languages/python_venv.py
parentReleasing debian version 2.3.0-1. (diff)
downloadpre-commit-1312af87e5908ac252c0659a60216e96ec5b23bd.tar.xz
pre-commit-1312af87e5908ac252c0659a60216e96ec5b23bd.zip
Merging upstream version 2.5.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/languages/python_venv.py')
-rw-r--r--pre_commit/languages/python_venv.py46
1 files changed, 0 insertions, 46 deletions
diff --git a/pre_commit/languages/python_venv.py b/pre_commit/languages/python_venv.py
deleted file mode 100644
index 5404c8b..0000000
--- a/pre_commit/languages/python_venv.py
+++ /dev/null
@@ -1,46 +0,0 @@
-import os.path
-
-from pre_commit.languages import python
-from pre_commit.util import CalledProcessError
-from pre_commit.util import cmd_output
-from pre_commit.util import cmd_output_b
-
-ENVIRONMENT_DIR = 'py_venv'
-get_default_version = python.get_default_version
-
-
-def orig_py_exe(exe: str) -> str: # pragma: no cover (platform specific)
- """A -mvenv virtualenv made from a -mvirtualenv virtualenv installs
- packages to the incorrect location. Attempt to find the _original_ exe
- and invoke `-mvenv` from there.
-
- See:
- - https://github.com/pre-commit/pre-commit/issues/755
- - https://github.com/pypa/virtualenv/issues/1095
- - https://bugs.python.org/issue30811
- """
- try:
- prefix_script = 'import sys; print(sys.real_prefix)'
- _, prefix, _ = cmd_output(exe, '-c', prefix_script)
- prefix = prefix.strip()
- except CalledProcessError:
- # not created from -mvirtualenv
- return exe
-
- if os.name == 'nt':
- expected = os.path.join(prefix, 'python.exe')
- else:
- expected = os.path.join(prefix, 'bin', os.path.basename(exe))
-
- if os.path.exists(expected):
- return expected
- else:
- return exe
-
-
-def make_venv(envdir: str, python: str) -> None:
- cmd_output_b(orig_py_exe(python), '-mvenv', envdir, cwd='/')
-
-
-_interface = python.py_interface(ENVIRONMENT_DIR, make_venv)
-in_env, healthy, run_hook, install_environment = _interface