Skip to content

Commit ac5b061

Browse files
authored
Merge pull request #60 from quietvoid/python-build
Add Python build support
2 parents ae637f0 + e684d85 commit ac5b061

8 files changed

Lines changed: 312 additions & 111 deletions

File tree

.github/workflows/build.yml

Lines changed: 79 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,52 @@
11
name: Build
22

3-
on: [workflow_dispatch]
4-
5-
permissions:
6-
attestations: write
7-
contents: read
8-
id-token: write
9-
10-
env:
11-
LIBPLACEBO_TAG: v7.360.1
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
129

1310
jobs:
14-
build-linux:
15-
runs-on: ubuntu-24.04
11+
build-non-windows-wheel:
12+
strategy:
13+
matrix:
14+
include:
15+
- arch: linux_x86_64
16+
runs-on: ubuntu-latest
17+
- arch: linux_aarch64
18+
runs-on: ubuntu-24.04-arm
19+
- arch: macosx_x86_64
20+
runs-on: macos-15-intel
21+
- arch: macosx_arm64
22+
runs-on: macos-15
23+
fail-fast: false
24+
25+
runs-on: ${{ matrix.runs-on }}
26+
1627
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v6.0.2
28+
- uses: actions/checkout@v6
1929
with:
2030
submodules: recursive
2131

22-
- name: Setup Python
23-
uses: actions/setup-python@v6.2.0
32+
- uses: pypa/cibuildwheel@v3.4.1
2433
with:
25-
python-version: "3.14.3"
26-
- name: Install uv
27-
uses: astral-sh/setup-uv@v7.6.0
28-
- name: Install Python dependencies
29-
run: |
30-
uv tool install meson
31-
uv tool install ninja
34+
output-dir: dist
35+
extras: uv
3236

33-
- name: Install APT dependencies
37+
- name: Fix tag
3438
run: |
35-
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
36-
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
37-
38-
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
39-
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
39+
cd dist
40+
for whl in *.whl; do
41+
pipx run wheel tags --remove --python-tag py3 --abi-tag none $whl
42+
done
4043
41-
sudo apt update
42-
sudo apt install -y cmake glslang-dev shaderc vulkan-headers
43-
44-
- name: Checkout SPIRV
45-
uses: actions/checkout@v6.0.2
44+
- uses: actions/upload-artifact@v7
4645
with:
47-
repository: KhronosGroup/SPIRV-Cross
48-
ref: sdk-1.3.236.0
49-
path: temp/SPIRV-Cross
50-
- name: Install SPIRV
51-
working-directory: ./temp/SPIRV-Cross
52-
run: |
53-
cmake -H. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
54-
-DSPIRV_CROSS_SHARED=ON -DSPIRV_CROSS_CLI=OFF \
55-
-DSPIRV_CROSS_ENABLE_TESTS=OFF ..
56-
ninja -Cbuild
57-
sudo $(which ninja) -Cbuild install
58-
59-
- name: Checkout VapourSynth
60-
uses: actions/checkout@v6.0.2
61-
with:
62-
repository: vapoursynth/vapoursynth
63-
ref: R68
64-
path: vapoursynth
65-
- name: Install VapourSynth
66-
run: |
67-
git clone https://bitbucket.org/the-sekrit-twc/zimg.git --depth 1 --recurse-submodules --shallow-submodules
68-
pushd zimg
69-
./autogen.sh
70-
./configure --prefix=/usr
71-
sudo make install -j$(nproc)
72-
popd
73-
74-
pushd vapoursynth
75-
./autogen.sh
76-
./configure --prefix=/usr --disable-python-module --disable-vsscript
77-
sudo make install -j$(nproc)
78-
79-
- name: Setup libplacebo subproject
80-
uses: actions/checkout@v6
81-
with:
82-
repository: haasn/libplacebo
83-
ref: ${{ env.LIBPLACEBO_TAG }}
84-
path: 'subprojects/libplacebo'
85-
submodules: recursive
86-
87-
- name: Build vs-placebo
88-
run: |
89-
meson setup build --buildtype release -Dlibplacebo:demos=false -Dlibplacebo:glslang=enabled
90-
meson compile -vC build
46+
name: vs-placebo-${{ matrix.arch }}
47+
path: dist
9148

