Skip to content

Commit

Permalink
use uv to manage project (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn authored Sep 15, 2024
1 parent 0ab8193 commit 29b9294
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 40 deletions.
45 changes: 18 additions & 27 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,37 @@ env:
jobs:
Testing:
runs-on: ${{ matrix.os }}
env:
UV_CACHE_DIR: "/tmp/.uv-cache"
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-rc.2"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Create virtual environment
run: |
python -m venv venv
- name: "Test Rust"
if: matrix.os == 'ubuntu-latest'
run: |
cargo test
- name: Install tzfpy and test(Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
source venv/Scripts/activate
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
maturin develop --release --extras=pytz
pytest | tee benchmark_result.txt
- name: Install tzfpy and test(Ubuntu&macoS)
if: matrix.os != 'windows-latest'
- name: Install tzfpy and test
shell: bash
run: |
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements_dev.txt
maturin develop --release --extras=pytz
pytest | tee benchmark_result.txt
uv run ruff check .
uv run pytest | tee benchmark_result.txt
- name: Setup benchmark file name
id: gen-benchmark-file-name
Expand All @@ -81,6 +69,9 @@ jobs:
name: "benchmark_result_as_md_${{ matrix.python-version }}_${{ matrix.os }}"
path: ${{ steps.gen-benchmark-file-name.outputs.filename }}

- name: Minimize uv cache
run: uv cache prune --ci

Report:
needs: [Testing]
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "tzfpy"
version = "0.15.6"
version = "0.16.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -19,7 +19,7 @@ crate-type = ["cdylib"]

[dependencies]
lazy_static = "1.5.0"
pyo3 = {version = "0.22.2", features = ["extension-module", "abi3-py38"]}
pyo3 = {version = "0.22.2", features = ["extension-module", "abi3-py39"]}

# tzf-rs = { git = "https://github.com/ringsaturn/tzf-rs", rev = "31b1730", default-features = false}
tzf-rs = { version = "0.4.9", default-features = false }
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ Issues = "https://github.com/ringsaturn/tzfpy/issues"
[tool.maturin]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
features = ["pyo3/extension-module"]

[tool.uv]
dev-dependencies = [
"ruff>=0.6.5",
"citiespy>=0.6.3",
"maturin>=1.7.1",
"pytest>=8.3.3",
"pytest-benchmark>=4.0.0",
"pytest-cov>=5.0.0",
"pytest-pretty>=1.2.0",
"pytz>=2024.2",
"tzdata>=2024.1",
]
8 changes: 0 additions & 8 deletions requirements_dev.txt

This file was deleted.

4 changes: 2 additions & 2 deletions tzfpy.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Probably the fastest Python package to convert longitude/latitude to timezone name(s).
"""
"""Probably the fastest Python package to convert longitude/latitude to timezone name(s)."""

from typing import List

def get_tz(lng: float, lat: float) -> str:
Expand Down
Loading

0 comments on commit 29b9294

Please sign in to comment.