diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-09-14 14:59:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-14 14:59:52 -0400 |
commit | 351b5fec817e6ed568b56017e7402ea6ea9d55a4 (patch) | |
tree | 59b1235c47e98bf3fdff71c574cd077cf74a2785 | |
parent | 629ad3da717eb360eda53874e590b48f0a5acd2e (diff) | |
parent | 1f23f9a25e6c91554954185e84497056062093be (diff) | |
download | external_python_setuptools-351b5fec817e6ed568b56017e7402ea6ea9d55a4.tar.gz external_python_setuptools-351b5fec817e6ed568b56017e7402ea6ea9d55a4.tar.bz2 external_python_setuptools-351b5fec817e6ed568b56017e7402ea6ea9d55a4.zip |
Merge pull request #786 from s-t-e-v-e-n-k/no-parse-requirement-arg-duplication
Don't duplicate error case in package_index
-rwxr-xr-x | setuptools/command/easy_install.py | 14 | ||||
-rwxr-xr-x | setuptools/package_index.py | 17 |
2 files changed, 13 insertions, 18 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index e8b90c70..a3792ce2 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -49,8 +49,9 @@ from setuptools.sandbox import run_setup from setuptools.py31compat import get_path, get_config_vars from setuptools.command import setopt from setuptools.archive_util import unpack_archive -from setuptools.package_index import PackageIndex -from setuptools.package_index import URL_SCHEME +from setuptools.package_index import ( + PackageIndex, parse_requirement_arg, URL_SCHEME, +) from setuptools.command import bdist_egg, egg_info from pkg_resources import ( yield_lines, normalize_path, resource_string, ensure_directory, @@ -1522,15 +1523,6 @@ def get_exe_prefixes(exe_filename): return prefixes -def parse_requirement_arg(spec): - try: - return Requirement.parse(spec) - except ValueError: - raise DistutilsError( - "Not a URL, existing file, or requirement spec: %r" % (spec,) - ) - - class PthDistributions(Environment): """A .pth file with Distribution paths in it""" diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 82cd608f..3fb39269 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -52,6 +52,15 @@ _tmpl = "setuptools/{setuptools.__version__} Python-urllib/{py_major}" user_agent = _tmpl.format(py_major=sys.version[:3], **globals()) +def parse_requirement_arg(spec): + try: + return Requirement.parse(spec) + except ValueError: + raise DistutilsError( + "Not a URL, existing file, or requirement spec: %r" % (spec,) + ) + + def parse_bdist_wininst(name): """Return (base,pyversion) or (None,None) for possible .exe name""" @@ -561,13 +570,7 @@ class PackageIndex(Environment): # Existing file or directory, just return it return spec else: - try: - spec = Requirement.parse(spec) - except ValueError: - raise DistutilsError( - "Not a URL, existing file, or requirement spec: %r" % - (spec,) - ) + spec = parse_requirement_arg(spec) return getattr(self.fetch_distribution(spec, tmpdir), 'location', None) def fetch_distribution( |