You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
5.2 KiB
129 lines
5.2 KiB
From 9b8653289e84c6d24b5da1ffc8c21e8c204fc48c Mon Sep 17 00:00:00 2001
|
|
From: Lumir Balhar <lbalhar@redhat.com>
|
|
Date: Mon, 3 Jan 2022 11:50:56 +0100
|
|
Subject: [PATCH] rpm wheels
|
|
|
|
---
|
|
src/virtualenv/run/__init__.py | 5 +++--
|
|
src/virtualenv/seed/embed/base_embed.py | 7 +++++-
|
|
src/virtualenv/seed/embed/pip_invoke.py | 1 +
|
|
.../seed/embed/via_app_data/via_app_data.py | 1 +
|
|
src/virtualenv/seed/wheels/embed/__init__.py | 3 +++
|
|
src/virtualenv/util/path/_system_wheels.py | 22 +++++++++++++++++++
|
|
6 files changed, 36 insertions(+), 3 deletions(-)
|
|
create mode 100644 src/virtualenv/util/path/_system_wheels.py
|
|
|
|
diff --git a/src/virtualenv/run/__init__.py b/src/virtualenv/run/__init__.py
|
|
index e8e7ab1..617cf67 100644
|
|
--- a/src/virtualenv/run/__init__.py
|
|
+++ b/src/virtualenv/run/__init__.py
|
|
@@ -89,8 +89,9 @@ def build_parser_only(args=None):
|
|
|
|
def handle_extra_commands(options):
|
|
if options.upgrade_embed_wheels:
|
|
- result = manual_upgrade(options.app_data, options.env)
|
|
- raise SystemExit(result)
|
|
+ # result = manual_upgrade(options.app_data, options.env)
|
|
+ logging.warning("virtualenv installed from the RPM package uses wheels from RPM packages as well. Updating them via virtualenv is not possible. The RPM packaged wheels are updated together with other RPM packages of the system.")
|
|
+ raise SystemExit(1)
|
|
|
|
|
|
def load_app_data(args, parser, options):
|
|
diff --git a/src/virtualenv/seed/embed/base_embed.py b/src/virtualenv/seed/embed/base_embed.py
|
|
index c794e83..0867e9c 100644
|
|
--- a/src/virtualenv/seed/embed/base_embed.py
|
|
+++ b/src/virtualenv/seed/embed/base_embed.py
|
|
@@ -6,11 +6,12 @@ from six import add_metaclass
|
|
|
|
from virtualenv.util.path import Path
|
|
from virtualenv.util.six import ensure_str, ensure_text
|
|
+from virtualenv.util.path._system_wheels import get_system_wheels_paths
|
|
|
|
from ..seeder import Seeder
|
|
from ..wheels import Version
|
|
|
|
-PERIODIC_UPDATE_ON_BY_DEFAULT = True
|
|
+PERIODIC_UPDATE_ON_BY_DEFAULT = False
|
|
|
|
|
|
@add_metaclass(ABCMeta)
|
|
@@ -116,3 +117,7 @@ class BaseEmbed(Seeder):
|
|
|
|
def __repr__(self):
|
|
return ensure_str(self.__unicode__())
|
|
+
|
|
+ def insert_system_wheels_paths(self, creator):
|
|
+ system_wheels_paths = get_system_wheels_paths(creator.interpreter.executable)
|
|
+ self.extra_search_dir = list(system_wheels_paths) + self.extra_search_dir
|
|
diff --git a/src/virtualenv/seed/embed/pip_invoke.py b/src/virtualenv/seed/embed/pip_invoke.py
|
|
index c935c02..2d9d80d 100644
|
|
--- a/src/virtualenv/seed/embed/pip_invoke.py
|
|
+++ b/src/virtualenv/seed/embed/pip_invoke.py
|
|
@@ -17,6 +17,7 @@ class PipInvoke(BaseEmbed):
|
|
def run(self, creator):
|
|
if not self.enabled:
|
|
return
|
|
+ self.insert_system_wheels_paths(creator)
|
|
for_py_version = creator.interpreter.version_release_str
|
|
with self.get_pip_install_cmd(creator.exe, for_py_version) as cmd:
|
|
env = pip_wheel_env_run(self.extra_search_dir, self.app_data, self.env)
|
|
diff --git a/src/virtualenv/seed/embed/via_app_data/via_app_data.py b/src/virtualenv/seed/embed/via_app_data/via_app_data.py
|
|
index 9a98a70..a0ecadf 100644
|
|
--- a/src/virtualenv/seed/embed/via_app_data/via_app_data.py
|
|
+++ b/src/virtualenv/seed/embed/via_app_data/via_app_data.py
|
|
@@ -39,6 +39,7 @@ class FromAppData(BaseEmbed):
|
|
def run(self, creator):
|
|
if not self.enabled:
|
|
return
|
|
+ self.insert_system_wheels_paths(creator)
|
|
with self._get_seed_wheels(creator) as name_to_whl:
|
|
pip_version = name_to_whl["pip"].version_tuple if "pip" in name_to_whl else None
|
|
installer_class = self.installer_class(pip_version)
|
|
diff --git a/src/virtualenv/seed/wheels/embed/__init__.py b/src/virtualenv/seed/wheels/embed/__init__.py
|
|
index d38ccf8..4b80d98 100644
|
|
--- a/src/virtualenv/seed/wheels/embed/__init__.py
|
|
+++ b/src/virtualenv/seed/wheels/embed/__init__.py
|
|
@@ -48,8 +48,11 @@ BUNDLE_SUPPORT = {
|
|
}
|
|
MAX = "3.11"
|
|
|
|
+# Redefined here because bundled wheels are removed in RPM build
|
|
+BUNDLE_SUPPORT = None
|
|
|
|
def get_embed_wheel(distribution, for_py_version):
|
|
+ return None # BUNDLE_SUPPORT == None anyway
|
|
path = BUNDLE_FOLDER / (BUNDLE_SUPPORT.get(for_py_version, {}) or BUNDLE_SUPPORT[MAX]).get(distribution)
|
|
return Wheel.from_path(path)
|
|
|
|
diff --git a/src/virtualenv/util/path/_system_wheels.py b/src/virtualenv/util/path/_system_wheels.py
|
|
new file mode 100644
|
|
index 0000000..a968dee
|
|
--- /dev/null
|
|
+++ b/src/virtualenv/util/path/_system_wheels.py
|
|
@@ -0,0 +1,22 @@
|
|
+from subprocess import check_output, CalledProcessError
|
|
+
|
|
+from virtualenv.util.path import Path
|
|
+
|
|
+
|
|
+def get_system_wheels_paths(executable):
|
|
+ # ensurepip wheels
|
|
+ # We need subprocess here to check ensurepip with the Python we are creating
|
|
+ # a new virtual environment for
|
|
+ try:
|
|
+ ensurepip_path = check_output((executable, "-u", "-c", 'import ensurepip; print(ensurepip.__path__[0])'), universal_newlines=True)
|
|
+ ensurepip_path = Path(ensurepip_path.strip()) / "_bundled"
|
|
+ except CalledProcessError:
|
|
+ pass
|
|
+ else:
|
|
+ if ensurepip_path.is_dir():
|
|
+ yield ensurepip_path
|
|
+
|
|
+ # Standard wheels path
|
|
+ wheels_dir = Path("/usr/share/python-wheels")
|
|
+ if wheels_dir.exists():
|
|
+ yield wheels_dir
|
|
--
|
|
2.33.1
|
|
|