[PATCH] Migrate Python bindings installation script from distutils to setuptools, attempt 2

Aaron Rainbolt <[email protected]>
Newsgroups gmane.comp.literature.sword.devel
Message-ID <[email protected]>
Apologies for my initial failed attempt, I made a number of blunders in 
my first patch.

This second patch:

* Only modifies the CMake build system (the previous changes to 
Autotools was the result of me patching more than was necessary)
* Uses correct indentation (I had spaces and tabs confused before, now 
I'm using tabs correctly)
* Successfully applies against the head of SVN and against the 1.9.0 tarball
* Successfully builds against the 1.9.0 tarball (I haven't tried 
building SVN with this yet)
* Switches the Python setup script embedded in the CMake system from 
using distutils to using setuptools
* Adds a SWORD_PYTHON_INSTALL_ROOT build option for allowing the Python 
bindings to be installed without building a Python egg (works around 
https://github.com/pypa/setuptools/issues/3143)
* Has the patch as an attachment since it appears either GMail or 
Thunderbird potentially mangled my patch last time

As before, everything in the patch is made available under GPLv2.

_______________________________________________
sword-devel mailing list: [email protected]
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
pyfix.patch (text/x-patch, 986 B)
--- a/bindings/swig/python/CMakeLists.txt	2023-10-02 20:55:56.264801835 -0500
+++ b/bindings/swig/python/CMakeLists.txt	2023-10-02 20:59:53.103289769 -0500
@@ -25,7 +25,7 @@
 
 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 @@
 	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")
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.