From: Eli Schwartz Date: Wed, 26 Jun 2024 03:22:17 +0000 (-0400) Subject: build: avoid installing tomli on recent python X-Git-Tag: 3.2.0~2^2~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a517bb4579d2b8caa4ddc1e81294d6026c8974d6;p=thirdparty%2Fpsycopg.git build: avoid installing tomli on recent python It is in the stdlib. No need to have wheel building require downloading yet another build dependency. --- diff --git a/psycopg_c/build_backend/cython_backend.py b/psycopg_c/build_backend/cython_backend.py index bb7bc48f6..686ecc746 100644 --- a/psycopg_c/build_backend/cython_backend.py +++ b/psycopg_c/build_backend/cython_backend.py @@ -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 diff --git a/psycopg_c/pyproject.toml b/psycopg_c/pyproject.toml index 831e030df..1b27b44d5 100644 --- a/psycopg_c/pyproject.toml +++ b/psycopg_c/pyproject.toml @@ -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