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