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 1fd2cb13860a9111c98a0151e1951fdbac49ee16 Mon Sep 17 00:00:00 2001
|
|
From: Lumir Balhar <lbalhar@redhat.com>
|
|
Date: Tue, 23 Jun 2020 09:02:20 +0200
|
|
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 8de7962..3df28b6 100644
|
|
--- a/src/virtualenv/run/__init__.py
|
|
+++ b/src/virtualenv/run/__init__.py
|
|
@@ -74,8 +74,9 @@ def build_parser_only(args=None):
|
|
|
|
def handle_extra_commands(options):
|
|
if options.upgrade_embed_wheels:
|
|
- result = manual_upgrade(options.app_data)
|
|
- raise SystemExit(result)
|
|
+ # result = manual_upgrade(options.app_data)
|
|
+ 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 f41b5fc..1b8e8fc 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)
|
|
@@ -115,3 +116,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 372e140..9bedb00 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)
|
|
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 779ee18..d6f2157 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 d118754..bc747d5 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.10"
|
|
|
|
+# 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.26.2
|
|
|