[sword-devel] [PATCH] Migrate setup.py files from using distutils to using setuptools
Aaron Rainbolt
arraybolt3 at gmail.com
Mon Oct 2 21:38:06 EDT 2023
I realize these are autotools files, but they are somehow getting pulled
into the CMake build process. The spec file for the Fedora build is
still using CMake, the build was failing because of an attempt to use
distutils rather than setuptools, and the only places where distutils
was mentioned was in Python scripts embedded into the Autotools files.
Patching them fixed the problem, so I assume the CMake builds must be
using those files to generate the Python scripts for installing the
Python bindings.
I realize now that my patch was against the 1.9.0 tarball, not against
the latest SVN revision (why I didn't think to do it against the SVN
repo, I don't know, but I didn't). The patch doesn't apply for me either
so scrap this one and I'll submit a new one against the head of SVN.
Sorry about that.
On 10/2/23 20:27, Greg Hellings wrote:
> Aaron,
>
> Your patch fails to apply against the head of SVN for me, with this error:
>
> @ patch -p1 < ../aaron-rainbolt.patch
> patching file bindings/swig/oldmake/Makefile.am
> Hunk #1 FAILED at 76.
> 1 out of 1 hunk FAILED -- saving rejects to file
> bindings/swig/oldmake/Makefile.am.rej
> patching file bindings/swig/package/Makefile.am
> Hunk #1 FAILED at 84.
> 1 out of 1 hunk FAILED -- saving rejects to file
> bindings/swig/package/Makefile.am.rej
> can't find file to patch at input line 35
> Perhaps you used the wrong -p or --strip option?
> The text leading up to this was:
> --------------------------
> |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
> --------------------------
> File to patch:
>
> Furthermore, it looks like you are patching the autotools build
> system, which is not supported in the Python and Perl bindings. Those
> are only supported building through the CMake files. At least, they
> aren't supported by me as I don't go near autotools, and last I knew I
> was the only one working in the Swig bindings.
>
> I don't know why your patch is failing to apply, as I don't believe
> there should be any drift in those Makefiles. I'd be happy to try
> again if you have any advice as to why the patch is not applying.
>
> --Greg
>
> On Thu, Sep 28, 2023 at 11:53 AM Aaron Rainbolt <arraybolt3 at gmail.com>
> wrote:
>
> 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 <arraybolt3 at 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
> <http://install.cmake.in>"
> "${CMAKE_CURRENT_BINARY_DIR}/install.cmake")
> --
> 2.41.0
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
>
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
More information about the sword-devel
mailing list