]> 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:39:39 +0000 (18:39 +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 97bd2af8844173f55317475b7dd9842a229d3bd6..267707c7c9286c9401ac201a9d6c682b7b088041 100644 (file)
@@ -8,11 +8,16 @@ otherwise it only relies on the c files to have been precompiled.
 # Copyright (C) 2023 The Psycopg Team
 
 import os
+import sys
 from typing import Any, List
 
-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"):
@@ -24,7 +29,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