Merge lp:~barry/python/ensurepip into lp:~doko/python/pkg3.4-debian

Proposed by Barry Warsaw
Status: Needs review
Proposed branch: lp:~barry/python/ensurepip
Merge into: lp:~doko/python/pkg3.4-debian
Diff against target: 200 lines (+88/-13)
5 files modified
changelog (+10/-0)
control (+1/-1)
patches/ensurepip-venv-only.diff (+54/-0)
patches/ensurepip-wheels.diff (+22/-12)
patches/series (+1/-0)
To merge this branch: bzr merge lp:~barry/python/ensurepip
Reviewer Review Type Date Requested Status
Matthias Klose Pending
Review via email: mp+245351@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

105. By Barry Warsaw

d/patches/ensurepip-venv-only.diff: New patch to disallow the use of
ensurepip when used outside of a virtualenv or pyvenv virtual
environment, directing users to apt-get instead. Given by Donald Stufft.

104. By Barry Warsaw

d/patches/ensurepip-wheels.diff: Update to new locations. Given by
Donald Stufft.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'changelog'
2--- changelog 2014-12-11 21:38:43 +0000
3+++ changelog 2014-12-24 04:27:20 +0000
4@@ -1,3 +1,13 @@
5+python3.4 (3.4.2-4) UNRELEASED; urgency=medium
6+
7+ * d/patches/ensurepip-wheels.diff: Update to new locations. Given by
8+ Donald Stufft.
9+ * d/patches/ensurepip-venv-only.diff: New patch to disallow the use of
10+ ensurepip when used outside of a virtualenv or pyvenv virtual
11+ environment, directing users to apt-get instead. Given by Donald Stufft.
12+
13+ -- Barry Warsaw <barry@debian.org> Tue, 23 Dec 2014 13:34:25 -0500
14+
15 python3.4 (3.4.2-3) unstable; urgency=medium
16
17 * Update to 20141202 from the 3.4 branch.
18
19=== modified file 'control'
20--- control 2014-12-11 21:38:43 +0000
21+++ control 2014-12-24 04:27:20 +0000
22@@ -6,7 +6,7 @@
23 gcc (>= 4:4.9.2),
24 quilt, autoconf,
25 lsb-release, sharutils,
26- libreadline6-dev, libncursesw5-dev (>= 5.3), gcc (>= 4:4.9.1-1),
27+ libreadline6-dev, libncursesw5-dev (>= 5.3),
28 zlib1g-dev, libbz2-dev, liblzma-dev,
29 libgdbm-dev, libdb-dev,
30 tk-dev, blt-dev (>= 2.4z), libssl-dev,
31
32=== added file 'patches/ensurepip-venv-only.diff'
33--- patches/ensurepip-venv-only.diff 1970-01-01 00:00:00 +0000
34+++ patches/ensurepip-venv-only.diff 2014-12-24 04:27:20 +0000
35@@ -0,0 +1,54 @@
36+--- a/Lib/ensurepip/__init__.py
37++++ b/Lib/ensurepip/__init__.py
38+@@ -3,11 +3,38 @@
39+ import os.path
40+ import sys
41+ import tempfile
42+-import glob
43+
44+
45+ __all__ = ["version", "bootstrap"]
46+
47++def _ensurepip_is_disabled_in_debian_for_system():
48++ # Detect if ensurepip is being executed inside of a python-virtualenv
49++ # environment and return early if so.
50++ if hasattr(sys, 'real_prefix'):
51++ return
52++
53++ # Detect if ensurepip is being executed inside of a stdlib venv
54++ # environment and return early if so.
55++ if sys.prefix != getattr(sys, "base_prefix", sys.prefix):
56++ return
57++
58++ # If we've gotten here, then we are running inside of the system Python
59++ # and we don't want to use ensurepip to install into the system Python
60++ # so instead we'll redirect the user to using dpkg and apt-get.
61++ print("""\
62++ensurepip is disabled in Debian/Ubuntu for the system python.
63++
64++Python modules for the system python are usually handled by dpkg and apt-get.
65++
66++ apt-get install python-<module name>
67++
68++Install the python-pip package to use pip itself. Using pip together
69++with the system python might have unexpected results for any system installed
70++module, so use it on your own risk, or make sure to only use it in virtual
71++environments.
72++""")
73++ sys.exit(1)
74++
75+
76+ # pip currently requires ssl support, so we try to provide a nicer
77+ # error message when that is missing (http://bugs.python.org/issue19744)
78+@@ -68,6 +95,11 @@
79+
80+ Note that calling this function will alter both sys.path and os.environ.
81+ """
82++
83++ # Ensure that we are only running this inside of a virtual environment
84++ # of some kind.
85++ _ensurepip_is_disabled_in_debian_for_system()
86++
87+ if altinstall and default_pip:
88+ raise ValueError("Cannot use altinstall and default_pip together")
89+
90
91=== modified file 'patches/ensurepip-wheels.diff'
92--- patches/ensurepip-wheels.diff 2014-12-11 21:38:43 +0000
93+++ patches/ensurepip-wheels.diff 2014-12-24 04:27:20 +0000
94@@ -1,13 +1,15 @@
95-Index: b/Lib/ensurepip/__init__.py
96-===================================================================
97 --- a/Lib/ensurepip/__init__.py
98 +++ b/Lib/ensurepip/__init__.py
99-@@ -1,3 +1,4 @@
100+@@ -1,20 +1,17 @@
101 +import glob
102 import os
103 import os.path
104- import pkgutil
105-@@ -8,13 +9,9 @@ import tempfile
106+-import pkgutil
107+ import sys
108+ import tempfile
109++import glob
110+
111+
112 __all__ = ["version", "bootstrap"]
113
114
115@@ -22,7 +24,7 @@
116 try:
117 import ssl
118 except ImportError:
119-@@ -26,8 +23,8 @@ else:
120+@@ -26,8 +23,8 @@
121 pass
122
123 _PROJECTS = [
124@@ -33,7 +35,7 @@
125 ]
126
127
128-@@ -45,7 +42,10 @@ def version():
129+@@ -45,7 +42,10 @@
130 """
131 Returns a string specifying the bundled version of pip.
132 """
133@@ -45,7 +47,7 @@
134
135 def _disable_pip_configuration_settings():
136 # We deliberately ignore all pip environment variables
137-@@ -87,20 +87,39 @@ def bootstrap(*, root=None, upgrade=Fals
138+@@ -87,20 +87,47 @@
139 # omit pip and easy_install
140 os.environ["ENSUREPIP_OPTIONS"] = "install"
141
142@@ -71,12 +73,20 @@
143 +
144 with tempfile.TemporaryDirectory() as tmpdir:
145 + for project in _PROJECTS:
146++ # This directory is a "well known directory" which Debian has
147++ # patched pip to look in when attempting to locate wheels to use to
148++ # satisify the dependencies that pip normally bundles but Debian
149++ # has debundled. This is critically important and if this
150++ # directory changes then both python-pip and python-virtualenv
151++ # need to be updated to match.
152++ venv_wheel_dir = os.path.join(sys.prefix, 'lib', 'python-wheels')
153++ os.makedirs(venv_wheel_dir, exist_ok=True)
154 + try:
155 + with open('/usr/share/python-wheels/%s.dependencies' % project) as fp:
156 + dependencies = [line[:-1].split()[0] for line in fp.readlines()]
157 + except FileNotFoundError:
158 + dependencies = []
159-+ copy_wheels(dependencies, tmpdir, sys.path)
160++ copy_wheels(dependencies, venv_wheel_dir, sys.path)
161 +
162 # Put our bundled wheels into a temporary directory and construct the
163 # additional paths that need added to sys.path
164@@ -95,7 +105,7 @@
165
166 # Construct the arguments to be passed to the pip command
167 args = ["install", "--no-index", "--find-links", tmpdir]
168-@@ -113,7 +132,7 @@ def bootstrap(*, root=None, upgrade=Fals
169+@@ -113,7 +140,7 @@
170 if verbosity:
171 args += ["-" + "v" * verbosity]
172
173@@ -104,7 +114,7 @@
174
175 def _uninstall_helper(*, verbosity=0):
176 """Helper to support a clean default uninstall process on Windows
177-@@ -127,7 +146,8 @@ def _uninstall_helper(*, verbosity=0):
178+@@ -127,7 +154,8 @@
179 return
180
181 # If the pip version doesn't match the bundled one, leave it alone
182@@ -114,7 +124,7 @@
183 msg = ("ensurepip will only uninstall a matching version "
184 "({!r} installed, {!r} bundled)")
185 print(msg.format(pip.__version__, _PIP_VERSION), file=sys.stderr)
186-@@ -141,7 +161,7 @@ def _uninstall_helper(*, verbosity=0):
187+@@ -141,7 +169,7 @@
188 if verbosity:
189 args += ["-" + "v" * verbosity]
190
191
192=== modified file 'patches/series'
193--- patches/series 2014-12-11 21:38:43 +0000
194+++ patches/series 2014-12-24 04:27:20 +0000
195@@ -35,4 +35,5 @@
196 disable-some-tests.diff
197 issue21264.diff
198 ensurepip-wheels.diff
199+ensurepip-venv-only.diff
200 no-ssl3.diff

Subscribers

People subscribed via source and target branches

to all changes: