diff --git a/contrib/bindings/python/pyproject.toml b/contrib/bindings/python/pyproject.toml index da7505e..896960a 100644 --- a/contrib/bindings/python/pyproject.toml +++ b/contrib/bindings/python/pyproject.toml @@ -17,7 +17,7 @@ [build-system] requires = [ - "setuptools>=68", + "setuptools>=61", "wheel", "cffi>=1.10.0" ] diff --git a/contrib/bindings/python/setup.py b/contrib/bindings/python/setup.py index 6dfa618..e77775b 100755 --- a/contrib/bindings/python/setup.py +++ b/contrib/bindings/python/setup.py @@ -17,7 +17,27 @@ import setuptools +# This is only needed for backwards compatibility with older versions. +def parse_pyproject(): + try: + import tomllib + openmode = "rb" + except ImportError: + # For pre-3.11 Python support. + import toml as tomllib + openmode = "r" + + with open("pyproject.toml", openmode) as f: + return tomllib.load(f) + +pyproject = parse_pyproject() + setuptools.setup( + # For backwards-compatibility with pre-pyproject setuptools. + name=pyproject["project"]["name"], + version=pyproject["project"]["version"], + install_requires=pyproject["project"]["dependencies"], + # Configure cffi building. ext_package="pathrs", platforms=["Linux"], cffi_modules=["pathrs/pathrs_build.py:ffibuilder"],