Skip to content

Commit

Permalink
chore: move to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jan 25, 2025
1 parent 0a79914 commit 5df8289
Show file tree
Hide file tree
Showing 23 changed files with 860 additions and 1,711 deletions.
6 changes: 5 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# shellcheck shell=bash
use flake
watch_file poetry.lock

watch_file uv.lock
watch_file nix/pyproject-overrides.nix
watch_file nix/overlay.nix
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
poetry.lock linguist-generated=true
uv.lock linguist-generated=true
flake.lock linguist-generated=true
80 changes: 20 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,96 +19,56 @@ jobs:
os:
- ubuntu-latest
python-version:
- "39"
- "310"
- "311"
- "312"
include:
- os: macos-latest
python-version: "39"
- os: macos-latest
python-version: "312"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v30 # v30
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable-small

- uses: cachix/cachix-action@v15
with:
name: numbsql
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
extraPullNames: nix-community,poetry2nix
extraPullNames: nix-community

- name: build and test
- name: build
run: nix build --no-link --keep-going '.#numbsql${{ matrix.python-version }}'

- name: test
run: nix build --no-link --keep-going '.#numbsql${{ matrix.python-version }}.passthru.tests.pytest'

- name: show closure size
run: |
set -euo pipefail
nix path-info -Shr '.#numbsql${{ matrix.python-version }}' | sort -h -k2
conda:
uv:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
spec:
- deps:
python-version: "3.9"
numba: "0.53"
llvmlite: "0.36"
- env:
NUMBA_CAPTURED_ERRORS: new_style
deps:
python-version: "3.10"
- env:
NUMBA_CAPTURED_ERRORS: new_style
deps:
python-version: "3.11"
- env:
NUMBA_CAPTURED_ERRORS: new_style
deps:
python-version: "3.12"
defaults:
run:
shell: bash -l {0}
python-version:
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: install_python
with:
python-version: ${{ matrix.spec.deps.python-version }}

- run: pip3 install poetry2conda poetry

- run: poetry add --lock "numba@${{ matrix.spec.deps.numba }}" "llvmlite@${{ matrix.spec.deps.llvmlite }}" --python "${{ steps.install_python.outputs.python-version }}"
if: ${{ matrix.spec.deps.numba != null && matrix.spec.deps.llvmlite != null }}

- run: poetry2conda --dev pyproject.toml - | tee environment.yaml

- uses: conda-incubator/setup-miniconda@v3
with:
mamba-version: "*"
miniforge-variant: Mambaforge
miniforge-version: latest
channel-priority: strict
activate-environment: numbsql
python-version: ${{ matrix.spec.deps.python-version }}
environment-file: environment.yaml

- run: pip install .
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v3

- run: pytest --numprocesses auto
- name: run tests
run: uv run --group tests pytest -vv
env:
NUMBA_CAPTURED_ERRORS: ${{ matrix.spec.env.NUMBA_CAPTURED_ERRORS }}
NUMBA_CAPTURED_ERRORS: new_style

dry-run-release:
runs-on: ubuntu-latest
Expand All @@ -124,7 +84,7 @@ jobs:
- uses: cachix/cachix-action@v15
with:
name: numbsql
extraPullNames: nix-community,poetry2nix
extraPullNames: nix-community

- name: setup git info
run: |
Expand All @@ -139,7 +99,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs:
- conda
- uv
- dry-run-release
- nix
steps:
Expand All @@ -161,10 +121,10 @@ jobs:
- uses: cachix/cachix-action@v15
with:
name: numbsql
extraPullNames: nix-community,poetry2nix
extraPullNames: nix-community

- name: run semantic-release
run: ./ci/release/run.sh
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ integers might be unsafe, then you shouldn't use this library.

## Requirements

* Python `>=3.9`
* Python `>=3.10`
* `numba`
* `llvmlite`

Use `nix-shell` from the repository to avoid dependency hell.
Use `nix develop` from the repository root to avoid dependency hell.

## Installation

* `poetry install`
* `pip install numbsql`

## Examples

Expand Down
6 changes: 3 additions & 3 deletions ci/release/prepare.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env nix-shell
#!nix-shell -p cacert gnugrep unzip poetry nix -i bash
#!nix-shell -p cacert gnugrep unzip uv python3 -i bash
# shellcheck shell=bash

set -euo pipefail

version="${1}"

# set version
poetry version "$version"
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version "$version"

# build artifacts
poetry build
uv build --python "$(which python)"

# ensure that the built wheel has the correct version number
unzip -p "dist/numbsql-${version}-py3-none-any.whl" numbsql/__init__.py | grep -q "__version__ = \"$version\""
4 changes: 2 additions & 2 deletions ci/release/publish.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell --pure --keep POETRY_PYPI_TOKEN_PYPI -p cacert poetry -i bash
#!nix-shell --pure --keep UV_PUBLISH_TOKEN -p cacert uv -i bash
# shellcheck shell=bash

set -euo pipefail

poetry publish
uv publish
2 changes: 1 addition & 1 deletion ci/release/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -p cacert poetry git nodejs nix -i bash
#!nix-shell -p cacert uv git nodejs nix -i bash
# shellcheck shell=bash

set -euo pipefail
Expand Down
8 changes: 4 additions & 4 deletions ci/release/verify.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=channel:nixos-unstable-small --pure --keep POETRY_PYPI_TOKEN_PYPI -p poetry -i bash
#!nix-shell -I nixpkgs=channel:nixos-unstable-small --pure --keep UV_PUBLISH_TOKEN -p uv python3 -i bash
# shellcheck shell=bash

set -euo pipefail

dry_run="${1:-false}"

# verify pyproject.toml
poetry check
# verify pyproject.toml and lock file
uv lock --python "$(which python)" --locked

# verify that we have a token available to push to pypi using set -u
if [ "${dry_run}" = "false" ]; then
: "${POETRY_PYPI_TOKEN_PYPI}"
: "${UV_PUBLISH_TOKEN}"
fi
5 changes: 2 additions & 3 deletions examples/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ def main() -> None:

con.create_aggregate(python_defined, 1, cls.class_type.class_def)

query1 = f"select key, {builtin}(value) as builtin_{builtin} from t " f"group by 1"
query1 = f"select key, {builtin}(value) as builtin_{builtin} from t group by 1"
query2 = (
f"select key, {cfunc_defined}(value) as cfunc_{cfunc_defined} "
f"from t group by 1"
f"select key, {cfunc_defined}(value) as cfunc_{cfunc_defined} from t group by 1"
)
query3 = (
f"select key, {python_defined}(value) as python_{python_defined}"
Expand Down
Loading

0 comments on commit 5df8289

Please sign in to comment.