Skip to content

Commit b70bc30

Browse files
committed
Replace pkg_resources with packaging in setup.py
setuptools>=78 removed the bundled pkg_resources module, causing ModuleNotFoundError on all CI jobs except Python 3.8-ubuntu (which uses an older setuptools). Use packaging.requirements.Requirement instead, which provides the same version-specifier matching and is always available as a dependency of setuptools.
1 parent 7de9458 commit b70bc30

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def finalize_options(self):
108108
need_cythonize = True
109109

110110
if need_cythonize:
111-
import pkg_resources
111+
from packaging.requirements import Requirement
112112

113113
# Double check Cython presence in case setup_requires
114114
# didn't go into effect (most likely because someone
@@ -121,8 +121,8 @@ def finalize_options(self):
121121
'please install {} to compile uvloop from source'.format(
122122
CYTHON_DEPENDENCY))
123123

124-
cython_dep = pkg_resources.Requirement.parse(CYTHON_DEPENDENCY)
125-
if Cython.__version__ not in cython_dep:
124+
cython_req = Requirement(CYTHON_DEPENDENCY)
125+
if not cython_req.specifier.contains(Cython.__version__):
126126
raise RuntimeError(
127127
'uvloop requires {}, got Cython=={}'.format(
128128
CYTHON_DEPENDENCY, Cython.__version__

0 commit comments

Comments
 (0)