distributed `blosc2.pc` has wrong prefix
nega0 opened this issue · 7 comments
The distributed blosc2.pc
includes the wrong prefix. This obviously complicates anything that tries to use pkg-config
to detect blsoc2
. Basically whatever temporary directory python-blosc2
is installed to during the build process becomes the prefix.
The two wheels I've checked have:
- macOS-arm64:
prefix=/Users/runner/work/python-blosc2/python-blosc2/_skbuild/macosx-11.0-arm64-3.11/cmake-install
- linux-x86_64:
prefix=/project/_skbuild/linux-x86_64-3.10/cmake-install
When installing from source you get something akin to:
prefix=/Users/nega/Downloads/python-blosc2/_skbuild/macosx-13.0-arm64-3.11/cmake-install
Three ways I see to address this issue are
- during the build process, edit the
build2.pc
after its creation - take advantage of DESTDIR during the build of
c-blosc2
- remove
build2.pc
outright
See also PyTables/PyTables#998
The following is a demonstration of installing python-blosc2
into a clean virtual env creatively called "blosc2".
❯ python -m venv blosc2
❯ . blosc2/bin/activate
blosc2 ❯ pip3 install --upgrade blosc2
[... 8< ...]
Successfully installed blosc2-2.2.1 markdown-it-py-2.2.0 mdurl-0.1.2 msgpack-1.0.5 ndindex-1.7 numpy-1.24.3 py-cpuinfo-9.0.0 pygments-2.15.1 rich-13.3.5
blosc2 ❯ find ./blosc2 -name blosc2.pc
./blosc2/lib/pkgconfig/blosc2.pc
blosc2 ❯ cat ./blosc2/lib/pkgconfig/blosc2.pc
prefix=/Users/runner/work/python-blosc2/python-blosc2/_skbuild/macosx-11.0-arm64-3.11/cmake-install
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
sharedlibdir=${libdir}
includedir=${prefix}/include
Name: blosc2
Description: A blocking, shuffling and lossless compression library
URL: https://blosc.org/
Version: 2.9.1
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lblosc2
Cflags: -I${includedir}
blosc2 ❯ find blosc2 -name libblosc2\*
blosc2/lib/libblosc2.2.dylib
blosc2/lib/libblosc2.a
blosc2/lib/libblosc2.2.9.1.dylib
blosc2/lib/libblosc2.dylib
https://github.com/Blosc/c-blosc2/blob/4e78fbb9dccf7563cd93d36821c696d06b302972/blosc2.pc.in#L1:
prefix=@CMAKE_INSTALL_PREFIX@
scikit-build sets that variable. Maybe it should not.
https://github.com/scikit-build/scikit-build/blob/8e9eab0752ca7e0bea39814e712f9f4535806516/skbuild/cmaker.py#L279
CMAKE_INSTALL_PREFIX
should respond to DESTDIR
. I didn't look specifically what python-blosc2
is doing, but if you were staging a general CMake project for distribution you'd do something like
$ cmake -DCMAKE_INSTALL_PREFIX=/opt/project ../src
$ make DESTDIR=/scratch/staging_area install
and it will install to /scratch/staging_area/opt/project/{lib,bin,share,etc,etc}
you can then tar it up or whatever, and paths will be correct for the final destination. there's a bit more to it than that.
Additionally, CMake can generate pkg-config *.pc files. Maybe c-blosc2
should be taking advantage of that instead of just running blosc2.pc
through configure_file()
.
prefix=@CMAKE_INSTALL_PREFIX@
for a library.pc.in
file is a common pattern though. Maybe scikit-build should split up their setting into CMAKE_INSTALL_PREFIX
and DESTDIR
.
cc @henryiii
OTOH, how is a python build backend supposed to know where a wheel is to be installed? The shipped .pc.in
in the wheel will have a hardcoded prefix but the installation could be in any PYTHONPATH (venv, system, user, ...). Thus, a wheel should not have the pkconfig file at all.
Thus, a wheel should not have the pkconfig file at all.
Aggreed
Thus, a wheel should not have the pkconfig file at all.
Aggreed
Sounds good to me too. Any idea on how to prevent blosc2.pc to go in the wheel? Happy to remove it.
👍