Skip to content

Commit 510f693

Browse files
committed
publish ontoenv under both names
1 parent 4aa0d79 commit 510f693

File tree

12 files changed

+135
-39
lines changed

12 files changed

+135
-39
lines changed

.github/workflows/artifacts.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,36 @@ jobs:
137137
- run: maturin sdist -m python/Cargo.toml
138138
- uses: actions/upload-artifact@v4
139139
with:
140-
name: pyontoenv_dist
140+
name: ontoenv_dist
141141
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/*
142170

143171
wheel_linux:
144172
runs-on: ubuntu-latest
@@ -162,7 +190,7 @@ jobs:
162190
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true') || matrix.architecture == 'x86_64'
163191
- uses: actions/upload-artifact@v4
164192
with:
165-
name: pyontoenv_${{ matrix.architecture }}_linux_gnu
193+
name: ontoenv_${{ matrix.architecture }}_linux_gnu
166194
path: target/wheels/*.whl
167195

168196
wheel_linux_musl:
@@ -188,7 +216,7 @@ jobs:
188216
- run: find .
189217
- uses: actions/upload-artifact@v4
190218
with:
191-
name: pyontoenv_${{ matrix.architecture }}_linux_musl
219+
name: ontoenv_${{ matrix.architecture }}_linux_musl
192220
path: target/wheels/*.whl
193221

194222
wheel_mac:
@@ -229,7 +257,7 @@ jobs:
229257
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true')
230258
- uses: actions/upload-artifact@v4
231259
with:
232-
name: pyontoenv_macos
260+
name: ontoenv_macos
233261
path: target/wheels/*.whl
234262

235263
wheel_windows:
@@ -255,27 +283,28 @@ jobs:
255283
- run: maturin build --release -m python/Cargo.toml --features abi3
256284
- uses: actions/upload-artifact@v4
257285
with:
258-
name: pyontoenv_windows
286+
name: ontoenv_windows
259287
path: target/wheels/*.whl
260288

261289
publish_pypi:
262290
if: github.event_name == 'release'
263291
runs-on: ubuntu-latest
264292
environment:
265293
name: publish
266-
url: https://pypi.org/p/pyontoenv
294+
url: https://pypi.org/p/ontoenv
267295
permissions:
268296
id-token: write
269297
needs:
270298
- python_sdist
299+
- python_pyontoenv_alias
271300
- wheel_windows
272301
- wheel_mac
273302
- wheel_linux
274303
- wheel_linux_musl
275304
steps:
276305
- uses: actions/download-artifact@v4
277306
with:
278-
pattern: pyontoenv_*
307+
pattern: ontoenv_*
279308
path: dist
280309
merge-multiple: true
281310
- uses: pypa/gh-action-pypi-publish@release/v1

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

python/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyOntoenv
1+
# OntoEnv Python Bindings
22

33
## Installation
44

5-
`pip install pyontoenv`
5+
`pip install ontoenv`
66

77
## Usage
88

@@ -24,7 +24,7 @@ brick_name = env.add("../brick/Brick.ttl")
2424
print(f"Added ontology {brick_name}")
2525

2626
# When you add from a URL whose declared ontology name differs (for example a
27-
# versioned IRI served at a versionless URL), pyontoenv records that alias. You
27+
# versioned IRI served at a versionless URL), ontoenv records that alias. You
2828
# can later refer to the ontology by either the canonical name or the original
2929
# URL when resolving imports or querying.
3030

@@ -58,10 +58,10 @@ print(f"Graph with imported dependencies has {len(g)} triples")
5858

5959
## CLI Entrypoint
6060

61-
Installing `pyontoenv` also provides the Rust-backed `ontoenv` command-line tool:
61+
Installing `ontoenv` also provides the Rust-backed `ontoenv` command-line tool:
6262

6363
```
64-
pip install pyontoenv
64+
pip install ontoenv
6565
ontoenv --help
6666
```
6767

python/ontoenv/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Python package shim for the ontoenv extension."""
22

3-
# This is the name we set in python/Cargo.toml
4-
from .pyontoenv import OntoEnv, Ontology, run_cli, version # type: ignore[attr-defined]
5-
from . import pyontoenv as _ext # type: ignore[attr-defined]
3+
# These symbols come from the Rust extension module built via maturin.
4+
from ._native import OntoEnv, Ontology, run_cli, version # type: ignore[attr-defined]
5+
from . import _native as _ext # type: ignore[attr-defined]
66

77
__doc__ = getattr(_ext, "__doc__", None) # type: ignore[assignment]
88

0 commit comments

Comments
 (0)