92-
build-windows:
49+
build-windows-wheel:
9350
runs-on: windows-latest
9451
defaults:
9552
run:
@@ -100,47 +57,68 @@ jobs:
10057
with:
10158
submodules: recursive
10259
- name: Setup MSYS2
103-
uses: msys2/setup-msys2@v2.27.0
60+
uses: msys2/setup-msys2@v2
10461
with:
10562
msystem: UCRT64
63+
update: true
10664
install: >-
10765
base-devel
66+
mingw-w64-ucrt-x86_64-git
10867
mingw-w64-ucrt-x86_64-jq
10968
mingw-w64-ucrt-x86_64-gcc
110-
mingw-w64-ucrt-x86_64-pkg-config
69+
mingw-w64-ucrt-x86_64-python-build
70+
mingw-w64-ucrt-x86_64-pkgconf
11171
mingw-w64-ucrt-x86_64-vapoursynth
11272
mingw-w64-ucrt-x86_64-meson
11373
mingw-w64-ucrt-x86_64-ninja
11474
mingw-w64-ucrt-x86_64-spirv-tools
11575
mingw-w64-ucrt-x86_64-spirv-cross
116-
mingw-w64-ucrt-x86_64-vulkan
11776
mingw-w64-ucrt-x86_64-vulkan-headers
11877
mingw-w64-ucrt-x86_64-vulkan-loader
11978
mingw-w64-ucrt-x86_64-libdovi
12079
mingw-w64-ucrt-x86_64-lcms2
12180
mingw-w64-ucrt-x86_64-shaderc
122-
123-
- name: Setup libplacebo subproject
124-
uses: actions/checkout@v6
125-
with:
126-
repository: haasn/libplacebo
127-
ref: ${{ env.LIBPLACEBO_TAG }}
128-
path: 'subprojects/libplacebo'
129-
submodules: recursive
81+
mingw-w64-ucrt-x86_64-uv
13082
13183
- name: Build vs-placebo
13284
run: |
133-
meson setup build --buildtype release --prefer-static --default-library=static -Dcpp_link_args='-static' -Dlibplacebo:demos=false -Dlibplacebo:glslang=enabled
134-
meson compile -vC build
135-
- name: Attest build provenance
136-
uses: actions/attest-build-provenance@v4.1.0
137-
with:
138-
subject-path: build/libvs_placebo.dll
139-
- name: Export version
85+
: # FIXME: uv does not want to work with subprojects
86+
python -m build --wheel -Csetup-args="--default-library=static" \
87+
-Csetup-args="-Dprefer_static=true" \
88+
-Csetup-args="-Dlibplacebo:demos=false" \
89+
-Csetup-args="-Dlibplacebo:glslang=enabled"
90+
91+
- name: Fix tag
14092
run: |
141-
echo "ARTIFACT_VERSION=$(meson introspect --projectinfo build | jq -r '.version')" >> $GITHUB_ENV
142-
- name: Upload
143-
uses: actions/upload-artifact@v7.0.0
93+
cd dist
94+
for whl in *.whl; do
95+
uvx wheel tags --remove --python-tag py3 --abi-tag none --platform-tag win_amd64 $whl
96+
done
97+
98+
- name: Build sdist
99+
run: python -m build --sdist
100+
101+
- uses: actions/upload-artifact@v7
102+
with:
103+
name: vs-placebo-sdist
104+
path: dist/*.tar.gz
105+
106+
- uses: actions/upload-artifact@v7
144107
with:
145-
name: vsplacebo-windows-${{ env.ARTIFACT_VERSION }}
146-
path: build/libvs_placebo.dll
108+
name: vs-placebo-win_amd64
109+
path: dist/*.whl
110+
111+
publish:
112+
permissions:
113+
id-token: write
114+
needs: [build-non-windows-wheel, build-windows-wheel]
115+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
116+
runs-on: ubuntu-latest
117+
118+
steps:
119+
- uses: actions/download-artifact@v8
120+
with:
121+
path: dist
122+
merge-multiple: true
123+
124+
- uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ build
22
.vscode
33
.cache/*
44
.DS_Store
5+
6+
subprojects/*
7+
!subprojects/*.wrap

cibw/before_all_linux.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
if command -v dnf >/dev/null 2>&1; then
5+
dnf -y install cmake openssl3-devel libXrandr-devel
6+
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/lib64/pkgconfig"
7+
ln -s /usr/lib64/pkgconfig/openssl3.pc /usr/lib64/pkgconfig/openssl.pc
8+
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
9+
source ~/.cargo/env
10+
cargo install cargo-c
11+
else
12+
apk add --no-cache cmake rust cargo cargo-c libxrandr-dev
13+
fi
14+
15+
uv tool install meson
16+
uv tool install ninja
17+
export PATH="${PATH}:$HOME/.local/bin"
18+
19+
git clone https://github.com/KhronosGroup/Vulkan-Headers.git --branch "${VULKAN_SDK_TAG}" --depth 1
20+
cd Vulkan-Headers
21+
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr
22+
cmake --build build
23+
cmake --install build
24+
cd ..
25+
rm -rf Vulkan-Headers
26+
27+
git clone https://github.com/KhronosGroup/Vulkan-Loader --branch "${VULKAN_SDK_TAG}" --depth 1
28+
cd Vulkan-Loader
29+
cmake -B build -D CMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \
30+
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
31+
-DCMAKE_SKIP_INSTALL_RPATH=ON
32+
cmake --build build
33+
cmake --install build
34+
cd ..
35+
rm -rf Vulkan-Loader
36+
37+
git clone https://github.com/KhronosGroup/SPIRV-Headers.git --branch "${VULKAN_SDK_TAG}" --depth 1
38+
cd SPIRV-Headers
39+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
40+
cmake --build build
41+
cmake --install build
42+
cd ..
43+
rm -rf SPIRV-Headers
44+
45+
git clone https://github.com/KhronosGroup/SPIRV-Tools.git --branch "${VULKAN_SDK_TAG}" --depth 1
46+
cd SPIRV-Tools
47+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
48+
-DCMAKE_INSTALL_PREFIX=/usr \
49+
-DBUILD_SHARED_LIBS=ON \
50+
-DSPIRV_TOOLS_BUILD_STATIC=OFF \
51+
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
52+
-DSPIRV-Headers_SOURCE_DIR=/usr
53+
cmake --build build
54+
cmake --install build
55+
cd ..
56+
rm -rf SPIRV-Tools
57+
58+
git clone https://github.com/KhronosGroup/SPIRV-Cross.git --branch "${VULKAN_SDK_TAG}" --depth 1
59+
cd SPIRV-Cross
60+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
61+
-DCMAKE_INSTALL_PREFIX=/usr \
62+
-DSPIRV_CROSS_SHARED=ON \
63+
-DSPIRV_CROSS_STATIC=OFF \
64+
-DSPIRV_CROSS_CLI=OFF \
65+
-DSPIRV_CROSS_ENABLE_TESTS=OFF \
66+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
67+
cmake --build build
68+
cmake --install build
69+
cd ..
70+
rm -rf SPIRV-Cross
71+
72+
git clone https://github.com/KhronosGroup/glslang.git --branch "${VULKAN_SDK_TAG}" --depth 1
73+
cd glslang
74+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
75+
-DCMAKE_INSTALL_PREFIX=/usr \
76+
-DALLOW_EXTERNAL_SPIRV_TOOLS='ON' \
77+
-DBUILD_SHARED_LIBS='ON'
78+
cmake --build build
79+
cmake --install build
80+
cd ..
81+
rm -rf glslang
82+
83+
git clone https://github.com/google/shaderc.git --branch "${SHADERC_TAG}" --depth 1
84+
cd shaderc
85+
sed '/examples/d;/third_party/d' -i CMakeLists.txt
86+
sed '/build-version/d' -i glslc/CMakeLists.txt
87+
printf "\"${SHADERC_VERSION}\"\n\"${VULKAN_SDK_VERSION}\"\n\"${VULKAN_SDK_VERSION}\"\n" > glslc/src/build-version.inc
88+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
89+
-DCMAKE_INSTALL_PREFIX=/usr \
90+
-DSHADERC_SKIP_TESTS=ON \
91+
-Dglslang_SOURCE_DIR=/usr/include/glslang
92+
cmake --build build
93+
cmake --install build
94+
cd ..
95+
rm -rf shaderc
96+
97+
git clone https://github.com/quietvoid/dovi_tool.git --branch "${LIBDOVI_TAG}" --depth 1
98+
cd dovi_tool/dolby_vision
99+
cargo fetch --locked
100+
cargo cbuild --frozen --profile release-deploy \
101+
--library-type cdylib \
102+
--prefix=/usr
103+
cargo cinstall --frozen --profile release-deploy \
104+
--library-type cdylib \
105+
--prefix=/usr
106+
cd ../..
107+
rm -rf dovi_tool
108+
109+
git clone https://github.com/haasn/libplacebo.git --branch "${LIBPLACEBO_TAG}" --depth 1
110+
cd libplacebo
111+
git submodule update --init
112+
meson setup build --buildtype=release --prefix=/usr \
113+
-Dvulkan=enabled \
114+
-Dglslang=enabled \
115+
-Dshaderc=enabled
116+
meson compile -C build
117+
meson install -C build
118+
cd ..
119+
rm -rf libplacebo

cibw/before_all_macos.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
brew update
5+
brew install libplacebo shaderc glslang dovi_tool

0 commit comments

Comments
 (0)