-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional dependency on pyvips-binary
#507
Conversation
Nice! Yes, maybe a separate repo is better. |
Allowing users to install pyvips with binary packages via: pip install "pyvips[binary]" See: https://pypi.org/project/pyvips-binary/.
ea769b2
to
d375529
Compare
pyvips-binary
packagepyvips-binary
... here are some testing notes: $ pkg-config --exists --print-errors vips
Package vips was not found in the pkg-config search path.
Perhaps you should add the directory containing `vips.pc'
to the PKG_CONFIG_PATH environment variable
Package 'vips', required by 'virtual:world', not found
$ pip3 install pyvips
$ python -c "import pyvips; print(pyvips.API_mode)"
ModuleNotFoundError: No module named '_libvips'
During handling of the above exception, another exception occurred:
[...]
OSError: cannot load library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory.
[...]
$ pip3 install pyvips-binary
$ python -c "import pyvips; print(pyvips.API_mode)"
True
$ python -c "import pyvips; pyvips.Image.black(1024, 1024).write_to_file('x.jpg')"
$ file x.jpg
x.jpg: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=6, orientation=upper-left, xresolution=86, yresolution=94, resolutionunit=2], baseline, precision 8, 1024x1024, components 1 |
Ah fantastic! That's so cool. I'll test here as well. Shall we put you on the |
Is is possible to invert the sense of this option? I'm sure most people should use the netvips binaries rather than the system ones. So |
Feel free to add me to the authors list! I usually use the same email address that's on my GitHub profile.
I had the same thought, but it doesn't seem to be possible at the moment. This future possible enhancement is discussed in detail here: https://discuss.python.org/t/4898. |
Maybe we could just make another pyvips package ( |
That approach might work, but I'm uncertain if it's the best option for users who prefer relying on system binaries. For example, Zulip tends to favor using libvips from the package manager (see e.g. commit zulip/zulip@e8f7e28). Additionally, pyvips is commonly used by users who process whole-slide images, something that the The Perhaps we should consider catching the Details
|
This is ready for review now. The last todo note has been fixed with https://pypi.org/project/pyvips-binary/8.16.0rc1/. |
Hooray! This is really great Kleis. |
Shall we do 3.0.0? I think everything is ready now. |
Sounds good to me, feel free to release 3.0.0 (coincidentally NetVips 3.0.0 was also released today 🎉). |
Congratulations! ... I'm being dumb, I don't seem to be able to get pyvips to find its libvips on ubuntu:
But it makes a binary with an extra (I guess?) commit number:
Then:
|
I wonder if this relates to libvips/libvips#3901 (comment), which can also be fixed by running $ pip install pyvips
Defaulting to user installation because normal site-packages is not writeable
Collecting pyvips
Using cached pyvips-2.2.3-py2.py3-none-any.whl
Requirement already satisfied: cffi>=1.0.0 in /usr/lib64/python3.12/site-packages (from pyvips) (1.16.0)
Requirement already satisfied: pycparser in ./.local/lib/python3.12/site-packages (from cffi>=1.0.0->pyvips) (2.22)
Installing collected packages: pyvips
Successfully installed pyvips-2.2.3
$ pip install pyvips-binary
Defaulting to user installation because normal site-packages is not writeable
Collecting pyvips-binary
Downloading pyvips_binary-8.16.0-cp37-abi3-manylinux_2_28_x86_64.whl.metadata (2.3 kB)
Requirement already satisfied: cffi>=1.0.0 in /usr/lib64/python3.12/site-packages (from pyvips-binary) (1.16.0)
Requirement already satisfied: pycparser in ./.local/lib/python3.12/site-packages (from cffi>=1.0.0->pyvips-binary) (2.22)
Downloading pyvips_binary-8.16.0-cp37-abi3-manylinux_2_28_x86_64.whl (7.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.2/7.2 MB 8.9 MB/s eta 0:00:00
Installing collected packages: pyvips-binary
Successfully installed pyvips-binary-8.16.0
$ ldd $(python -m site --user-site)/_libvips.abi3.so
linux-vdso.so.1 (0x00007fd3d253a000)
libvips-541602e6.so.42 => /home/kleisauke/.local/lib/python3.12/site-packages/pyvips_binary.libs/libvips-541602e6.so.42 (0x00007fd3d1200000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd3d24f4000)
libc.so.6 => /lib64/libc.so.6 (0x00007fd3d100f000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fd3d24e2000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fd3d24dd000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fd3d0c00000)
libm.so.6 => /lib64/libm.so.6 (0x00007fd3d23f7000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fd3d23c9000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd3d253c000)
$ python3
Python 3.12.7 (main, Oct 1 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> print(pyvips.API_mode)
True
>>> |
The naming of |
Allowing users to install pyvips with binary packages via:
$ pip install "pyvips[binary]"
See: https://pypi.org/project/pyvips-binary/.
Marked as draft due to this notes:
Perhaps this should be in a separate repository?Done: https://github.com/kleisauke/pyvips-binaryWindows binaries are currently using the
# GLib is compiled as a shared library in the "-static-ffi" variant
# TODO: Remove after we distribute the "-static" variant in the libvips-packaging repo
linkname+=" -llibglib-2.0 -llibgobject-2.0"
Done: https://pypi.org/project/pyvips-binary/8.16.0rc1/-static-ffi
variant. The plan is to distribute the-static
variant when libvips 8.16 is released.pyvips/pyvips-binary/scripts/cibw_before_build.sh
Lines 14 to 16 in ea769b2
(this will also require a major bump in NetVips, see e.g. commit kleisauke/net-vips@8856756)