parent
3b8d8f6724
commit
7f4443442e
@ -1,54 +0,0 @@
|
||||
From 58ff51c482ed40a6b38766c90954d7d3edcaa0fb Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||
Date: Mon, 8 Nov 2021 15:54:18 +0100
|
||||
Subject: [PATCH] Fix test_custom_venv_install_scheme_is_prefered mocking if
|
||||
"venv" install scheme actually exists
|
||||
|
||||
The error this prevents was:
|
||||
|
||||
"""distutils.command.install
|
||||
|
||||
Implements the Distutils 'install' command."""
|
||||
|
||||
...
|
||||
|
||||
# Copy from sysconfig._INSTALL_SCHEMES
|
||||
for key in SCHEME_KEYS:
|
||||
for distutils_scheme_name, sys_scheme_name in (
|
||||
("unix_prefix", "posix_prefix"), ("unix_home", "posix_home"),
|
||||
("nt", "nt")):
|
||||
sys_key = key
|
||||
> sys_scheme = sysconfig._INSTALL_SCHEMES[sys_scheme_name]
|
||||
E KeyError: 'posix_home'
|
||||
---
|
||||
tests/unit/discovery/py_info/test_py_info.py | 9 ++++++++-
|
||||
1 file changed, 8 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/unit/discovery/py_info/test_py_info.py b/tests/unit/discovery/py_info/test_py_info.py
|
||||
index 053a6f906..d4c4bba25 100644
|
||||
--- a/tests/unit/discovery/py_info/test_py_info.py
|
||||
+++ b/tests/unit/discovery/py_info/test_py_info.py
|
||||
@@ -349,7 +349,6 @@ def test_custom_venv_install_scheme_is_prefered(mocker):
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
sysconfig_install_schemes = _stringify_schemes_dict(sysconfig_install_schemes)
|
||||
- mocker.patch("sysconfig._INSTALL_SCHEMES", sysconfig_install_schemes)
|
||||
|
||||
# On Python < 3.10, the distutils schemes are not derived from sysconfig schemes
|
||||
# So we mock them as well to assert the custom "venv" install scheme has priority
|
||||
@@ -367,7 +366,15 @@ def test_custom_venv_install_scheme_is_prefered(mocker):
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
distutils_schemes = _stringify_schemes_dict(distutils_schemes)
|
||||
+
|
||||
+ # We need to mock distutils first, so they don't see the mocked sysconfig,
|
||||
+ # if imported for the first time.
|
||||
+ # That can happen if the actual interpreter has the "venv" INSTALL_SCHEME
|
||||
+ # and hence this is the first time we are touching distutils in this process.
|
||||
+ # If distutils saw our mocked sysconfig INSTALL_SCHEMES, we would need
|
||||
+ # to define all install schemes.
|
||||
mocker.patch("distutils.command.install.INSTALL_SCHEMES", distutils_schemes)
|
||||
+ mocker.patch("sysconfig._INSTALL_SCHEMES", sysconfig_install_schemes)
|
||||
|
||||
pyinfo = PythonInfo()
|
||||
pyver = "{}.{}".format(pyinfo.version_info.major, pyinfo.version_info.minor)
|
@ -1,70 +0,0 @@
|
||||
From 5fe71e1126b6d4e5c3abc0d03c7c3709f1b1c1d4 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||
Date: Mon, 6 Dec 2021 15:42:33 +0100
|
||||
Subject: [PATCH] Use 'selectable' interface for entry points only when
|
||||
available
|
||||
|
||||
This reverts commit 17caadc974cb2a24f70374525596cd1160579594.
|
||||
---
|
||||
docs/changelog/2246.feature.rst | 1 +
|
||||
setup.cfg | 1 -
|
||||
src/virtualenv/run/plugin/base.py | 15 +++++++++++++--
|
||||
3 files changed, 14 insertions(+), 3 deletions(-)
|
||||
create mode 100644 docs/changelog/2246.feature.rst
|
||||
|
||||
diff --git a/docs/changelog/2246.feature.rst b/docs/changelog/2246.feature.rst
|
||||
new file mode 100644
|
||||
index 0000000..4be877d
|
||||
--- /dev/null
|
||||
+++ b/docs/changelog/2246.feature.rst
|
||||
@@ -0,0 +1 @@
|
||||
+Drop the runtime dependency of ``backports.entry-points-selectable`` - by :user:`hroncok`.
|
||||
diff --git a/setup.cfg b/setup.cfg
|
||||
index 70d77fb..1cec841 100644
|
||||
--- a/setup.cfg
|
||||
+++ b/setup.cfg
|
||||
@@ -40,7 +40,6 @@ project_urls =
|
||||
[options]
|
||||
packages = find:
|
||||
install_requires =
|
||||
- backports.entry_points_selectable>=1.0.4
|
||||
distlib>=0.3.1,<1
|
||||
filelock>=3.2,<4
|
||||
platformdirs>=2,<3
|
||||
diff --git a/src/virtualenv/run/plugin/base.py b/src/virtualenv/run/plugin/base.py
|
||||
index f1f4ee0..048c76a 100644
|
||||
--- a/src/virtualenv/run/plugin/base.py
|
||||
+++ b/src/virtualenv/run/plugin/base.py
|
||||
@@ -1,8 +1,16 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
+import sys
|
||||
from collections import OrderedDict
|
||||
|
||||
-from backports.entry_points_selectable import entry_points
|
||||
+if sys.version_info >= (3, 8):
|
||||
+ from importlib.metadata import entry_points
|
||||
+
|
||||
+ importlib_metadata_version = ()
|
||||
+else:
|
||||
+ from importlib_metadata import entry_points, version
|
||||
+
|
||||
+ importlib_metadata_version = tuple(int(i) for i in version("importlib_metadata").split(".")[:2])
|
||||
|
||||
|
||||
class PluginLoader(object):
|
||||
@@ -11,7 +19,10 @@ class PluginLoader(object):
|
||||
|
||||
@classmethod
|
||||
def entry_points_for(cls, key):
|
||||
- return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(group=key))
|
||||
+ if sys.version_info >= (3, 10) or importlib_metadata_version >= (3, 6):
|
||||
+ return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(group=key))
|
||||
+ else:
|
||||
+ return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
|
||||
|
||||
@staticmethod
|
||||
def entry_points():
|
||||
--
|
||||
2.33.1
|
||||
|
@ -1 +1 @@
|
||||
SHA512 (virtualenv-20.10.0.tar.gz) = df940aa29801a39d39be46d3518a99e93efb2113650abf81d00b4545183ec6806823ce8b754c5a3c951cb64e941944421046c709ed3de6a925489e5ac1988d48
|
||||
SHA512 (virtualenv-20.13.0.tar.gz) = 72aa8cffe92551479ad4ec93395597cd9f77ddaf2063e36d5836277199a96ab2d57236d94b99b7038a60ada103a2d8a37ae4b13ffaaa6ed8e786245d9fbbf6d6
|
||||
|
Loading…
Reference in new issue