openzim / python-libzim

Libzim binding for Python: read/write ZIM files in Python
https://pypi.org/project/libzim/
GNU General Public License v3.0
62 stars 19 forks source link

Cannot run "python setup.py clean" without having libzim.so present #131

Closed legoktm closed 2 years ago

legoktm commented 2 years ago

In Debian packaging, the clean step, which runs python setup.py clean runs before dependencies are installed, so libzim.so isn't present yet and setup.py errors out saying it can't be found.

For now I added a patch to the Debian package that does:

diff --git a/setup.py b/setup.py
index 12acdee..864558d 100755
--- a/setup.py
+++ b/setup.py
@@ -88,7 +88,7 @@ if header_file.exists() and lib_file.exists():
     )
     include_dirs.append("include")
     library_dirs = ["lib"]
-else:
+elif 'clean' not in sys.argv:
     # Check for library.
     if not find_library("zim"):
         print(

I'm not sure if there's a better way to check whether the clean step is being invoked or not.

legoktm commented 2 years ago

Related is https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=997440, in which running python setup.py clean actually triggers cythonization and makes the checkout dirty. I think the answer is to do something like https://github.com/Unidata/cftime/issues/91, which is basically what my patch is but more complete.

I found the cftime example via Debian codesearch, along with https://sources.debian.org/src/ceph/16.2.7+ds-2/src/pybind/cephfs/setup.py/?hl=156#L174 so I guess that's the correct approach?

Will work on a patch.

legoktm commented 2 years ago

Here's what I came up with: https://salsa.debian.org/debian/python-libzim/-/blob/master/debian/patches/0002-Avoid-running-cythonize-on-setup.py-clean-and-simila.patch