|
|
9941a6 |
From b7b8a713d9f1ebac6430fd0fc10175ed37b834ee Mon Sep 17 00:00:00 2001
|
|
|
9941a6 |
From: Lumir Balhar <lbalhar@redhat.com>
|
|
|
9941a6 |
Date: Thu, 18 Mar 2021 13:08:52 +0100
|
|
|
9941a6 |
Subject: [PATCH] rpm
|
|
|
9941a6 |
|
|
|
9941a6 |
---
|
|
|
9941a6 |
virtualenv.py | 66 ++++++++++++++++++++++++++++++++++++++++++---------
|
|
|
9941a6 |
1 file changed, 55 insertions(+), 11 deletions(-)
|
|
|
9941a6 |
|
|
|
1148d3 |
diff --git a/virtualenv.py b/virtualenv.py
|
|
|
9941a6 |
index 5699998..9854324 100755
|
|
|
1148d3 |
--- a/virtualenv.py
|
|
|
1148d3 |
+++ b/virtualenv.py
|
|
|
1148d3 |
@@ -39,9 +39,9 @@ except ImportError:
|
|
|
1148d3 |
__version__ = "15.1.0"
|
|
|
1148d3 |
virtualenv_version = __version__ # legacy
|
|
|
1148d3 |
|
|
|
1148d3 |
-if sys.version_info < (2, 6):
|
|
|
1148d3 |
+if sys.version_info < (2, 7):
|
|
|
1148d3 |
print('ERROR: %s' % sys.exc_info()[1])
|
|
|
1148d3 |
- print('ERROR: this script requires Python 2.6 or greater.')
|
|
|
1148d3 |
+ print('ERROR: this script requires Python 2.7 or greater.')
|
|
|
1148d3 |
sys.exit(101)
|
|
|
1148d3 |
|
|
|
1148d3 |
try:
|
|
|
9941a6 |
@@ -399,6 +399,8 @@ def _find_file(filename, dirs):
|
|
|
1148d3 |
def file_search_dirs():
|
|
|
1148d3 |
here = os.path.dirname(os.path.abspath(__file__))
|
|
|
1148d3 |
dirs = [here, join(here, 'virtualenv_support')]
|
|
|
1148d3 |
+ dirs.insert(1, '/usr/share/python{}-wheels'.format(sys.version_info[0]))
|
|
|
9941a6 |
+ dirs.insert(1, '/usr/share/python{}{}-wheels'.format(*sys.version_info[:2]))
|
|
|
1148d3 |
if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv':
|
|
|
1148d3 |
# Probably some boot script; just in case virtualenv is installed...
|
|
|
1148d3 |
try:
|
|
|
9941a6 |
@@ -859,7 +861,12 @@ def install_wheel(project_names, py_executable, search_dirs=None,
|
|
|
9941a6 |
import tempfile
|
|
|
9941a6 |
import os
|
|
|
9941a6 |
|
|
|
9941a6 |
- import pip
|
|
|
9941a6 |
+ try:
|
|
|
9941a6 |
+ from pip._internal import main as _main
|
|
|
9941a6 |
+ if type(_main) is type(sys): # <type 'module'>
|
|
|
9941a6 |
+ _main = _main.main # nested starting in Pip 19.3
|
|
|
9941a6 |
+ except ImportError:
|
|
|
9941a6 |
+ from pip import main as _main
|
|
|
9941a6 |
|
|
|
9941a6 |
try:
|
|
|
9941a6 |
cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
|
|
|
9941a6 |
@@ -878,7 +885,7 @@ def install_wheel(project_names, py_executable, search_dirs=None,
|
|
|
9941a6 |
args += ["--cert", cert_file.name]
|
|
|
9941a6 |
args += sys.argv[1:]
|
|
|
9941a6 |
|
|
|
9941a6 |
- sys.exit(pip.main(args))
|
|
|
9941a6 |
+ sys.exit(_main(args))
|
|
|
9941a6 |
finally:
|
|
|
9941a6 |
if cert_file is not None:
|
|
|
9941a6 |
os.remove(cert_file.name)
|
|
|
9941a6 |
@@ -1038,20 +1045,57 @@ def change_prefix(filename, dst_prefix):
|
|
|
9941a6 |
assert False, "Filename %s does not start with any of these prefixes: %s" % \
|
|
|
9941a6 |
(filename, prefixes)
|
|
|
9941a6 |
|
|
|
9941a6 |
-def copy_required_modules(dst_prefix, symlink):
|
|
|
9941a6 |
- import imp
|
|
|
9941a6 |
+def find_module_filename(modname):
|
|
|
9941a6 |
+ if sys.version_info < (3, 4):
|
|
|
9941a6 |
+ # noinspection PyDeprecation
|
|
|
9941a6 |
+ import imp
|
|
|
9941a6 |
+
|
|
|
9941a6 |
+ try:
|
|
|
9941a6 |
+ file_handler, filepath, _ = imp.find_module(modname)
|
|
|
9941a6 |
+ except ImportError:
|
|
|
9941a6 |
+ return None
|
|
|
9941a6 |
+ else:
|
|
|
9941a6 |
+ if file_handler is not None:
|
|
|
9941a6 |
+ file_handler.close()
|
|
|
9941a6 |
+ return filepath
|
|
|
9941a6 |
+ else:
|
|
|
9941a6 |
+ import importlib.util
|
|
|
9941a6 |
|
|
|
9941a6 |
+ if sys.version_info < (3, 5):
|
|
|
9941a6 |
+
|
|
|
9941a6 |
+ def find_spec(modname):
|
|
|
9941a6 |
+ # noinspection PyDeprecation
|
|
|
9941a6 |
+ loader = importlib.find_loader(modname)
|
|
|
9941a6 |
+ if loader is None:
|
|
|
9941a6 |
+ return None
|
|
|
9941a6 |
+ else:
|
|
|
9941a6 |
+ return importlib.util.spec_from_loader(modname, loader)
|
|
|
9941a6 |
+
|
|
|
9941a6 |
+ else:
|
|
|
9941a6 |
+ find_spec = importlib.util.find_spec
|
|
|
9941a6 |
+
|
|
|
9941a6 |
+ spec = find_spec(modname)
|
|
|
9941a6 |
+ if spec is None:
|
|
|
9941a6 |
+ return None
|
|
|
9941a6 |
+ if not os.path.exists(spec.origin):
|
|
|
9941a6 |
+ # https://bitbucket.org/pypy/pypy/issues/2944/origin-for-several-builtin-modules
|
|
|
9941a6 |
+ # on pypy3, some builtin modules have a bogus build-time file path, ignore them
|
|
|
9941a6 |
+ return None
|
|
|
9941a6 |
+ filepath = spec.origin
|
|
|
9941a6 |
+ # https://www.python.org/dev/peps/pep-3147/#file guarantee to be non-cached
|
|
|
9941a6 |
+ if os.path.basename(filepath) == "__init__.py":
|
|
|
9941a6 |
+ filepath = os.path.dirname(filepath)
|
|
|
9941a6 |
+ return filepath
|
|
|
9941a6 |
+
|
|
|
9941a6 |
+def copy_required_modules(dst_prefix, symlink):
|
|
|
9941a6 |
for modname in REQUIRED_MODULES:
|
|
|
9941a6 |
if modname in sys.builtin_module_names:
|
|
|
9941a6 |
logger.info("Ignoring built-in bootstrap module: %s" % modname)
|
|
|
9941a6 |
continue
|
|
|
9941a6 |
- try:
|
|
|
9941a6 |
- f, filename, _ = imp.find_module(modname)
|
|
|
9941a6 |
- except ImportError:
|
|
|
9941a6 |
+ filename = find_module_filename(modname)
|
|
|
9941a6 |
+ if filename is None:
|
|
|
9941a6 |
logger.info("Cannot import bootstrap module: %s" % modname)
|
|
|
9941a6 |
else:
|
|
|
9941a6 |
- if f is not None:
|
|
|
9941a6 |
- f.close()
|
|
|
9941a6 |
# special-case custom readline.so on OS X, but not for pypy:
|
|
|
9941a6 |
if modname == 'readline' and sys.platform == 'darwin' and not (
|
|
|
9941a6 |
is_pypy or filename.endswith(join('lib-dynload', 'readline.so'))):
|
|
|
9941a6 |
--
|
|
|
9941a6 |
2.30.2
|
|
|
9941a6 |
|