Attached is the patch that fixes this problem; it has already been forwarded
to Matthias.  The potentially controversial bit is the new dependency on
virtualenv, which is required to pick up the pip wheel.  Alternatively, we
could split python-virtualenv into a separate -support binary package, but
that of course would have to go through NEW.
diff --git a/debian/changelog b/debian/changelog
index 469d204..27eead3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+python3.5 (3.5.1-6ubuntu3~test0) UNRELEASED; urgency=medium
+
+  * d/patches/ensurepip-disabled.diff: Provide more debugging when the
+    ensurepip command fails.
+  * d/patches/ensurepip-wheels.diff: Update for compatibility with latest
+    python-pip packages.
+  * d/control.in: Add virtualenv to Depends of pythonX.Y-venv.
+
+ -- Barry Warsaw <ba...@ubuntu.com>  Mon, 29 Feb 2016 16:45:06 -0500
+
 python3.5 (3.5.1-6ubuntu2) xenial; urgency=medium
 
   * python3.5-venv: Drop the dependency on python-pip-whl, depend on
diff --git a/debian/control.in b/debian/control.in
index 3999830..bb5ac65 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -38,7 +38,7 @@ Architecture: any
 Multi-Arch: allowed
 Priority: @PRIO@
 Depends: @PVER@ (= ${binary:Version}),
- python-pip-whl (>= 8.0.2-7), ${shlibs:Depends}, ${misc:Depends}
+ python-pip-whl (>= 8.0.2-7), virtualenv, ${shlibs:Depends}, ${misc:Depends}
 Breaks: python3-pip (<< 1.5.6-4)
 Description: Interactive high-level object-oriented language (pyvenv binary, version @VER@)
  Python is a high-level, interactive, object-oriented language. Its @VER@ version
diff --git a/debian/patches/ensurepip-disabled.diff b/debian/patches/ensurepip-disabled.diff
index 7fbc575..1226e2e 100644
--- a/debian/patches/ensurepip-disabled.diff
+++ b/debian/patches/ensurepip-disabled.diff
@@ -1,10 +1,8 @@
 # DP: Disable ensurepip for the system installation, only enable it for virtual environments.
 
-Index: b/Lib/ensurepip/__init__.py
-===================================================================
 --- a/Lib/ensurepip/__init__.py
 +++ b/Lib/ensurepip/__init__.py
-@@ -8,6 +8,34 @@ import tempfile
+@@ -8,6 +8,34 @@
  
  __all__ = ["version", "bootstrap"]
  
@@ -39,7 +37,7 @@ Index: b/Lib/ensurepip/__init__.py
  
  # pip currently requires ssl support, so we try to provide a nicer
  # error message when that is missing (http://bugs.python.org/issue19744)
-@@ -68,6 +96,11 @@ def bootstrap(*, root=None, upgrade=Fals
+@@ -68,6 +96,11 @@
  
      Note that calling this function will alter both sys.path and os.environ.
      """
@@ -51,11 +49,9 @@ Index: b/Lib/ensurepip/__init__.py
      if altinstall and default_pip:
          raise ValueError("Cannot use altinstall and default_pip together")
  
-Index: b/Lib/venv/__init__.py
-===================================================================
 --- a/Lib/venv/__init__.py
 +++ b/Lib/venv/__init__.py
-@@ -254,7 +254,24 @@ class EnvBuilder:
+@@ -252,7 +252,28 @@
          # intended for the global Python environment
          cmd = [context.env_exe, '-Im', 'ensurepip', '--upgrade',
                                                      '--default-pip']
@@ -65,7 +61,9 @@ Index: b/Lib/venv/__init__.py
 +        # following command will produce an unhelpful error.  Let's make it
 +        # more user friendly.
 +        try:
-+            subprocess.check_output(cmd, stderr=subprocess.STDOUT)
++            subprocess.check_output(
++                cmd, stderr=subprocess.STDOUT,
++                universal_newlines=True)
 +        except subprocess.CalledProcessError:
 +            print("""\
 +The virtual environment was not created successfully because ensurepip is not
@@ -76,7 +74,9 @@ Index: b/Lib/venv/__init__.py
 +
 +You may need to use sudo with that command.  After installing the python3-venv
 +package, recreate your virtual environment.
-+""")
++
++Failing command: {}
++""".format(cmd))
 +            sys.exit(1)
  
      def setup_scripts(self, context):
diff --git a/debian/patches/ensurepip-wheels.diff b/debian/patches/ensurepip-wheels.diff
index 930e013..aae0dac 100644
--- a/debian/patches/ensurepip-wheels.diff
+++ b/debian/patches/ensurepip-wheels.diff
@@ -1,5 +1,3 @@
-Index: b/Lib/ensurepip/__init__.py
-===================================================================
 --- a/Lib/ensurepip/__init__.py
 +++ b/Lib/ensurepip/__init__.py
 @@ -1,3 +1,4 @@
