1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-04 12:02:29 +03:00

python: Make it compatible with python3.12

Python 3.12 removes distutils so it's mandatory to use setuptools with
python >= 3.12.

This patch prints a message when trying to run the setup.py script with
a python >= 3.12 without setuptools and try to use the setuptools import
by default.

This patch also creates a new file, pyproject.toml [1], to prepare for
building in modern systems.

[1] https://peps.python.org/pep-0517/
This commit is contained in:
Daniel Garcia Moreno
2023-10-24 07:41:28 +02:00
parent 42e018bdc9
commit 1534c167fc
2 changed files with 11 additions and 4 deletions

3
python/pyproject.toml Normal file
View File

@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

View File

@ -5,11 +5,15 @@
import sys, os, subprocess import sys, os, subprocess
try: try:
import setuptools from setuptools import setup, Extension
except ImportError: except ImportError:
pass try:
# Using distutils, for python < 3.12
from distutils.core import setup, Extension from distutils.core import setup, Extension
except ImportError:
# distutils is not present in python 3.12 and greater
print("setuptools is required for python >= 3.12")
sys.exit(1)
# Below ROOT, we expect to find include, include/libxml2, lib and bin. # Below ROOT, we expect to find include, include/libxml2, lib and bin.
# On *nix, it is not needed (but should not harm), # On *nix, it is not needed (but should not harm),