Skip to content

Commit c11e91f

Browse files
authored
Merge pull request #85 from fonttools/fix-pkg-resources
Replace pkg_resources with importlib.metadata
2 parents 805b844 + 0b7d58d commit c11e91f

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ requires = [
33
"setuptools",
44
"wheel",
55
"setuptools_scm",
6+
"packaging",
67
"cython >= 3.2.0",
78
]
89

setup.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from distutils.dir_util import mkpath
99
from distutils.file_util import copy_file
1010
from distutils.util import get_platform
11-
import pkg_resources
11+
from importlib.metadata import version as get_package_version
12+
from packaging.version import parse as parse_version
1213
import struct
1314
import subprocess
1415
import sys
@@ -55,11 +56,11 @@ def bool_from_environ(key: str, default: bool = False):
5556
else:
5657
sys.exit("error: could not parse cython version from pyproject.toml")
5758
try:
58-
pkg_resources.require("cython >= %s" % cython_min_version)
59-
except pkg_resources.ResolutionError:
59+
cython_version = parse_version(get_package_version("cython"))
60+
cython_min = parse_version(cython_min_version)
61+
with_cython = cython_version >= cython_min
62+
except Exception:
6063
with_cython = False
61-
else:
62-
with_cython = True
6364

6465
inside_sdist = os.path.exists("PKG-INFO")
6566

@@ -256,13 +257,13 @@ def _copy_windows_dlls(self):
256257

257258
ext_path = self.get_ext_fullpath(ext.name)
258259
dest_dir = os.path.dirname(ext_path)
259-
mkpath(dest_dir, verbose=self.verbose, dry_run=self.dry_run)
260-
copy_file(
261-
dll_fullpath,
262-
os.path.join(dest_dir, dll_filename),
263-
verbose=self.verbose,
264-
dry_run=self.dry_run,
265-
)
260+
if not self.dry_run:
261+
mkpath(dest_dir, verbose=self.verbose)
262+
copy_file(
263+
dll_fullpath,
264+
os.path.join(dest_dir, dll_filename),
265+
verbose=self.verbose,
266+
)
266267

267268

268269
def build_skia(build_base):
@@ -406,7 +407,7 @@ def get_skia_using_pkgconfig():
406407
"build_ext": custom_build_ext,
407408
},
408409
options={"bdist_wheel": {"py_limited_api": "cp310"}} if use_py_limited_api else {},
409-
setup_requires=["setuptools_scm"] + setuptools_git_ls_files + wheel,
410+
setup_requires=["setuptools_scm", "packaging"] + setuptools_git_ls_files + wheel,
410411
install_requires=[],
411412
extras_require={
412413
"testing": [

0 commit comments

Comments
 (0)