55 lines
1.8 KiB
Diff
55 lines
1.8 KiB
Diff
From 548bba106dca7905b6ca915ef58481b3d71f35d8 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
|
|
Date: Mon, 23 Oct 2023 10:16:34 +0200
|
|
Subject: [PATCH] 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/
|
|
---
|
|
python/pyproject.toml | 3 +++
|
|
python/setup.py.in | 12 ++++++++----
|
|
4 files changed, 13 insertions(+), 5 deletions(-)
|
|
create mode 100755 python/pyproject.toml.in
|
|
|
|
Index: libxml2-2.11.5/python/setup.py.in
|
|
===================================================================
|
|
--- libxml2-2.11.5.orig/python/setup.py.in
|
|
+++ libxml2-2.11.5/python/setup.py.in
|
|
@@ -5,11 +5,15 @@
|
|
import sys, os
|
|
|
|
try:
|
|
- import setuptools
|
|
+ from setuptools import setup, Extension
|
|
except ImportError:
|
|
- pass
|
|
-
|
|
-from distutils.core import setup, Extension
|
|
+ try:
|
|
+ # Using distutils, for python < 3.12
|
|
+ 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.
|
|
# On *nix, it is not needed (but should not harm),
|
|
Index: libxml2-2.11.5/python/pyproject.toml
|
|
===================================================================
|
|
--- /dev/null
|
|
+++ libxml2-2.11.5/python/pyproject.toml
|
|
@@ -0,0 +1,3 @@
|
|
+[build-system]
|
|
+requires = ["setuptools"]
|
|
+build-backend = "setuptools.build_meta"
|