Skip to content

Unversioned `numpy` build dependency breaks build

Now that numpy has updated their latest version to 2.0.0 on June 16, 2024 (roughly 10 days ago as of this writing), the build cannot succeed because it is always attempting to use the 2.0.0 headers.

There is a proposed fix but I am unsure if it will work in the general case as building against 2.x but running against 1.x is unlikely to work.

To reproduce, simply create a requirements.txt with:

numpy==1.24.3
SharedArray==3.2.2

and attempt to pip install -r requirements.txt. You'll get an error like

x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-5yz5exhh/overlay/lib/python3.10/site-packages/numpy/_core/include -I/home/jywei/openpcdet/include -I/usr/include/python3.10 -c ./src/shared_array_create.c -o build/temp.linux-x86_64-cpython-310/./src/shared_array_create.o
  ./src/shared_array_create.c: In function ‘do_create’:
  ./src/shared_array_create.c:58:21: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘elsize’
     58 |         size = dtype->elsize;
        |                     ^~
  ./src/shared_array_create.c:94:31: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘elsize’
     94 |         meta->itemsize = dtype->elsize;
        |                               ^~
  ./src/shared_array_create.c:108:50: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘elsize’
    108 |                             NULL, map_addr, dtype->elsize,
        |                                                  ^~
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

If you turn on -v -v, you will also see

Collecting numpy
    Using cached https://some.server/pypi/packages/packages/d6/a8/6a2419c40c7b6f7cb4ef52c532c88e55490c4fa92885964757d507adddce/numpy-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.3 MB)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information