Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ jobs:
with:
python-version: "3.11"

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Sync dependencies (locked)
run: |
uv sync --locked --all-groups

- name: Build & install native extension (maturin develop)
uses: PyO3/maturin-action@v1
with:
command: develop
args: --release
manylinux: "2_28"

- name: Run linters
run: |
make check-linting
Expand All @@ -37,17 +47,31 @@ jobs:
with:
python-version: "3.11"

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Sync dependencies (locked)
run: |
uv sync --locked --all-groups

- name: Build & install native extension (maturin develop)
uses: PyO3/maturin-action@v1
with:
command: develop
args: --release
manylinux: "2_28"

- name: Sanity check (import Rust extension)
run: |
uv run python -c "import typeid; import typeid._base32; print('Rust extension OK')"

- name: Run tests
run: |
make test

- name: Run doc tests
run: |
make test-docs
127 changes: 85 additions & 42 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,83 @@ permissions:
contents: write
id-token: write

env:
PROJECT_NAME: typeid-python

jobs:
test:
uses: ./.github/workflows/test.yml
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 9
submodules: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Sync dependencies (locked)
run: |
uv sync --locked --all-groups

- name: Run tests
run: |
make test

- name: Run linters
run: |
make check-linting

test-native:
name: Build + import native extension (${{ matrix.os }}, py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs:
- test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

# Build & install the package in-place with the extension
- name: Build & install (maturin develop)
uses: PyO3/maturin-action@v1
with:
command: develop
args: --release

- name: Sanity check (import extension)
run: |
python -c "import typeid; import typeid._base32; print('native ext OK')"


build-wheels:
name: Build wheels (${{ matrix.os }})
name: Build wheels (${{ matrix.os }}, py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs: test
needs: test-native
strategy:
fail-fast: false
matrix:
Expand All @@ -36,10 +105,8 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Build wheels (Rust-enabled)
# Build typeid-python wheel (includes rust extension)
- name: Build wheels (maturin)
uses: PyO3/maturin-action@v1
with:
command: build
Expand All @@ -51,7 +118,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-py${{ matrix.python-version }}
path: rust-base32/dist/*.whl
path: dist/*.whl

build-sdist:
runs-on: ubuntu-latest
Expand All @@ -67,49 +134,25 @@ jobs:
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Sync deps (including build tools)
run: |
uv sync --all-extras --dev

- name: Build sdist
run: |
make build-sdist
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz

build-rust-sdist:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: dtolnay/rust-toolchain@stable
- name: Build rust sdist
# Build typeid-python sdist (maturin)
- name: Build sdist (maturin)
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: rust-base32

- uses: actions/upload-artifact@v4
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: rust-sdist
path: rust-base32/dist/*.tar.gz
name: sdist
path: dist/*.tar.gz

publish-package:
runs-on: ubuntu-latest
needs:
- build-sdist
- build-rust-sdist
needs: build-sdist
permissions:
contents: read
id-token: write
Expand Down Expand Up @@ -149,4 +192,4 @@ jobs:
uv sync --locked --all-groups

- name: Deploy to Pages
run: uv run mkdocs gh-deploy --force
run: uv run mkdocs gh-deploy --force
94 changes: 0 additions & 94 deletions .github/workflows/test.yml

This file was deleted.

14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,17 @@ See [`Docs: Performance`](https://akhundmurad.github.io/typeid-python/performanc

## Installation

### Core (pure Python)
### Core

```console
$ pip install typeid-python
```

### With Rust acceleration (recommended)

```console
$ pip install typeid-python[rust]
```

This enables:
Included:

* Rust base32 encode/decode
* `uuid-utils` for fast UUIDv7 generation

If Rust is unavailable, TypeID automatically falls back to the pure-Python implementation.

### Other optional extras

```console
Expand Down Expand Up @@ -111,7 +103,7 @@ assert tid.prefix == "user"

```python
from typeid import TypeID
from uuid6 import uuid7
from uuid_utils import uuid7

u = uuid7()
tid = TypeID.from_uuid(prefix="user", suffix=u)
Expand Down
Loading