inducer / pyopencl

OpenCL integration for Python, plus shiny features
http://mathema.tician.de/software/pyopencl
Other
1.04k stars 238 forks source link

Compatibility with `numpy2` #719

Closed kif closed 3 months ago

kif commented 3 months ago

Describe the bug pyopencl cannot be built with numpy2

To Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/inducer/pyopencl
  2. python setup.py build

Expected behavior A clear and concise description of what you expected to happen.

Environment (please complete the following information):

Additional context Python from mamba, build in a virtual-env (not conda-env)

kif commented 3 months ago
~/workspace/pyopencl % python setup.py build
running build
running build_py
copying pyopencl/cache.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/ipython_ext.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/cltypes.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/tools.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/__init__.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/_cluda.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/_mymako.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/invoker.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/version.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/scan.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/bitonic_sort.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/reduction.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/elementwise.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/bitonic_sort_templates.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/algorithm.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/capture_call.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/clrandom.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/clmath.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/array.py -> build/lib.linux-x86_64-cpython-312/pyopencl
copying pyopencl/compyte/dtypes.py -> build/lib.linux-x86_64-cpython-312/pyopencl/compyte
copying pyopencl/compyte/array.py -> build/lib.linux-x86_64-cpython-312/pyopencl/compyte
copying pyopencl/characterize/__init__.py -> build/lib.linux-x86_64-cpython-312/pyopencl/characterize
copying pyopencl/characterize/performance.py -> build/lib.linux-x86_64-cpython-312/pyopencl/characterize
copying pyopencl/compyte/ndarray/gen_reduction.py -> build/lib.linux-x86_64-cpython-312/pyopencl/compyte/ndarray
copying pyopencl/compyte/ndarray/test_gpu_elemwise.py -> build/lib.linux-x86_64-cpython-312/pyopencl/compyte/ndarray
copying pyopencl/compyte/ndarray/test_gpu_ndarray.py -> build/lib.linux-x86_64-cpython-312/pyopencl/compyte/ndarray
copying pyopencl/compyte/ndarray/setup_opencl.py -> build/lib.linux-x86_64-cpython-312/pyopencl/compyte/ndarray
copying pyopencl/compyte/ndarray/gen_elemwise.py -> build/lib.linux-x86_64-cpython-312/pyopencl/compyte/ndarray
running egg_info
writing pyopencl.egg-info/PKG-INFO
writing dependency_links to pyopencl.egg-info/dependency_links.txt
writing requirements to pyopencl.egg-info/requires.txt
writing top-level names to pyopencl.egg-info/top_level.txt
reading manifest file 'pyopencl.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'experiments/*.py'
warning: no previously-included files matching '*' found under directory '_skbuild'
adding license file 'LICENSE'
writing manifest file 'pyopencl.egg-info/SOURCES.txt'
/users/kieffer/.venv/py312/lib/python3.12/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'pyopencl.cl' is absent from the `packages` configuration.
!!

        ********************************************************************************
        ############################
        # Package would be ignored #
        ############################
        Python recognizes 'pyopencl.cl' as an importable package[^1],
        but it is absent from setuptools' `packages` configuration.

        This leads to an ambiguous overall configuration. If you want to distribute this
        package, please make sure that 'pyopencl.cl' is explicitly added
        to the `packages` configuration field.

        Alternatively, you can also rely on setuptools' discovery methods
        (for example by using `find_namespace_packages(...)`/`find_namespace:`
        instead of `find_packages(...)`/`find:`).

        You can read more about "package discovery" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

        If you don't want 'pyopencl.cl' to be distributed and are
        already explicitly excluding 'pyopencl.cl' via
        `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
        you can try to use `exclude_package_data`, or `include-package-data=False` in
        combination with a more fine grained `package-data` configuration.

        You can read more about "package data files" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

        [^1]: For Python, any directory (with suitable naming) can be imported,
              even if it does not contain any `.py` files.
              On the other hand, currently there is no concept of package data
              directory, all directories are treated like packages.
        ********************************************************************************

!!
  check.warn(importable)
copying pyopencl/cl/pyopencl-bessel-j-complex.cl -> build/lib.linux-x86_64-cpython-312/pyopencl/cl
copying pyopencl/cl/pyopencl-complex.h -> build/lib.linux-x86_64-cpython-312/pyopencl/cl
copying pyopencl/cl/pyopencl-hankel-complex.cl -> build/lib.linux-x86_64-cpython-312/pyopencl/cl
copying pyopencl/cl/pyopencl-ranluxcl.cl -> build/lib.linux-x86_64-cpython-312/pyopencl/cl
copying pyopencl/cl/pyopencl-random123/array.h -> build/lib.linux-x86_64-cpython-312/pyopencl/cl/pyopencl-random123
copying pyopencl/cl/pyopencl-random123/openclfeatures.h -> build/lib.linux-x86_64-cpython-312/pyopencl/cl/pyopencl-random123
copying pyopencl/cl/pyopencl-random123/philox.cl -> build/lib.linux-x86_64-cpython-312/pyopencl/cl/pyopencl-random123
copying pyopencl/cl/pyopencl-random123/threefry.cl -> build/lib.linux-x86_64-cpython-312/pyopencl/cl/pyopencl-random123
running build_ext
gcc -pthread -B /opt/mamba/envs/python_3.12/compiler_compat -fno-strict-overflow -Wall -O3 -DNDEBUG -fPIC -I/users/kieffer/.venv/py312/include -I/opt/mamba/envs/python_3.12/include/python3.12 -c /tmp/tmps_in1_fz.cpp -o tmp/tmps_in1_fz.o -std=gnu++14
gcc -pthread -B /opt/mamba/envs/python_3.12/compiler_compat -fno-strict-overflow -Wall -O3 -DNDEBUG -fPIC -I/users/kieffer/.venv/py312/include -I/opt/mamba/envs/python_3.12/include/python3.12 -c /tmp/tmpcnetwv0g.cpp -o tmp/tmpcnetwv0g.o -fvisibility=hidden
INFO: Disabling color, you really want to install colorlog.
Disabling color, you really want to install colorlog.
building 'pyopencl._cl' extension
gcc -pthread -B /opt/mamba/envs/python_3.12/compiler_compat -fno-strict-overflow -Wall -O3 -DNDEBUG -fPIC -DPYGPU_PACKAGE=pyopencl -DPYGPU_PYOPENCL=1 -DPYOPENCL_PRETEND_CL_VERSION=4112 -Ipybind11/include -I/users/kieffer/.venv/py312/lib/python3.12/site-packages/pybind11/include -I/users/kieffer/.venv/py312/lib/python3.12/site-packages/numpy/core/include -I/users/kieffer/.venv/py312/include -I/opt/mamba/envs/python_3.12/include/python3.12 -c -std=gnu++14 src/bitlog.cpp -o build/temp.linux-x86_64-cpython-312/src/bitlog.o -fvisibility=hidden -DVERSION_INFO=\"2024.1\" -fvisibility=hidden
gcc -pthread -B /opt/mamba/envs/python_3.12/compiler_compat -fno-strict-overflow -Wall -O3 -DNDEBUG -fPIC -DPYGPU_PACKAGE=pyopencl -DPYGPU_PYOPENCL=1 -DPYOPENCL_PRETEND_CL_VERSION=4112 -Ipybind11/include -I/users/kieffer/.venv/py312/lib/python3.12/site-packages/pybind11/include -I/users/kieffer/.venv/py312/lib/python3.12/site-packages/numpy/core/include -I/users/kieffer/.venv/py312/include -I/opt/mamba/envs/python_3.12/include/python3.12 -c -std=gnu++14 src/wrap_cl.cpp -o build/temp.linux-x86_64-cpython-312/src/wrap_cl.o -fvisibility=hidden -DVERSION_INFO=\"2024.1\" -fvisibility=hidden
In file included from src/wrap_cl.cpp:29:
src/wrap_cl.hpp:101:10: fatal error: numpy/arrayobject.h: No such file or directory
  101 | #include <numpy/arrayobject.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command '/usr/lib/ccache/gcc' failed with exit code 1
inducer commented 3 months ago

720 contains an initial draft that should already be pretty close.

inducer commented 3 months ago

And thanks for flagging this.