Skip to content

Commit 6695db7

Browse files
authored
Drop use of pkg_resources from setup.py (MagicStack#1362)
Use `packaging` as a modern alternative.
1 parent db8ecc2 commit 6695db7

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ docs = [
6262
[build-system]
6363
requires = [
6464
"setuptools>=77.0.3",
65+
"packaging>=24.0",
6566
"Cython(>=3.2.1,<4.0.0)"
6667
]
6768
build-backend = "setuptools.build_meta"

‎setup.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import re
1818
import subprocess
1919

20+
from packaging.requirements import Requirement
21+
2022
# We use vanilla build_ext, to avoid importing Cython via
2123
# the setuptools version.
2224
import setuptools
@@ -188,8 +190,6 @@ def finalize_options(self):
188190
need_cythonize = True
189191

190192
if need_cythonize:
191-
import pkg_resources
192-
193193
# Double check Cython presence in case setup_requires
194194
# didn't go into effect (most likely because someone
195195
# imported Cython before setup_requires injected the
@@ -201,8 +201,8 @@ def finalize_options(self):
201201
'please install {} to compile asyncpg from source'.format(
202202
CYTHON_DEPENDENCY))
203203

204-
cython_dep = pkg_resources.Requirement.parse(CYTHON_DEPENDENCY)
205-
if Cython.__version__ not in cython_dep:
204+
cython_dep = Requirement(CYTHON_DEPENDENCY)
205+
if Cython.__version__ not in cython_dep.specifier:
206206
raise RuntimeError(
207207
'asyncpg requires {}, got Cython=={}'.format(
208208
CYTHON_DEPENDENCY, Cython.__version__

0 commit comments

Comments
 (0)