gesellkammer / pyliblo3

fork of pyliblo with better pip integration, binary wheels and no external dependencies
https://pypi.org/project/pyliblo3/
GNU Lesser General Public License v2.1
10 stars 3 forks source link

Pyliblo3 fails to build on Fedora 41 with python 3.13.0 #6

Closed martinkg closed 1 week ago

martinkg commented 2 weeks ago

I am trying to build pyliblo3 from your repo on Fedora 41 with python-3.13.0 and python3-cython-3.0.11. I've got a build error during compilation:

root@fc41:/tmp/pyliblo3-master# ./setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-313
creating build/lib.linux-x86_64-cpython-313/pyliblo3
copying pyliblo3/__init__.py -> build/lib.linux-x86_64-cpython-313/pyliblo3
copying pyliblo3/_liblo.pyi -> build/lib.linux-x86_64-cpython-313/pyliblo3
running build_ext
Compiling pyliblo3/_liblo.pyx because it changed.
[1/1] Cythonizing pyliblo3/_liblo.pyx
/usr/lib64/python3.13/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/pyliblo3-master/pyliblo3/_liblo.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
building 'pyliblo3._liblo' extension
creating build/temp.linux-x86_64-cpython-313
creating build/temp.linux-x86_64-cpython-313/pyliblo3
gcc -fno-strict-overflow -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -fcf-protection -fexceptions -fcf-protection -fexceptions -fcf-protection -fexceptions -O3 -fPIC -Ipyliblo3 -I/usr/include -I/usr/local/include -I/usr/include/python3.13 -c pyliblo3/_liblo.c -o build/temp.linux-x86_64-cpython-313/pyliblo3/_liblo.o -fno-strict-aliasing -Werror-implicit-function-declaration -Wfatal-errors
pyliblo3/_liblo.c: In function ‘__pyx_f_8pyliblo3_6_liblo__msg_callback’:
pyliblo3/_liblo.c:9011:92: error: passing argument 1 of ‘lo_blob_dataptr’ from incompatible pointer type [-Wincompatible-pointer-types]
 9011 |       __pyx_t_7 = __Pyx_PyBytes_FromCString(((unsigned char *)lo_blob_dataptr((__pyx_v_argv[__pyx_v_i])))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 274, __pyx_L1_error)
      |                                                                               ~~~~~~~~~~~~~^~~~~~~~~~~~
      |                                                                                            |
      |                                                                                            lo_arg *
pyliblo3/_liblo.c:1353:78: note: in definition of macro ‘__Pyx_PyBytes_FromCString’
 1353 | #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
      |                                                                              ^
compilation terminated due to -Wfatal-errors.
error: command '/usr/bin/gcc' failed with exit code 1
martinkg commented 2 weeks ago

with the following changes in the file pyliblo3/_liblo.c, it compiles on Fedora40 and Fedora41.

--- pyliblo3-master/pyliblo3/_liblo.c.orig  2024-08-25 12:44:43.066128982 +0200
+++ pyliblo3-master/pyliblo3/_liblo.c   2024-08-25 12:45:19.302396335 +0200
@@ -9011,7 +9011,7 @@
  *         else:
  *             v = None  # unhandled data type
  */
-      __pyx_t_7 = __Pyx_PyBytes_FromCString(((unsigned char *)lo_blob_dataptr((__pyx_v_argv[__pyx_v_i])))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 273, __pyx_L1_error)
+      __pyx_t_7 = __Pyx_PyBytes_FromCString((unsigned char *)lo_blob_dataptr(*(struct lo_blob_ **)&__pyx_v_argv[__pyx_v_i])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 274, __pyx_L1_error)
       __Pyx_GOTREF(__pyx_t_7);
       __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 273, __pyx_L1_error)
       __Pyx_GOTREF(__pyx_t_6);
martinkg commented 2 weeks ago

I don't think the patch will really help, because the _liblo.c file will be recreated and the changes will be lost again. But how can this be solved?

martinkg commented 2 weeks ago

the following patch fix_liblo3.patch should now working.

LecrisUT commented 2 weeks ago

In the setup.py I only see a reference to the .pyx file, so I assume simply deleting the _liblo.c file would be sufficient, although I have not done cythonization packaging by hand like that. If that doesn't work on the Fedora packaging, either call cython manually before the build, or wait for the recommendation in #7 to be adopted.

martinkg commented 2 weeks ago

thanks for your respond, that works for me.

%prep
%autosetup -p1 -n %{name}-%{commit0}
# Remove pregenerated Cython C sources and build it again
rm -rf pyliblo3/_liblo.c
cython pyliblo3/_liblo.pxd

# Remove shebang and executable bit from example scripts 
%py3_shebang_fix .
chmod -x examples/* COPYING NEWS README.md PKG-INFO

%build
%py3_build

%install
%py3_instal
LecrisUT commented 2 weeks ago

Please also follow the modern python guidelines, i.e. %pyproject_wheel etc.

martinkg commented 1 week ago

compiles with this changes on F41

.....
%prep
%autosetup -p1 -n pyliblo3-%{commit0}
# Remove pregenerated Cython C sources and build it again
rm -rf pyliblo3/_liblo.c

# Fix permissions (fix for rpmlint warning "spurious-executable-perm")
chmod 644 NEWS README.md COPYING

%generate_buildrequires
%pyproject_buildrequires

%build
cython -I pyliblo3 pyliblo3/_liblo.pyx
%pyproject_wheel
....
LecrisUT commented 1 week ago

Waaait a minute... the initial error in this post is identical with the one we are encountering on the mailing-list where we have run the cython command. Seems like we have circled back to the beginning on this issue?