diff --git a/pyproject.toml b/pyproject.toml index e2b18388..66a6fbe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,7 @@ docs = [ [build-system] requires = [ "setuptools>=77.0.3", + "packaging>=24.0", "Cython(>=3.2.1,<4.0.0)" ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index f9fafadf..11d73c0b 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,8 @@ import re import subprocess +from packaging.requirements import Requirement + # We use vanilla build_ext, to avoid importing Cython via # the setuptools version. import setuptools @@ -188,8 +190,6 @@ def finalize_options(self): need_cythonize = True if need_cythonize: - import pkg_resources - # Double check Cython presence in case setup_requires # didn't go into effect (most likely because someone # imported Cython before setup_requires injected the @@ -201,8 +201,8 @@ def finalize_options(self): 'please install {} to compile asyncpg from source'.format( CYTHON_DEPENDENCY)) - cython_dep = pkg_resources.Requirement.parse(CYTHON_DEPENDENCY) - if Cython.__version__ not in cython_dep: + cython_dep = Requirement(CYTHON_DEPENDENCY) + if Cython.__version__ not in cython_dep.specifier: raise RuntimeError( 'asyncpg requires {}, got Cython=={}'.format( CYTHON_DEPENDENCY, Cython.__version__