Good morning/evening, and thanks for your time.

As distutils has been deprecated and finally removed in Python 3.12, SWORD is unable to build in Fedora without the following patch. The patch:

* Replaces all references to distutils with their setuptools equivalents.

* Modifies the build system to allow specifying a new CMake argument, "SWORD_PYTHON_INSTALL_ROOT", which allows setting the installation path for the Python bindings without generating a Python egg. (This is necessary since Python eggs have been deprecated as well and will likely be removed later. See https://github.com/pypa/setuptools/issues/3143 - specifying both a --root and a --prefix to the setup.py scripts seems to work around this issue.)

All contributions in this patch are made available to the SWORD Project under the terms of the GNU General Public License version 2.

Thanks for your consideration, and have a blessed day!

Aaron

(P.S. - the reason this appears to be a Git patch is because I used Git to let me generate a multi-file patch more easily. I realize SWORD uses SVN, sorry if this looks confusing.)



From 07b31a74ea920077fa0d69cdab2ab188dd17b322 Mon Sep 17 00:00:00 2001
From: Aaron Rainbolt <arraybo...@gmail.com>
Date: Wed, 27 Sep 2023 10:51:27 -0600
Subject: [PATCH] Migrate to setuptools

---
 bindings/swig/oldmake/Makefile.am   | 2 +-
 bindings/swig/package/Makefile.am   | 3 +--
 bindings/swig/package/Makefile.in   | 3 +--
 bindings/swig/python/CMakeLists.txt | 7 +++++--
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/bindings/swig/oldmake/Makefile.am b/bindings/swig/oldmake/Makefile.am
index 45a37ef..789813b 100644
--- a/bindings/swig/oldmake/Makefile.am
+++ b/bindings/swig/oldmake/Makefile.am
@@ -76,7 +76,7 @@ python_makebuild: $(PYTHONSWIG)
     echo "writing python/setup.py"
     @echo "#! /usr/bin/python" > python/setup.py
     @echo "" >> python/setup.py
-    @echo "from distutils.core import setup, Extension" >> python/setup.py
+    @echo "from setuptools import setup, Extension" >> python/setup.py
     @echo "setup (name = \"sword\"," >> python/setup.py
     @echo "    version = \"$(VERSION)\"," >> python/setup.py
     @echo "    maintainer = \"Sword Developers\"," >> python/setup.py
diff --git a/bindings/swig/package/Makefile.am b/bindings/swig/package/Makefile.am
index 14500c3..f44974d 100644
--- a/bindings/swig/package/Makefile.am
+++ b/bindings/swig/package/Makefile.am
@@ -84,8 +84,7 @@ python_makebuild: $(PYTHONSWIG)
     echo "writing python/setup.py"
     @echo "#! /usr/bin/python" > python/setup.py
     @echo "" >> python/setup.py
-    @echo "from distutils.core import setup" >> python/setup.py
-    @echo "from distutils.extension import Extension" >> python/setup.py
+    @echo "from setuptools import setup, Extension" >> python/setup.py
     @echo "import commands" >> python/setup.py
     @echo "" >> python/setup.py
     @echo "def pkgconfig(*packages, **kw):" >> python/setup.py
diff --git a/bindings/swig/package/Makefile.in b/bindings/swig/package/Makefile.in
index b5f05c9..370a9e7 100644
--- a/bindings/swig/package/Makefile.in
+++ b/bindings/swig/package/Makefile.in
@@ -938,8 +938,7 @@ python_makebuild: $(PYTHONSWIG)
     echo "writing python/setup.py"
     @echo "#! /usr/bin/python" > python/setup.py
     @echo "" >> python/setup.py
-    @echo "from distutils.core import setup" >> python/setup.py
-    @echo "from distutils.extension import Extension" >> python/setup.py
+    @echo "from setuptools import setup, Extension" >> python/setup.py
     @echo "import commands" >> python/setup.py
     @echo "" >> python/setup.py
     @echo "def pkgconfig(*packages, **kw):" >> python/setup.py
diff --git a/bindings/swig/python/CMakeLists.txt b/bindings/swig/python/CMakeLists.txt
index cbb4058..247bc79 100644
--- a/bindings/swig/python/CMakeLists.txt
+++ b/bindings/swig/python/CMakeLists.txt
@@ -25,7 +25,7 @@ ENDIF(NOT PYTHONLIBS_FOUND)

 SET(PY_SCRIPT "#!${PYTHON_EXECUTABLE}

-from distutils.core import setup, Extension
+from setuptools import setup, Extension
 setup(
     name='sword',
     version='${SWORD_VERSION}',
@@ -51,8 +51,11 @@ ADD_CUSTOM_TARGET(swordswig_python${SWORD_PYTHON_VERSION} ALL
     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

 # Allow user installation to custom directory
+IF(NOT SWORD_PYTHON_INSTALL_ROOT STREQUAL "")
+    SET(SETUP_ARGS "\"--root=${SWORD_PYTHON_INSTALL_ROOT}\"")
+ENDIF(NOT SWORD_PYTHON_INSTALL_ROOT STREQUAL "")
 IF(NOT SWORD_PYTHON_INSTALL_DIR STREQUAL "")
-    SET(SETUP_ARGS "\"--prefix=${SWORD_PYTHON_INSTALL_DIR}\"")
+    SET(SETUP_ARGS "${SETUP_ARGS}\"--prefix=${SWORD_PYTHON_INSTALL_DIR}\"")
 ENDIF(NOT SWORD_PYTHON_INSTALL_DIR STREQUAL "")
 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/install.cmake.in"
            "${CMAKE_CURRENT_BINARY_DIR}/install.cmake")
--
2.41.0

_______________________________________________
sword-devel mailing list: sword-devel@crosswire.org
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Reply via email to