Skip to content

Commit 413cf64

Browse files
committed
Add pyvips-binary package
Binary wheels are build using cibuildwheel for use on the most common platforms: - macOS x64 (>= 10.13) - macOS ARM64 - Linux x64 (glibc >= 2.26, musl >= 1.2.2, CPU with SSE4.2) - Linux ARM64 (glibc >= 2.26, musl >= 1.2.2) - Windows x64 - Windows x86
1 parent 4e7582b commit 413cf64

File tree

7 files changed

+447
-1
lines changed

7 files changed

+447
-1
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22

3-
on: [ push, pull_request ]
3+
on: [push, pull_request]
44

55
jobs:
66
CI:

.github/workflows/wheels.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Wheels
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
wheels:
7+
name: Build wheels on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os: [ubuntu-24.04, windows-2022, macos-13]
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up QEMU
18+
if: runner.os == 'Linux'
19+
uses: docker/setup-qemu-action@v3
20+
with:
21+
platforms: arm64
22+
23+
- name: Install pkg-config
24+
if: runner.os == 'Windows'
25+
uses: msys2/setup-msys2@v2
26+
with:
27+
msystem: ucrt64
28+
install: mingw-w64-ucrt-x86_64-pkg-config
29+
30+
- name: Put MSYS2 on PATH
31+
if: runner.os == 'Windows'
32+
run: Add-Content $env:GITHUB_PATH "$env:RUNNER_TEMP\msys64\ucrt64\bin"
33+
34+
- name: Build wheels
35+
uses: pypa/[email protected]
36+
with:
37+
package-dir: pyvips-binary
38+
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: wheels-${{ matrix.os }}
42+
path: wheelhouse/*.whl
43+
if-no-files-found: error

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ version = {attr = "pyvips.version.__version__"}
6969
exclude = [
7070
"doc*",
7171
"examples*",
72+
"pyvips-binary*",
7273
"tests*",
7374
]
7475

7576
[project.optional-dependencies]
77+
binary = ["pyvips-binary"]
7678
# All the following are used for our own testing
7779
tox = ["tox"]
7880
test = [

pyvips-binary/pyproject.toml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
[build-system]
2+
requires = [
3+
# First version of setuptools to support pyproject.toml configuration
4+
"setuptools>=61.0.0",
5+
"wheel",
6+
"cffi>=1.0.0",
7+
"pkgconfig>=1.5",
8+
]
9+
build-backend = "setuptools.build_meta"
10+
11+
[project]
12+
name = "pyvips-binary"
13+
# Must be kept in sync with `scripts/download-vips.py`
14+
version = "8.15.0"
15+
authors = [
16+
{name = "John Cupitt", email = "[email protected]"},
17+
]
18+
description = "Prebuilt libvips and dependencies for use with pyvips"
19+
license = {text = "LGPLv3+"}
20+
requires-python = ">=3.7"
21+
classifiers = [
22+
"Development Status :: 5 - Production/Stable",
23+
"Environment :: Console",
24+
"Intended Audience :: Developers",
25+
"Intended Audience :: Science/Research",
26+
"Topic :: Multimedia :: Graphics",
27+
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
28+
"OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
29+
"Programming Language :: Python",
30+
"Programming Language :: Python :: 3",
31+
"Programming Language :: Python :: 3 :: Only",
32+
"Programming Language :: Python :: 3.7",
33+
"Programming Language :: Python :: 3.8",
34+
"Programming Language :: Python :: 3.9",
35+
"Programming Language :: Python :: 3.10",
36+
"Programming Language :: Python :: 3.11",
37+
"Programming Language :: Python :: 3.12",
38+
"Programming Language :: Python :: Implementation :: CPython",
39+
"Programming Language :: Python :: Implementation :: PyPy",
40+
]
41+
42+
[tool.setuptools]
43+
include-package-data = false
44+
45+
[tool.setuptools.packages.find]
46+
exclude = ["scripts*"]
47+
48+
[tool.cibuildwheel]
49+
# Only build CPython 3.7, because we have portable abi3 wheels
50+
# Apple Silicon is only available on 3.8 and later
51+
build = [
52+
"cp37-*",
53+
"cp38-macosx_arm64"
54+
]
55+
build-frontend = "build"
56+
before-build = "bash {package}/scripts/cibw_before_build.sh"
57+
environment-pass = ["RUNNER_OS"]
58+
59+
[tool.cibuildwheel.environment]
60+
PKG_CONFIG_PATH = "./tmp/lib/pkgconfig"
61+
LD_LIBRARY_PATH = "$(pwd)/pyvips-binary/tmp/lib"
62+
DYLD_LIBRARY_PATH = "$(pwd)/pyvips-binary/tmp/lib"
63+
MACOSX_DEPLOYMENT_TARGET = "10.13"
64+
65+
[tool.cibuildwheel.linux]
66+
archs = "x86_64 aarch64"
67+
manylinux-x86_64-image = "manylinux_2_28"
68+
manylinux-aarch64-image = "manylinux_2_28"
69+
70+
[[tool.cibuildwheel.overrides]]
71+
select = "*-musllinux*"
72+
# Exclude a couple of system libraries from grafting into the resulting wheel
73+
repair-wheel-command = """\
74+
auditwheel repair -w {dest_dir} {wheel} \
75+
--exclude libc.so --exclude libstdc++.so.6 --exclude libgcc_s.so.1\
76+
"""
77+
78+
[tool.cibuildwheel.macos]
79+
archs = "x86_64 arm64"
80+
# https://github.com/pypa/cibuildwheel/pull/1169
81+
test-skip = "*-macosx_arm64"
82+
83+
[tool.cibuildwheel.windows]
84+
archs = "AMD64 x86"
85+
# Use delvewheel on Windows
86+
before-all = "pip install delvewheel"
87+
repair-wheel-command = """\
88+
delvewheel repair -w {dest_dir} {wheel} \
89+
--add-path ./pyvips-binary/tmp/lib --no-diagnostic\
90+
"""
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#/usr/bin/env bash
2+
set -xe
3+
4+
cd "$(dirname "$0")"
5+
6+
# Download and install vips
7+
basedir=$(python download-vips.py)
8+
9+
if [[ $RUNNER_OS == "Linux" ]]; then
10+
linkname="-l:libvips.so.42"
11+
elif [[ $RUNNER_OS == "Windows" ]]; then
12+
# MSVC convention: import library is called "libvips.lib"
13+
linkname="-llibvips"
14+
# GLib is compiled as a shared library in the "-static-ffi" variant
15+
# TODO: Remove after we distribute the "-static" variant in the libvips-packaging repo
16+
linkname+=" -llibglib-2.0 -llibgobject-2.0"
17+
elif [[ $RUNNER_OS == "macOS" ]]; then
18+
# -l:<LIB> syntax is unavailable with ld on macOS
19+
ln -sf libvips.42.dylib $basedir/lib/libvips.dylib
20+
# Allow delocate to find libvips.42.dylib by using an absolute path instead of @loader_path
21+
install_name_tool -id "$basedir/lib/libvips.42.dylib" $basedir/lib/libvips.42.dylib
22+
linkname="-lvips"
23+
fi
24+
25+
mkdir -p $basedir/lib/pkgconfig
26+
cat > $basedir/lib/pkgconfig/vips.pc << EOL
27+
prefix=${basedir}
28+
libdir=\${prefix}/lib
29+
includedir=\${prefix}/include
30+
31+
Name: vips
32+
Description: Image processing library
33+
Version: 8.15.0
34+
Requires:
35+
Libs: -L\${libdir} ${linkname}
36+
Cflags: -I\${includedir} -I\${includedir}/glib-2.0 -I\${libdir}/glib-2.0/include
37+
EOL

0 commit comments

Comments
 (0)