Commit ce433a1c17a0204b71c17849a815b8f5f31ba2d9
1 parent
48dfbf78
Update ez_setup.py
This pulls setuptools 33.1.1 – the last version that works reliably with zc.buildout.
Showing
1 changed file
with
6 additions
and
29 deletions
@@ -6,6 +6,8 @@ Setuptools bootstrapping installer. | @@ -6,6 +6,8 @@ Setuptools bootstrapping installer. | ||
6 | Maintained at https://github.com/pypa/setuptools/tree/bootstrap. | 6 | Maintained at https://github.com/pypa/setuptools/tree/bootstrap. |
7 | 7 | ||
8 | Run this script to install or upgrade setuptools. | 8 | Run this script to install or upgrade setuptools. |
9 | + | ||
10 | +This method is DEPRECATED. Check https://github.com/pypa/setuptools/issues/581 for more details. | ||
9 | """ | 11 | """ |
10 | 12 | ||
11 | import os | 13 | import os |
@@ -18,25 +20,22 @@ import subprocess | @@ -18,25 +20,22 @@ import subprocess | ||
18 | import platform | 20 | import platform |
19 | import textwrap | 21 | import textwrap |
20 | import contextlib | 22 | import contextlib |
21 | -import json | ||
22 | -import codecs | 23 | +import warnings |
23 | 24 | ||
24 | from distutils import log | 25 | from distutils import log |
25 | 26 | ||
26 | try: | 27 | try: |
27 | from urllib.request import urlopen | 28 | from urllib.request import urlopen |
28 | - from urllib.parse import urljoin | ||
29 | except ImportError: | 29 | except ImportError: |
30 | from urllib2 import urlopen | 30 | from urllib2 import urlopen |
31 | - from urlparse import urljoin | ||
32 | 31 | ||
33 | try: | 32 | try: |
34 | from site import USER_SITE | 33 | from site import USER_SITE |
35 | except ImportError: | 34 | except ImportError: |
36 | USER_SITE = None | 35 | USER_SITE = None |
37 | 36 | ||
38 | -LATEST = object() | ||
39 | -DEFAULT_VERSION = "18.3.2" | 37 | +# 33.1.1 is the last version that supports setuptools self upgrade/installation. |
38 | +DEFAULT_VERSION = "33.1.1" | ||
40 | DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/" | 39 | DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/" |
41 | DEFAULT_SAVE_DIR = os.curdir | 40 | DEFAULT_SAVE_DIR = os.curdir |
42 | 41 | ||
@@ -157,7 +156,6 @@ def use_setuptools( | @@ -157,7 +156,6 @@ def use_setuptools( | ||
157 | Return None. Raise SystemExit if the requested version | 156 | Return None. Raise SystemExit if the requested version |
158 | or later cannot be installed. | 157 | or later cannot be installed. |
159 | """ | 158 | """ |
160 | - version = _resolve_version(version) | ||
161 | to_dir = os.path.abspath(to_dir) | 159 | to_dir = os.path.abspath(to_dir) |
162 | 160 | ||
163 | # prior to importing, capture the module state for | 161 | # prior to importing, capture the module state for |
@@ -344,7 +342,6 @@ def download_setuptools( | @@ -344,7 +342,6 @@ def download_setuptools( | ||
344 | ``downloader_factory`` should be a function taking no arguments and | 342 | ``downloader_factory`` should be a function taking no arguments and |
345 | returning a function for downloading a URL to a target. | 343 | returning a function for downloading a URL to a target. |
346 | """ | 344 | """ |
347 | - version = _resolve_version(version) | ||
348 | # making sure we use the absolute path | 345 | # making sure we use the absolute path |
349 | to_dir = os.path.abspath(to_dir) | 346 | to_dir = os.path.abspath(to_dir) |
350 | zip_name = "setuptools-%s.zip" % version | 347 | zip_name = "setuptools-%s.zip" % version |
@@ -357,27 +354,6 @@ def download_setuptools( | @@ -357,27 +354,6 @@ def download_setuptools( | ||
357 | return os.path.realpath(saveto) | 354 | return os.path.realpath(saveto) |
358 | 355 | ||
359 | 356 | ||
360 | -def _resolve_version(version): | ||
361 | - """ | ||
362 | - Resolve LATEST version | ||
363 | - """ | ||
364 | - if version is not LATEST: | ||
365 | - return version | ||
366 | - | ||
367 | - meta_url = urljoin(DEFAULT_URL, '/pypi/setuptools/json') | ||
368 | - resp = urlopen(meta_url) | ||
369 | - with contextlib.closing(resp): | ||
370 | - try: | ||
371 | - charset = resp.info().get_content_charset() | ||
372 | - except Exception: | ||
373 | - # Python 2 compat; assume UTF-8 | ||
374 | - charset = 'UTF-8' | ||
375 | - reader = codecs.getreader(charset) | ||
376 | - doc = json.load(reader(resp)) | ||
377 | - | ||
378 | - return str(doc['info']['version']) | ||
379 | - | ||
380 | - | ||
381 | def _build_install_args(options): | 357 | def _build_install_args(options): |
382 | """ | 358 | """ |
383 | Build the arguments to 'python setup.py install' on the setuptools package. | 359 | Build the arguments to 'python setup.py install' on the setuptools package. |
@@ -433,4 +409,5 @@ def main(): | @@ -433,4 +409,5 @@ def main(): | ||
433 | return _install(archive, _build_install_args(options)) | 409 | return _install(archive, _build_install_args(options)) |
434 | 410 | ||
435 | if __name__ == '__main__': | 411 | if __name__ == '__main__': |
412 | + warnings.warn("ez_setup.py is deprecated, check https://github.com/pypa/setuptools/issues/581 for more info; use pip to install setuptools") | ||
436 | sys.exit(main()) | 413 | sys.exit(main()) |
Please
register
or
login
to post a comment