Skip to content

Commit

Permalink
chore: move dev to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Nov 13, 2024
1 parent 4d56cec commit f20acca
Show file tree
Hide file tree
Showing 20 changed files with 1,123 additions and 1,671 deletions.
5 changes: 4 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
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.

92 changes: 38 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,96 +19,80 @@ 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}
- macos-latest
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 }}
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v3

- run: pip3 install poetry2conda poetry
- name: show sqlite version
run: uv run python -c 'import sqlite3; print(sqlite3.sqlite_version)'

- 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 }}
- name: show C API libversion pre installation
run: uv run python -c 'from numba.sqlite import sqlite3_libversion; print(sqlite3_libversion().decode())'

- run: poetry2conda --dev pyproject.toml - | tee environment.yaml
- name: show library pre installation
run: uv run python -c 'import ctypes.util as u; print(u.find_library("sqlite3"))'

- 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
- name: install sqlite on windows
if: matrix.os == 'windows-latest'
run: choco install sqlite

- name: show os sqlite version
run: sqlite3 -version

- name: show C API libversion post installation
run: uv run python -c 'from numba.sqlite import sqlite3_libversion; print(sqlite3_libversion().decode())'

- run: pip install .
- name: show library post installation
run: uv run python -c 'import ctypes.util as u; print(u.find_library("sqlite3"))'

- run: pytest --numprocesses auto
- name: run tests
run: uv run --group tests pytest -vv -x --randomly-dont-reorganize
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 +108,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 +123,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs:
- conda
- uv
- dry-run-release
- nix
steps:
Expand All @@ -161,10 +145,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.7`
* Python `>=3.9`
* `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 nix -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

# 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 -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 --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
78 changes: 20 additions & 58 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f20acca

Please sign in to comment.