]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
build: avoid installing tomli on recent python
authorEli Schwartz <eschwartz93@gmail.com>
Wed, 26 Jun 2024 03:22:17 +0000 (23:22 -0400)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 28 Jun 2024 16:37:14 +0000 (18:37 +0200)
It is in the stdlib. No need to have wheel building require downloading
yet another build dependency.

psycopg_c/build_backend/cython_backend.py
psycopg_c/pyproject.toml

index bb7bc48f650a708b4eb9e5cda174a923f130ae74..686ecc746f0ce384864a6f4feb973d6ddaef96de 100644 (file)
@@ -10,11 +10,16 @@ otherwise it only relies on the c files to have been precompiled.
 from __future__ import annotations
 
 import os
+import sys
 from typing import Any
 
-import tomli
 from setuptools import build_meta
 
+if sys.version_info >= (3, 11):
+    import tomllib
+else:
+    import tomli as tomllib
+
 
 def get_requires_for_build_wheel(config_settings: Any = None) -> list[str]:
     if not os.path.exists("psycopg_c/_psycopg.pyx"):
@@ -26,7 +31,7 @@ def get_requires_for_build_wheel(config_settings: Any = None) -> list[str]:
     # to build. Get the version from the pyproject itself to keep things in the
     # same place.
     with open("pyproject.toml", "rb") as f:
-        pyprj = tomli.load(f)
+        pyprj = tomllib.load(f)
 
     rv: list[str] = pyprj["cython-backend"]["cython-requires"]
     return rv
index 831e030df119759ea8e2a3612b625e6b1cdcc9e9..1b27b44d5277cf7fb94c2b83ce317578580a984f 100644 (file)
@@ -1,5 +1,5 @@
 [build-system]
-requires = ["setuptools >= 49.2.0", "wheel >= 0.37", "tomli >= 2.0.1"]
+requires = ["setuptools >= 49.2.0", "wheel >= 0.37", "tomli >= 2.0.1 ; python_version<'3.11'"]
 
 # The cython_backend is a build backend adding a Cython dependency if the c
 # source must be build from pxd files (when building from git checkout), and