mcgrawia opened a new issue, #43:
URL: https://github.com/apache/datasketches-python/issues/43

   Hi datasketch team,
   
   Thank you for the awesome library! My team and I ran into an issue while 
attempting to install the `datasketches-python` package in an alpine linux 
docker container. I am a bit stumped as the problem appears to be related to 
the `prepare_numpy()` function, but as far as I can tell, I am using the same 
numpy version that was used when building the wheel files for other 
distributions. At its core, the error seems to be `error: cannot convert 
'std::nullptr_t' to 'int' in return`. Does anyone have any tips for how I can 
resolve this build issue? I've attached the error and a sample Dockerfile below 
if it helps.
   
   Thanks
   
   **Sample Dockerfile**
   
   ```dockerfile
   FROM python:3.12-alpine
   
   # install build deps
   RUN apk add --no-cache make cmake g++ git
   
   RUN pip3 install --no-cache-dir datasketches~=5.0
   ```
   
   **Error:**
   ```
   ... lots of warnings
         
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2:
 warning: #warning "Using deprecated NumPy API, disable it with " "#define 
NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
         In file included from /usr/include/c++/13.2.1/cstring:42,
                          from 
/tmp/datasketches/include/DataSketches/memory_operations.hpp:27,
                          from 
/tmp/datasketches/include/DataSketches/density_sketch_impl.hpp:26,
                          from 
/tmp/datasketches/include/DataSketches/density_sketch.hpp:254,
                          from 
/tmp/pip-install-xb49diqe/datasketches_8f31c08a390743fd9e84ba03778a8c57/src/density_wrapper.cpp:33:
         
/tmp/pip-install-xb49diqe/datasketches_8f31c08a390743fd9e84ba03778a8c57/src/density_wrapper.cpp:
 In function 'int prepare_numpy()':
   error seems to be here ->
         
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/numpy/core/include/numpy/__multiarray_api.h:1558:151:
 error: cannot convert 'std::nullptr_t' to 'int' in return
          1558 | #define import_array() {if (_import_array() < 0) 
{PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray 
failed to import"); return NULL; } }
               |                                                                
                                                                                
       ^~~~
         
/tmp/pip-install-xb49diqe/datasketches_8f31c08a390743fd9e84ba03778a8c57/src/density_wrapper.cpp:101:3:
 note: in expansion of macro 'import_array'
           101 |   import_array();
               |   ^~~~~~~~~~~~
         In file included from 
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/nanobind/include/nanobind/nanobind.h:48,
                          from 
/tmp/pip-install-xb49diqe/datasketches_8f31c08a390743fd9e84ba03778a8c57/src/density_wrapper.cpp:22:
         
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/nanobind/include/nanobind/nb_attr.h:
 In instantiation of 'struct nanobind::detail::func_data_prelim<0>':
         
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/nanobind/include/nanobind/nb_func.h:95:38:
   required from 'PyObject* nanobind::detail::func_create(Func&&, Return 
(*)(Args ...), std::index_sequence<Is2 ...>, const Extra& ...) [with bool 
ReturnRef = false; bool CheckGuard = true; Func = bind_density_sketch<double, 
datasketches::kernel_function_holder>(nanobind::module_&, const 
char*)::<lambda(const datasketches::density_sketch<double, 
datasketches::kernel_function_holder, std::allocator<double> >&)>; Return = 
datasketches::density_sketch<double, datasketches::kernel_function_holder, 
std::allocator<double> >; Args = {const datasketches::density_sketch<double, 
datasketches::kernel_function_holder, std::allocator<double> >&}; long unsigned 
int ...Is = {0}; Extra = {nanobind::scope, nanobind::name, 
nanobind::is_method}; PyObject = _object; std::index_sequence<Is2 ...> = 
std::integer_sequence<long unsigned int, 0>]'
         
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/nanobind/include/nanobind/nb_func.h:207:37:
   required from 'void nanobind::cpp_function_def(Func&&, const Extra& ...) 
[with Func = bind_density_sketch<double, 
datasketches::kernel_function_holder>(nanobind::module_&, const 
char*)::<lambda(const datasketches::density_sketch<double, 
datasketches::kernel_function_holder, std::allocator<double> >&)>; Extra = 
{scope, name, is_method}; typename std::enable_if<is_lambda_v<typename 
std::remove_reference<_Tp>::type>, int>::type <anonymous> = 0]'
         
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/nanobind/include/nanobind/nb_class.h:453:25:
   required from 'nanobind::class_<T, Ts>& nanobind::class_<T, Ts>::def(const 
char*, Func&&, const Extra& ...) [with Func = bind_density_sketch<double, 
datasketches::kernel_function_holder>(nanobind::module_&, const 
char*)::<lambda(const datasketches::density_sketch<double, 
datasketches::kernel_function_holder, std::allocator<double> >&)>; Extra = {}; 
T = datasketches::density_sketch<double, datasketches::kernel_function_holder, 
std::allocator<double> >; Ts = {}]'
         
/tmp/pip-install-xb49diqe/datasketches_8f31c08a390743fd9e84ba03778a8c57/src/density_wrapper.cpp:52:9:
   required from 'void bind_density_sketch(nanobind::module_&, const char*) 
[with T = double; K = datasketches::kernel_function_holder]'
         
/tmp/pip-install-xb49diqe/datasketches_8f31c08a390743fd9e84ba03778a8c57/src/density_wrapper.cpp:127:54:
   required from here
         
/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/nanobind/include/nanobind/nb_attr.h:192:14:
 warning: ISO C++ forbids zero-size array [-Wpedantic]
           192 |     arg_data args[Size];
               |              ^~~~
         gmake[3]: *** [CMakeFiles/python.dir/build.make:230: 
CMakeFiles/python.dir/src/density_wrapper.cpp.o] Error 1
         gmake[3]: *** Waiting for unfinished jobs....
         gmake[2]: *** [CMakeFiles/Makefile2:87: CMakeFiles/python.dir/all] 
Error 2
         gmake[1]: *** [CMakeFiles/Makefile2:94: CMakeFiles/python.dir/rule] 
Error 2
         gmake: *** [Makefile:124: python] Error 2
         Traceback (most recent call last):
           File 
"/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py",
 line 353, in <module>
             main()
           File 
"/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py",
 line 335, in main
             json_out['return_val'] = hook(**hook_input['kwargs'])
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File 
"/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py",
 line 251, in build_wheel
             return _build_backend().build_wheel(wheel_directory, 
config_settings,
                    
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py",
 line 410, in build_wheel
             return self._build_with_temp_dir(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py",
 line 395, in _build_with_temp_dir
             self.run_setup()
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py",
 line 311, in run_setup
             exec(code, locals())
           File "<string>", line 92, in <module>
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/__init__.py",
 line 104, in setup
             return distutils.core.setup(**attrs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py",
 line 185, in setup
             return run_commands(dist)
                    ^^^^^^^^^^^^^^^^^^
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py",
 line 201, in run_commands
             dist.run_commands()
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py",
 line 969, in run_commands
             self.run_command(cmd)
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/dist.py",
 line 967, in run_command
             super().run_command(command)
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py",
 line 988, in run_command
             cmd_obj.run()
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/wheel/bdist_wheel.py",
 line 368, in run
             self.run_command("build")
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py",
 line 318, in run_command
             self.distribution.run_command(command)
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/dist.py",
 line 967, in run_command
             super().run_command(command)
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py",
 line 988, in run_command
             cmd_obj.run()
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build.py",
 line 131, in run
             self.run_command(cmd_name)
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py",
 line 318, in run_command
             self.distribution.run_command(command)
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/dist.py",
 line 967, in run_command
             super().run_command(command)
           File 
"/tmp/pip-build-env-ihc_qezq/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py",
 line 988, in run_command
             cmd_obj.run()
           File "<string>", line 46, in run
           File "<string>", line 78, in build_extension
           File "/usr/local/lib/python3.12/subprocess.py", line 413, in 
check_call
             raise CalledProcessError(retcode, cmd)
         subprocess.CalledProcessError: Command '['cmake', '--build', '.', 
'--target', 'python', '--config', 'Release', '--', '-j2']' returned non-zero 
exit status 2.
         [end of output]
   
     note: This error originates from a subprocess, and is likely not a problem 
with pip.
     ERROR: Failed building wheel for datasketches
   Failed to build datasketches
   ERROR: Could not build wheels for datasketches, which is required to install 
pyproject.toml-based projects
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to