Skip to content

Commit 8dc7624

Browse files
authored
Merge pull request #21 from gtfierro/fixing-build
Fixing release process
2 parents 5238519 + 510f693 commit 8dc7624

File tree

13 files changed

+168
-67
lines changed

13 files changed

+168
-67
lines changed

.github/workflows/artifacts.yml

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
release:
55
types:
66
- published
7+
workflow_dispatch:
8+
inputs:
9+
run_full_matrix:
10+
description: Build all additional architectures (aarch64, universal2, etc.)
11+
type: boolean
12+
default: true
713

814
concurrency:
915
group: ${{ github.workflow }}-${{ github.ref }}
@@ -126,13 +132,41 @@ jobs:
126132
cache-dependency-path: '**/requirements.dev.txt'
127133
- run: pip install -r python/requirements.dev.txt
128134
- run: maturin build -m python/Cargo.toml
129-
- run: pip install --no-index --find-links=target/wheels/ pyontoenv
135+
- run: pip install --no-index --find-links=target/wheels/ ontoenv
130136
- run: rm -r target/wheels
131137
- run: maturin sdist -m python/Cargo.toml
132138
- uses: actions/upload-artifact@v4
133139
with:
134-
name: pyontoenv_dist
140+
name: ontoenv_dist
135141
path: target/wheels/*.tar.gz
142+
python_pyontoenv_alias:
143+
runs-on: ubuntu-latest
144+
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
145+
steps:
146+
- uses: actions/checkout@v4
147+
with:
148+
submodules: true
149+
- uses: actions/setup-python@v5
150+
with:
151+
python-version: "3.12"
152+
- run: |
153+
VERSION=$(awk '
154+
/^\[workspace.package\]/ { in_section=1; next }
155+
/^\[/ { if (in_section) exit; in_section=0 }
156+
in_section && $1 ~ /^version/ {
157+
gsub(/"/, "", $3);
158+
print $3;
159+
exit
160+
}
161+
' Cargo.toml)
162+
echo "ONTOENV_VERSION=$VERSION" >> "$GITHUB_ENV"
163+
- run: pip install build
164+
- run: python -m build
165+
working-directory: ./pyontoenv-shim
166+
- uses: actions/upload-artifact@v4
167+
with:
168+
name: ontoenv_pyontoenv_alias
169+
path: pyontoenv-shim/dist/*
136170

137171
wheel_linux:
138172
runs-on: ubuntu-latest
@@ -147,16 +181,16 @@ jobs:
147181
- uses: docker/setup-qemu-action@v2
148182
with:
149183
platforms: linux/${{ matrix.architecture }}
150-
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
184+
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true') && matrix.architecture != 'x86_64'
151185
- uses: ./.github/actions/setup-rust
152186
with:
153187
version: stable
154-
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/manylinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/manylinux_build_script.sh
155-
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/manylinux2014_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/manylinux_build_script.sh
156-
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
188+
- run: sed "s/%arch%/${{ matrix.architecture }}/g" .github/workflows/manylinux_build.sh | sed "s/%for_each_version%/${{ (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true')) && 'true' || '' }}/g" > .github/workflows/manylinux_build_script.sh
189+
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/manylinux_2_28_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/manylinux_build_script.sh
190+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true') || matrix.architecture == 'x86_64'
157191
- uses: actions/upload-artifact@v4
158192
with:
159-
name: pyontoenv_${{ matrix.architecture }}_linux_gnu
193+
name: ontoenv_${{ matrix.architecture }}_linux_gnu
160194
path: target/wheels/*.whl
161195

162196
wheel_linux_musl:
@@ -172,17 +206,17 @@ jobs:
172206
- uses: docker/setup-qemu-action@v2
173207
with:
174208
platforms: linux/${{ matrix.architecture }}
175-
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
209+
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true') && matrix.architecture != 'x86_64'
176210
- uses: ./.github/actions/setup-rust
177211
with:
178212
version: stable
179-
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/musllinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/musllinux_build_script.sh
213+
- run: sed "s/%arch%/${{ matrix.architecture }}/g" .github/workflows/musllinux_build.sh | sed "s/%for_each_version%/${{ (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true')) && 'true' || '' }}/g" > .github/workflows/musllinux_build_script.sh
180214
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/musllinux_1_2_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/musllinux_build_script.sh
181-
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
215+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true') || matrix.architecture == 'x86_64'
182216
- run: find .
183217
- uses: actions/upload-artifact@v4
184218
with:
185-
name: pyontoenv_${{ matrix.architecture }}_linux_musl
219+
name: ontoenv_${{ matrix.architecture }}_linux_musl
186220
path: target/wheels/*.whl
187221

188222
wheel_mac:
@@ -211,19 +245,19 @@ jobs:
211245
- run: pip install -r python/requirements.dev.txt
212246
- run: maturin build --release --features abi3
213247
working-directory: ./python
214-
- run: pip install --no-index --find-links=target/wheels/ pyontoenv
248+
- run: pip install --no-index --find-links=target/wheels/ ontoenv
215249
- run: rm -r target/wheels
216250
- run: maturin build --release --target universal2-apple-darwin --features abi3
217251
working-directory: ./python
218252
- run: maturin build --release --target x86_64-apple-darwin --features abi3
219253
working-directory: ./python
220-
if: github.event_name == 'release'
254+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true')
221255
- run: maturin build --release --target aarch64-apple-darwin --features abi3
222256
working-directory: ./python
223-
if: github.event_name == 'release'
257+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true')
224258
- uses: actions/upload-artifact@v4
225259
with:
226-
name: pyontoenv_macos
260+
name: ontoenv_macos
227261
path: target/wheels/*.whl
228262

229263
wheel_windows:
@@ -244,32 +278,33 @@ jobs:
244278
- run: pip install -r python/requirements.dev.txt
245279
- run: maturin build --release --features abi3
246280
working-directory: ./python
247-
- run: pip install --no-index --find-links=target/wheels/ pyontoenv
281+
- run: pip install --no-index --find-links=target/wheels/ ontoenv
248282
- run: rm -r target/wheels
249283
- run: maturin build --release -m python/Cargo.toml --features abi3
250284
- uses: actions/upload-artifact@v4
251285
with:
252-
name: pyontoenv_windows
286+
name: ontoenv_windows
253287
path: target/wheels/*.whl
254288

255289
publish_pypi:
256290
if: github.event_name == 'release'
257291
runs-on: ubuntu-latest
258292
environment:
259293
name: publish
260-
url: https://pypi.org/p/pyontoenv
294+
url: https://pypi.org/p/ontoenv
261295
permissions:
262296
id-token: write
263297
needs:
264298
- python_sdist
299+
- python_pyontoenv_alias
265300
- wheel_windows
266301
- wheel_mac
267302
- wheel_linux
268303
- wheel_linux_musl
269304
steps:
270305
- uses: actions/download-artifact@v4
271306
with:
272-
pattern: pyontoenv_*
307+
pattern: ontoenv_*
273308
path: dist
274309
merge-multiple: true
275310
- uses: pypa/gh-action-pypi-publish@release/v1
@@ -301,15 +336,6 @@ jobs:
301336
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
302337
env:
303338
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
304-
- name: Wait for crate index propagation
305-
run: sleep 45
306-
- name: Publish pyontoenv crate
307-
uses: katyo/publish-crates@v2
308-
with:
309-
path: './python'
310-
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
311-
env:
312-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
313339
full_archive:
314340
if: github.event_name == 'release'
315341
runs-on: ubuntu-latest
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
# from https://github.com/oxigraph/oxigraph/blob/main/.github/workflows/manylinux_build.sh
2+
set -euxo pipefail
23
cd /workdir
3-
yum -y install centos-release-scl-rh
4-
yum -y install llvm-toolset-7.0
5-
source scl_source enable llvm-toolset-7.0
4+
if command -v dnf >/dev/null 2>&1; then
5+
dnf -y update
6+
dnf -y install clang cmake make gcc-c++
7+
elif command -v yum >/dev/null 2>&1; then
8+
yum -y update
9+
yum -y install clang cmake make gcc-c++
10+
else
11+
echo "No supported package manager found (dnf/yum)" >&2
12+
exit 1
13+
fi
614
curl https://static.rust-lang.org/rustup/dist/%arch%-unknown-linux-gnu/rustup-init --output rustup-init
715
chmod +x rustup-init
816
./rustup-init -y --profile minimal --default-toolchain stable
917
source "$HOME/.cargo/env"
10-
export PATH="${PATH}:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin:/opt/python/cp311-cp311/bin"
18+
export PATH="${PATH}:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin:/opt/python/cp311-cp311/bin:/opt/python/cp312-cp312/bin"
1119
cd python
1220
python3.12 -m venv venv
1321
source venv/bin/activate
1422
pip install -r requirements.dev.txt
1523
maturin develop --release
16-
maturin build --release --features abi3 --compatibility manylinux2014
24+
maturin build --release --features abi3 --compatibility manylinux_2_28
1725
if [ %for_each_version% ]; then
1826
for VERSION in 8 9 10 11 12; do
19-
maturin build --release --interpreter "python3.$VERSION" --compatibility manylinux2014
27+
maturin build --release --interpreter "python3.$VERSION" --compatibility manylinux_2_28
2028
done
2129
for VERSION in 9 10; do
22-
maturin build --release --interpreter "pypy3.$VERSION" --compatibility manylinux2014
30+
maturin build --release --interpreter "pypy3.$VERSION" --compatibility manylinux_2_28
2331
done
2432
fi

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Project components:
1010
- CLI: `ontoenv` (installable via `cargo install ontoenv-cli`)
1111
- Rust library: [`ontoenv`](https://docs.rs/ontoenv/latest/ontoenv/)
12-
- Python bindings: [`pyontoenv`](https://pypi.org/project/pyontoenv/)
12+
- Python bindings: [`ontoenv`](https://pypi.org/project/ontoenv/)
1313

1414
## Overview
1515

@@ -47,7 +47,7 @@ Ontologies fetched from a URL often declare a different, usually versioned, onto
4747

4848
- Install from crates.io with `cargo install --locked ontoenv-cli`
4949
- From a local checkout, run `cargo install --path cli --locked` to build the current workspace
50-
- Install via PyPI with `pip install pyontoenv` to get the CLI together with the Python bindings
50+
- Install via PyPI with `pip install ontoenv` to get the CLI together with the Python bindings
5151
- Download a binary from the [Releases](https://github.com/gtfierro/ontoenv-rs/releases) tab
5252

5353
### Usage
@@ -151,11 +151,11 @@ Notes:
151151
- `ontoenv list missing` — missing imports (i.e. not found in environment); add `--json` for JSON array
152152
- `ontoenv why <IRI> [<IRI> ...]` — show who imports the given ontology as paths; add `--json` to emit a single JSON document mapping each IRI to path arrays
153153

154-
## Python API (`pyontoenv`)
154+
## Python API (`ontoenv`)
155155

156156
##### Installation
157157

158-
`pip install pyontoenv` (requires Python 3.9+; prebuilt wheels ship for common platforms. Building from source needs a Rust toolchain.)
158+
`pip install ontoenv` (requires Python 3.9+; prebuilt wheels ship for common platforms. Building from source needs a Rust toolchain.)
159159

160160
### Basic usage
161161

pyontoenv-shim/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# pyontoenv compatibility package
2+
3+
This is a lightweight wrapper that depends on the main `ontoenv` wheel and re-exports its public API so that existing `pip install pyontoenv` workflows continue to function.
4+
5+
It contains no additional functionality beyond importing `ontoenv`.

pyontoenv-shim/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools>=68"]
3+
build-backend = "setuptools.build_meta"

pyontoenv-shim/setup.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from __future__ import annotations
2+
3+
import os
4+
from pathlib import Path
5+
6+
from setuptools import find_packages, setup
7+
8+
ROOT = Path(__file__).parent.resolve()
9+
10+
version = os.environ.get("ONTOENV_VERSION")
11+
if not version:
12+
raise RuntimeError("ONTOENV_VERSION must be set when building pyontoenv shim")
13+
14+
readme = (
15+
(ROOT / "README.md").read_text(encoding="utf-8")
16+
if (ROOT / "README.md").exists()
17+
else "Compatibility wrapper that installs the ontoenv package."
18+
)
19+
20+
setup(
21+
name="pyontoenv",
22+
version=version,
23+
description="Compatibility wrapper that depends on the ontoenv package.",
24+
long_description=readme,
25+
long_description_content_type="text/markdown",
26+
author="Gabe Fierro",
27+
author_email="[email protected]",
28+
url="https://github.com/gtfierro/ontoenv-rs",
29+
license="BSD-3-Clause",
30+
python_requires=">=3.9",
31+
install_requires=[f"ontoenv=={version}"],
32+
packages=find_packages(where="src"),
33+
package_dir={"": "src"},
34+
include_package_data=True,
35+
classifiers=[
36+
"License :: OSI Approved :: BSD License",
37+
"Programming Language :: Python",
38+
"Programming Language :: Python :: 3",
39+
"Programming Language :: Python :: 3 :: Only",
40+
"Programming Language :: Python :: 3.9",
41+
"Programming Language :: Python :: 3.10",
42+
"Programming Language :: Python :: 3.11",
43+
"Programming Language :: Python :: 3.12",
44+
"Programming Language :: Python :: 3.13",
45+
],
46+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Compatibility wrapper that proxies to the real ``ontoenv`` package."""
2+
3+
from importlib import import_module
4+
5+
_ontoenv = import_module("ontoenv")
6+
7+
# Re-export the public surface.
8+
from ontoenv import * # type: ignore # noqa: F401,F403
9+
10+
version = getattr(_ontoenv, "version", None)
11+
__version__ = version if isinstance(version, str) else getattr(_ontoenv, "__version__", "0.0.0")
12+
13+
__all__ = getattr(_ontoenv, "__all__", [])

python/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "pyontoenv"
2+
name = "ontoenv-python"
33
version.workspace = true
44
edition.workspace = true
55
license.workspace = true
@@ -11,7 +11,7 @@ build = "build.rs"
1111

1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313
[lib]
14-
name = "pyontoenv"
14+
name = "ontoenv_python"
1515
crate-type = ["cdylib"]
1616
doc = false
1717

0 commit comments

Comments
 (0)