@@ -7,7 +5,7 @@ Index: b/Lib/ensurepip/__init__.py
  import os
  import os.path
  import pkgutil
-@@ -8,13 +9,9 @@ import tempfile
+@@ -8,13 +9,9 @@
  __all__ = ["version", "bootstrap"]
  
  
@@ -22,7 +20,7 @@ Index: b/Lib/ensurepip/__init__.py
  try:
      import ssl
  except ImportError:
-@@ -26,8 +23,8 @@ else:
+@@ -26,8 +23,9 @@
          pass
  
  _PROJECTS = [
@@ -30,10 +28,11 @@ Index: b/Lib/ensurepip/__init__.py
 -    ("pip", _PIP_VERSION),
 +    "setuptools",
 +    "pip",
++    "pkg_resources",
  ]
  
  
-@@ -45,7 +42,10 @@ def version():
+@@ -45,7 +43,10 @@
      """
      Returns a string specifying the bundled version of pip.
      """
@@ -45,7 +44,7 @@ Index: b/Lib/ensurepip/__init__.py
  
  def _disable_pip_configuration_settings():
      # We deliberately ignore all pip environment variables
-@@ -87,20 +87,46 @@ def bootstrap(*, root=None, upgrade=Fals
+@@ -87,20 +88,44 @@
          # omit pip and easy_install
          os.environ["ENSUREPIP_OPTIONS"] = "install"
  
@@ -70,20 +69,18 @@ Index: b/Lib/ensurepip/__init__.py
 +            paths.append(dest)
 +
      with tempfile.TemporaryDirectory() as tmpdir:
-+        for project in _PROJECTS:
-+            # This directory is a "well known directory" which Debian has patched
-+            # pip to look in when attempting to locate wheels to use to satisify
-+            # the dependencies that pip normally bundles but Debian has debundled.
-+            # This is critically important and if this directory changes then both
-+            # python-pip and python-virtualenv needs updated to match.
-+            venv_wheel_dir = os.path.join(sys.prefix, 'lib', 'python-wheels')
-+            os.makedirs(venv_wheel_dir, exist_ok=True)
-+            try:
-+                with open('/usr/share/python-wheels/%s.dependencies' % project) as fp:
-+                    dependencies = [line[:-1].split()[0] for line in fp.readlines()]
-+            except FileNotFoundError:
-+                dependencies = []
-+            copy_wheels(dependencies, venv_wheel_dir, sys.path)
++        # This directory is a "well known directory" which Debian has patched
++        # pip to look in when attempting to locate wheels to use to satisify
++        # the dependencies that pip normally bundles but Debian has debundled.
++        # This is critically important and if this directory changes then both
++        # python-pip and python-virtualenv needs updated to match.
++        venv_wheel_dir = os.path.join(sys.prefix, 'share', 'python-wheels')
++        os.makedirs(venv_wheel_dir, exist_ok=True)
++        dependencies = [
++            os.path.basename(whl).split('-')[0]
++            for whl in glob.glob('/usr/share/python-wheels/*.whl')
++            ]
++        copy_wheels(dependencies, venv_wheel_dir, sys.path)
 +
          # Put our bundled wheels into a temporary directory and construct the
          # additional paths that need added to sys.path
@@ -102,7 +99,7 @@ Index: b/Lib/ensurepip/__init__.py
  
          # Construct the arguments to be passed to the pip command
          args = ["install", "--no-index", "--find-links", tmpdir]
-@@ -113,7 +139,7 @@ def bootstrap(*, root=None, upgrade=Fals
+@@ -113,7 +138,7 @@
          if verbosity:
              args += ["-" + "v" * verbosity]
  
@@ -111,7 +108,7 @@ Index: b/Lib/ensurepip/__init__.py
  
  def _uninstall_helper(*, verbosity=0):
      """Helper to support a clean default uninstall process on Windows
-@@ -127,7 +153,8 @@ def _uninstall_helper(*, verbosity=0):
+@@ -127,7 +152,8 @@
          return
  
      # If the pip version doesn't match the bundled one, leave it alone
@@ -121,7 +118,7 @@ Index: b/Lib/ensurepip/__init__.py
          msg = ("ensurepip will only uninstall a matching version "
                 "({!r} installed, {!r} bundled)")
          print(msg.format(pip.__version__, _PIP_VERSION), file=sys.stderr)
-@@ -141,7 +168,7 @@ def _uninstall_helper(*, verbosity=0):
+@@ -141,7 +167,7 @@
      if verbosity:
          args += ["-" + "v" * verbosity]
  

Reply via email to