Skip to content

Commit aff5c9c

Browse files
authored
Publish on PyPI (#186)
1 parent 04d6e23 commit aff5c9c

File tree

4 files changed

+112
-64
lines changed

4 files changed

+112
-64
lines changed

.github/workflows/publish.yml

Lines changed: 86 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,76 +7,110 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build:
11-
name: Build distributions on ${{ matrix.os }} (Python ${{ matrix.python-version }})
10+
build_wheels:
11+
name: Build wheels on ${{ matrix.os }} ${{ matrix.arch }} ${{ matrix.python }}
1212
runs-on: ${{ matrix.os }}
1313
strategy:
14+
fail-fast: false
1415
matrix:
15-
os: [ubuntu-latest, windows-latest]
16-
python-version: ['3.10', '3.11', '3.12']
16+
include:
17+
# Linux x86_64
18+
- os: ubuntu-latest
19+
python: cp310
20+
arch: x86_64
21+
- os: ubuntu-latest
22+
python: cp311
23+
arch: x86_64
24+
- os: ubuntu-latest
25+
python: cp312
26+
arch: x86_64
27+
- os: ubuntu-latest
28+
python: cp313
29+
arch: x86_64
30+
# Linux aarch64
31+
- os: ubuntu-latest
32+
python: cp310
33+
arch: aarch64
34+
- os: ubuntu-latest
35+
python: cp311
36+
arch: aarch64
37+
- os: ubuntu-latest
38+
python: cp312
39+
arch: aarch64
40+
- os: ubuntu-latest
41+
python: cp313
42+
arch: aarch64
43+
# Windows
44+
- os: windows-latest
45+
python: cp310
46+
arch: AMD64
47+
- os: windows-latest
48+
python: cp311
49+
arch: AMD64
50+
- os: windows-latest
51+
python: cp312
52+
arch: AMD64
53+
- os: windows-latest
54+
python: cp313
55+
arch: AMD64
56+
1757
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
58+
- uses: actions/checkout@v4
2059
with:
2160
submodules: true
2261

23-
- name: Install dependencies (Linux)
24-
if: runner.os == 'Linux'
25-
run: |
26-
sudo apt-get update
27-
sudo apt-get install -y \
28-
libglm-dev libglfw3-dev libpng-dev libjpeg-dev libeigen3-dev
62+
- name: Docker login
63+
continue-on-error: true
64+
uses: docker/login-action@v1
65+
with:
66+
username: ${{ secrets.DOCKER_USERNAME }}
67+
password: ${{ secrets.DOCKER_TOKEN }}
68+
69+
- name: Set up QEMU
70+
if: matrix.arch == 'aarch64'
71+
uses: docker/setup-qemu-action@v3
2972

30-
- name: Set up Python
31-
uses: actions/setup-python@v4
73+
- name: Build wheels
74+
uses: pypa/[email protected]
75+
env:
76+
CIBW_BUILD: ${{ matrix.python }}-*
77+
CIBW_ARCHS: ${{ matrix.arch }}
78+
79+
- uses: actions/upload-artifact@v4
3280
with:
33-
python-version: ${{ matrix.python-version }}
34-
cache: 'pip'
81+
name: cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.python }}
82+
path: ./wheelhouse/*.whl
3583

36-
- name: Upgrade pip and install build deps
37-
run: |
38-
python -m pip install --upgrade pip
39-
pip install build setuptools scikit-build scikit-build-core pybind11
84+
build_sdist:
85+
name: Build source distribution
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
with:
90+
submodules: true
4091

41-
- name: Build sdist and wheel
42-
run: |
43-
python -m build --sdist --wheel -n
92+
- name: Build sdist
93+
run: pipx run build --sdist
4494

45-
- name: Upload built distributions as artifact
46-
uses: actions/upload-artifact@v4
95+
- uses: actions/upload-artifact@v4
4796
with:
48-
name: dist-${{ matrix.os }}-${{ matrix.python-version }}
49-
path: dist/*
97+
name: cibw-sdist
98+
path: dist/*.tar.gz
5099

51100
publish:
52101
name: Publish to PyPI
102+
needs: [build_wheels, build_sdist]
53103
runs-on: ubuntu-latest
54-
needs: build
55104
if: startsWith(github.ref, 'refs/tags/v')
56105
steps:
57-
- name: Download build artifacts
58-
uses: actions/download-artifact@v4
106+
- uses: actions/download-artifact@v4
59107
with:
60-
# download all artifacts produced by the build job
61-
path: downloaded_artifacts
62-
63-
- name: Collect distributions into dist/
64-
run: |
65-
mkdir -p dist
66-
find downloaded_artifacts -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec cp {} dist/ \;
67-
68-
- name: Show collected files
69-
run: ls -la dist || true
108+
pattern: cibw-*
109+
path: dist
110+
merge-multiple: true
70111

71-
- name: Install twine
72-
run: python -m pip install --upgrade pip twine
73-
74-
- name: Publish to PyPI via Twine
75-
env:
76-
TWINE_USERNAME: __token__
77-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
78-
run: |
79-
python -m pip install --upgrade twine
80-
# twine check may warn but won't block publishing here
81-
twine check dist/* || true
82-
twine upload --non-interactive -u "$TWINE_USERNAME" -p "$TWINE_PASSWORD" dist/*
112+
- name: Publish to PyPI
113+
uses: pypa/gh-action-pypi-publish@release/v1
114+
with:
115+
user: __token__
116+
password: ${{ secrets.PYPI_API_TOKEN }}

pyproject.toml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
[project]
2-
name = "pyridescence"
3-
version = "0.1.7"
4-
authors = [{name = "Kenji Koide", email = "[email protected]"}]
5-
description = "3D visualization library for rapid prototyping of 3D algorithms"
6-
readme = "README.md"
7-
license = {file = "LICENSE"}
8-
requires-python = ">=3.7"
9-
dependencies = ["numpy"]
10-
111
[build-system]
122
requires = ["setuptools", "scikit-build>=0.13", "scikit-build-core >=0.10", "pybind11 >2.10.0"]
133
build-backend = "scikit_build_core.setuptools.build_meta"
144

155
[tool.scikit-build.cmake.define]
166
BUILD_PYTHON_BINDINGS = true
177
BUILD_SHARED_LIBS = false
8+
9+
[tool.cibuildwheel.linux]
10+
before-all = "yum install -y libpng-devel libjpeg-turbo-devel wayland-devel mesa-libGL-devel libX11-devel libXcursor-devel libXinerama-devel libXrandr-devel libXi-devel libxkbcommon-devel"
11+
12+
[tool.cibuildwheel]
13+
manylinux-x86_64-image = "manylinux_2_28"
14+
manylinux-aarch64-image = "manylinux_2_28"
15+
build = "*"
16+
skip = "pp* *-win32 *_i686 *musllinux*" # Don't build for PyPy, Win32, i686

setup.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
from setuptools import find_packages, setup
2+
3+
with open("README.md", "r", encoding="utf-8") as fh:
4+
long_description = fh.read()
5+
26
setup(
7+
name="pyridescence",
8+
version="0.1.7",
9+
author="Kenji Koide",
10+
author_email="[email protected]",
11+
description="3D visualization library for rapid prototyping of 3D algorithms",
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
license="MIT",
315
cmake_source_dir=".",
4-
packages=['pyridescence_data'],
16+
packages=['pyridescence_data', 'pyridescence_data.texture', 'pyridescence_data.shader', 'pyridescence_data.models'],
517
package_dir={'pyridescence_data': 'data'},
6-
include_package_data=True
18+
include_package_data=True,
19+
python_requires=">=3.7",
20+
install_requires=["numpy"],
721
)

src/glk/io/ply_io.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <glk/io/ply_io.hpp>
22

3+
#include <cstdint>
34
#include <vector>
45
#include <unordered_map>
56
#include <fstream>

0 commit comments

Comments
 (0)