Skip to content

Commit 170657b

Browse files
committed
Setuptools now uses the 'packaging' package from pkg_resources, unifying the behavior around resolution of that package.
1 parent 9063c16 commit 170657b

File tree

4 files changed

+13
-21
lines changed

4 files changed

+13
-21
lines changed

pkg_resources/__init__.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@
7575
except ImportError:
7676
pass
7777

78-
import pkg_resources._vendor.packaging.version
79-
import pkg_resources._vendor.packaging.specifiers
80-
packaging = pkg_resources._vendor.packaging
78+
try:
79+
import packaging.version
80+
import packaging.specifiers
81+
except ImportError:
82+
# fallback to vendored version
83+
import pkg_resources._vendor.packaging.version
84+
import pkg_resources._vendor.packaging.specifiers
85+
packaging = pkg_resources._vendor.packaging
8186

8287

8388
class PEP440Warning(RuntimeWarning):

setuptools/command/egg_info.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
import re
1212
import sys
1313

14-
try:
15-
import packaging.version
16-
except ImportError:
17-
# fallback to vendored version
18-
import pkg_resources._vendor.packaging.version
19-
packaging = pkg_resources._vendor.packaging
20-
2114
from setuptools import Command
2215
from setuptools.command.sdist import sdist
2316
from setuptools.compat import basestring, PY3, StringIO
@@ -28,6 +21,7 @@
2821
safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename)
2922
import setuptools.unicode_utils as unicode_utils
3023

24+
from pkg_resources import packaging
3125

3226
class egg_info(Command):
3327
description = "create a distribution's .egg-info directory"

setuptools/dist.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@
1313
from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
1414
DistutilsSetupError)
1515

16-
try:
17-
import packaging.version
18-
except ImportError:
19-
# fallback to vendored version
20-
import pkg_resources._vendor.packaging.version
21-
packaging = pkg_resources._vendor.packaging
22-
2316
from setuptools.depends import Require
2417
from setuptools.compat import basestring, PY2
2518
from setuptools import windows_support
2619
import pkg_resources
2720

21+
packaging = pkg_resources.packaging
22+
2823

2924
def _get_unpatched(cls):
3025
"""Protect against re-patching the distutils if reloaded

setuptools/tests/test_resources.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import shutil
99
from unittest import TestCase
1010

11-
import pkg_resources._vendor.packaging.version
12-
import pkg_resources._vendor.packaging.specifiers
13-
packaging = pkg_resources._vendor.packaging
14-
1511
import pkg_resources
1612
from pkg_resources import (parse_requirements, VersionConflict, parse_version,
1713
Distribution, EntryPoint, Requirement, safe_version, safe_name,
1814
WorkingSet)
1915

16+
packaging = pkg_resources.packaging
17+
2018
from setuptools.command.easy_install import (get_script_header, is_sh,
2119
nt_quote_arg)
2220
from setuptools.compat import StringIO, iteritems, PY3

0 commit comments

Comments
 (0)