Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #261 from bsipocz/update-helpers-v2.0
Browse files Browse the repository at this point in the history
Update astropy-helpers v2.0
  • Loading branch information
bsipocz committed Jul 8, 2017
2 parents 9913c64 + 98cdf78 commit ea1b229
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"use_read_the_docs": "y",
"sphinx_theme": "astropy-boostrap",
"initialize_git_repo": "y",
"astropy_helpers_version": "v1.3.1",
"astropy_helpers_version": "v2.0",
"_parent_project": "astropy",
"_install_requires": "['astropy']",
"_copy_without_render": [
Expand Down
36 changes: 7 additions & 29 deletions {{ cookiecutter.package_name }}/ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Maintained at https://github.com/pypa/setuptools/tree/bootstrap.
Run this script to install or upgrade setuptools.
This method is DEPRECATED. Check https://github.com/pypa/setuptools/issues/581 for more details.
"""

import os
Expand All @@ -18,30 +20,29 @@
import platform
import textwrap
import contextlib
import json
import codecs

from distutils import log

try:
from urllib.request import urlopen
from urllib.parse import urljoin
except ImportError:
from urllib2 import urlopen
from urlparse import urljoin

try:
from site import USER_SITE
except ImportError:
USER_SITE = None

LATEST = object()
DEFAULT_VERSION = LATEST
# 33.1.1 is the last version that supports setuptools self upgrade/installation.
DEFAULT_VERSION = "33.1.1"
DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/"
DEFAULT_SAVE_DIR = os.curdir
DEFAULT_DEPRECATION_MESSAGE = "ez_setup.py is deprecated and when using it setuptools will be pinned to {0} since it's the last version that supports setuptools self upgrade/installation, check https://github.com/pypa/setuptools/issues/581 for more info; use pip to install setuptools"

MEANINGFUL_INVALID_ZIP_ERR_MSG = 'Maybe {0} is corrupted, delete it and try again.'

log.warn(DEFAULT_DEPRECATION_MESSAGE.format(DEFAULT_VERSION))


def _python_cmd(*args):
"""
Expand Down Expand Up @@ -157,7 +158,6 @@ def use_setuptools(
Return None. Raise SystemExit if the requested version
or later cannot be installed.
"""
version = _resolve_version(version)
to_dir = os.path.abspath(to_dir)

# prior to importing, capture the module state for
Expand Down Expand Up @@ -344,7 +344,6 @@ def download_setuptools(
``downloader_factory`` should be a function taking no arguments and
returning a function for downloading a URL to a target.
"""
version = _resolve_version(version)
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
zip_name = "setuptools-%s.zip" % version
Expand All @@ -357,27 +356,6 @@ def download_setuptools(
return os.path.realpath(saveto)


def _resolve_version(version):
"""
Resolve LATEST version
"""
if version is not LATEST:
return version

meta_url = urljoin(DEFAULT_URL, '/pypi/setuptools/json')
resp = urlopen(meta_url)
with contextlib.closing(resp):
try:
charset = resp.info().get_content_charset()
except Exception:
# Python 2 compat; assume UTF-8
charset = 'UTF-8'
reader = codecs.getreader(charset)
doc = json.load(reader(resp))

return str(doc['info']['version'])


def _build_install_args(options):
"""
Build the arguments to 'python setup.py install' on the setuptools package.
Expand Down

0 comments on commit ea1b229

Please sign in to comment.