SiLab-Bonn / pylandau

Simple Landau distribution definitions to be used in Python.
GNU Lesser General Public License v2.1
20 stars 4 forks source link

Building issue #30

Open spreiter opened 1 month ago

spreiter commented 1 month ago

Hi,

I recently tried to install pylandau and found two issues. I forked the repo to our own GitLab instances, so I could build packages with different Python versions using the manylinux images and found the following two problems.

  1. does not compile with Python 3.12
  2. does not compile with Cython 3

I could fix (2) quite easily by changing pyproject.toml:

-    "cython>=0.29",
+    "cython<3,>=0.29",

The issue for Python 3.12 seems more complex and I was not able to dig through.

PS: I also realized that the package builds for Python 3.7. Is there a reason to not support it? There is also no demand from my side, I am just curious ;)

cuddandr commented 1 month ago

I also encountered this issue with using Python 3.11 and had to downgrade the Cython version to 0.29.34 to get pylandau to compile.

There also seems to be some complaints from setuptools complaining about the pyproject.toml, however that seems to go away when using the downgraded Cython.

For reference, I get the following compilation errors when using Cython 3+

pyLandau/cpp/pylandau.cpp: In function ‘PyObject* __pyx_pf_8pylandau_6landau_pdf(PyObject*, PyArrayObject*, PyObject*, PyObject*)’:
      pyLandau/cpp/pylandau.cpp:6622:36: error: invalid cast of a prvalue expression of type ‘char*’ to type ‘double*&’
       6622 |     __pyx_t_10 = getLandauPDFData(((double *&)__pyx_f_5numpy_7ndarray_4data_data(((PyArrayObject *)__pyx_v_array))), ((unsigned int const &)(__pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_array))[0])), ((double const &)__pyx_t_8), ((double const &)__pyx_t_9));
            |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      pyLandau/cpp/pylandau.cpp: In function ‘PyObject* __pyx_pf_8pylandau_8langau_pdf(PyObject*, PyArrayObject*, PyObject*, PyObject*, PyObject*)’:
      pyLandau/cpp/pylandau.cpp:6974:36: error: invalid cast of a prvalue expression of type ‘char*’ to type ‘double*&’
       6974 |     __pyx_t_11 = getLangauPDFData(((double *&)__pyx_f_5numpy_7ndarray_4data_data(((PyArrayObject *)__pyx_v_array))), ((unsigned int const &)(__pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_array))[0])), ((double const &)__pyx_t_8), ((double const &)__pyx_t_9), ((double const &)__pyx_t_10));
            |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cbespin commented 3 weeks ago

Thanks for looking into this. I could not get pylandau to work with python 3.12 for myself, but the problem seems far from trivial. Might even be connected to the cython3 problem, which I have not tried yet. I have to dig into this further, but ideally I will move the whole package to numba or pybind instead of cython that gave me a lot of headaches since I took over the project.