Skip to content

Commit eaa5c0f

Browse files
committed
python bindings: fix builds for pre-pyproject setuptools
openSUSE Leap only has setuptools 44, which predates support for pyproject. This is fine, we just need to add the relevant metadata to the setuptools invocation. To reduce the amount of places we duplicate this information, just load pyproject.toml and read the values out (this does add a dependency on toml for pre-3.11 Python versions but that's fine). Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 2d7324b commit eaa5c0f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

contrib/bindings/python/pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
[build-system]
1919
requires = [
20-
"setuptools>=68",
20+
"cffi>=1.10.0",
21+
"setuptools>=61",
22+
"toml>=0.10", # TODO: Remove this once we only support Python >= 3.11.
2123
"wheel",
22-
"cffi>=1.10.0"
2324
]
2425
build-backend = "setuptools.build_meta"
2526

@@ -50,7 +51,7 @@ classifiers = [
5051

5152
requires-python = ">= 3.8"
5253
dependencies = [
53-
"cffi>=1.10.0"
54+
"cffi>=1.10.0",
5455
]
5556

5657
[project.urls]

contrib/bindings/python/setup.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,27 @@
1717

1818
import setuptools
1919

20+
# This is only needed for backwards compatibility with older versions.
21+
def parse_pyproject():
22+
try:
23+
import tomllib
24+
openmode = "rb"
25+
except ImportError:
26+
# TODO: Remove this once we only support Python >= 3.11.
27+
import toml as tomllib
28+
openmode = "r"
29+
30+
with open("pyproject.toml", openmode) as f:
31+
return tomllib.load(f)
32+
33+
pyproject = parse_pyproject()
34+
2035
setuptools.setup(
36+
# For backwards-compatibility with pre-pyproject setuptools.
37+
name=pyproject["project"]["name"],
38+
version=pyproject["project"]["version"],
39+
install_requires=pyproject["project"]["dependencies"],
40+
# Configure cffi building.
2141
ext_package="pathrs",
2242
platforms=["Linux"],
2343
cffi_modules=["pathrs/pathrs_build.py:ffibuilder"],

0 commit comments

Comments
 (0)