[Python-modules-commits] [python-pip] 09/14: Proper setting of WHEEL_DIR.

Barry Warsaw barry at moszumanska.debian.org
Fri Jan 29 15:52:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

barry pushed a commit to branch dirtbike
in repository python-pip.

commit d38a7b5dc5fb78930dfe417cf0bb0e72957444da
Author: Barry Warsaw <barry at python.org>
Date:   Thu Jan 28 18:00:56 2016 -0500

    Proper setting of WHEEL_DIR.
---
 pip/_vendor/__init__.py | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/pip/_vendor/__init__.py b/pip/_vendor/__init__.py
index 9e124b9..e7a9c43 100644
--- a/pip/_vendor/__init__.py
+++ b/pip/_vendor/__init__.py
@@ -20,7 +20,36 @@ DEBUNDLED = True
 # add to the beginning of sys.path before attempting to import anything. This
 # is done to support downstream re-distributors like Debian and Fedora who
 # wish to create their own Wheels for our dependencies to aid in debundling.
-WHEEL_DIR = os.path.abspath(os.path.dirname(__file__))
+base_prefix = getattr(sys, 'base_prefix', None)
+real_prefix = getattr(sys, 'real_prefix', None)
+if base_prefix is None:
+    # Python 2 has no base_prefix at all.  It also has no pyvenv.  Fall back
+    # to checking real_prefix.
+    if real_prefix is None:
+        # We are not in a venv.
+        in_venv = False
+    else:
+        # We're in a Python 2 virtualenv created venv, but real_prefix should
+        # never be the same as sys.prefix.
+        assert sys.prefix != real_prefix
+        in_venv = True
+elif sys.prefix != base_prefix:
+    # We're in a Python 3, pyvenv created venv.
+    in_venv = True
+elif real_prefix is None:
+    # We're in Python 3, outside a venv, but base better equal prefix.
+    assert sys.prefix == base_prefix
+    in_venv = False
+else:
+    # We're in a Python 3, virtualenv created venv.
+    assert real_prefix != sys.prefix
+    in_venv = True
+
+
+if in_venv:
+    WHEEL_DIR = os.path.join(sys.prefix, 'lib', 'python-wheels')
+else:
+    WHEEL_DIR = '/usr/share/python-wheels'
 
 
 # Define a small helper function to alias our vendored modules to the real ones

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pip.git



More information about the Python-modules-commits mailing list