Skip to content

Commit 91bd2ed

Browse files
authored
Use uv project instead of Hatch (#19)
* Use uv project instead of Hatch * Update workflows * Update contributing docs * Don't ignore .python-version --------- Co-authored-by: Jay Qi <[email protected]>
1 parent 5f8a087 commit 91bd2ed

File tree

12 files changed

+1098
-127
lines changed

12 files changed

+1098
-127
lines changed

.github/workflows/release-cli.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,21 @@ jobs:
1919
- uses: actions/checkout@v4
2020

2121
- uses: astral-sh/setup-uv@v5
22-
23-
- name: Install hatch
24-
run: |
25-
uv tool install hatch
26-
27-
- name: Install dependencies
28-
run: |
29-
hatch env create
22+
with:
23+
enable-cache: true
24+
cache-dependency-glob: |
25+
pyproject.toml
3026
3127
- name: Check that versions match
3228
run: |
3329
echo "Release tag: [${{ github.event.inputs.version }}] "
34-
PACKAGE_VERSION=$(hatch run vspect package rpzip)
30+
PACKAGE_VERSION=$(uv run python -m vspect package rpzip)
3531
echo "Package version: [$PACKAGE_VERSION]"
3632
[[ "${{ github.event.inputs.version }}" == "v$PACKAGE_VERSION" ]] || { exit 1; }
3733
3834
- name: Build package
3935
run: |
40-
hatch build
36+
uv build
4137
4238
- name: Publish to Test PyPI
4339
uses: pypa/[email protected]
@@ -59,7 +55,7 @@ jobs:
5955
- id: extract-changelog
6056
uses: sean0x42/[email protected]
6157
with:
62-
file: CHANGELOG.md
58+
file: cli/CHANGELOG.md
6359
pattern: ${{ github.event.inputs.version }}
6460

6561
- name: Write output to file

.github/workflows/release-lib.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,21 @@ jobs:
1616
- uses: actions/checkout@v4
1717

1818
- uses: astral-sh/setup-uv@v5
19-
20-
- name: Install hatch
21-
run: |
22-
uv tool install hatch
23-
24-
- name: Install dependencies
25-
run: |
26-
hatch env create
19+
with:
20+
enable-cache: true
21+
cache-dependency-glob: |
22+
pyproject.toml
2723
2824
- name: Check that versions match
2925
run: |
3026
echo "Input version tag: [${{ github.event.inputs.version }}] "
31-
PACKAGE_VERSION=$(hatch run vspect package repro-zipfile)
27+
PACKAGE_VERSION=$(uv run python -m vspect package repro-zipfile)
3228
echo "Package version: [$PACKAGE_VERSION]"
3329
[[ "${{ github.event.inputs.version }}" == "v$PACKAGE_VERSION" ]] || { exit 1; }
3430
3531
- name: Build package
3632
run: |
37-
hatch build
33+
uv build
3834
3935
- name: Publish to Test PyPI
4036
uses: pypa/[email protected]

.github/workflows/tests.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19+
- uses: extractions/setup-just@v2
20+
1921
- uses: astral-sh/setup-uv@v5
2022
with:
2123
enable-cache: true
2224
cache-dependency-glob: |
2325
pyproject.toml
2426
25-
- name: Install hatch
27+
- name: Lint package
2628
run: |
27-
uv tool install hatch
29+
uv run --group lint just lint
2830
29-
- name: Lint package
31+
- name: Typecheck package
3032
run: |
31-
hatch run lint
32-
hatch run typecheck
33+
uv run --group typecheck --all-extras just typecheck
3334
3435
tests:
3536
name: "Tests (${{ matrix.os }}, Python ${{ matrix.python-version }})"
@@ -43,53 +44,32 @@ jobs:
4344
steps:
4445
- uses: actions/checkout@v4
4546

47+
- uses: extractions/setup-just@v2
48+
4649
- uses: astral-sh/setup-uv@v5
4750
with:
4851
enable-cache: true
52+
cache-suffix: "tests-${{ matrix.python-version }}"
4953
cache-dependency-glob: |
5054
pyproject.toml
5155
52-
- name: Install hatch
53-
run: |
54-
uv tool install hatch
55-
5656
- name: Install zip on Windows
5757
if: matrix.os == 'windows-latest'
5858
run: |
5959
choco install zip
6060
6161
- name: Run tests
6262
run: |
63-
hatch run tests.py${{ matrix.python-version }}:test
63+
just python=${{ matrix.python-version }} test -vv
6464
6565
- name: Upload coverage to codecov
66-
uses: codecov/codecov-action@v3
66+
uses: codecov/codecov-action@v5
6767
with:
6868
token: ${{ secrets.CODECOV_TOKEN }}
69-
file: ./coverage.xml
69+
files: ./coverage.xml
7070
fail_ci_if_error: ${{ (github.event_name == 'push' && true) || (github.event_name == 'pull_request' && true) || false }}
7171
if: ${{ matrix.os == 'ubuntu-latest' }}
7272

73-
- name: Build distribution and test installation
74-
shell: bash
75-
run: |
76-
hatch build
77-
if [[ ${{ matrix.os }} == "windows-latest" ]]; then
78-
PYTHON_BIN=Scripts/python
79-
else
80-
PYTHON_BIN=bin/python
81-
fi
82-
echo "=== Testing wheel installation ==="
83-
python -m venv .venv-whl
84-
.venv-whl/$PYTHON_BIN -m pip install --upgrade pip
85-
.venv-whl/$PYTHON_BIN -m pip install dist/repro_zipfile-*.whl
86-
.venv-whl/$PYTHON_BIN -c "from repro_zipfile import ReproducibleZipFile"
87-
echo "=== Testing source installation ==="
88-
python -m venv .venv-sdist
89-
.venv-sdist/$PYTHON_BIN -m pip install --upgrade pip
90-
.venv-sdist/$PYTHON_BIN -m pip install dist/repro_zipfile-*.tar.gz --force-reinstall
91-
.venv-sdist/$PYTHON_BIN -c "from repro_zipfile import ReproducibleZipFile"
92-
9373
notify:
9474
name: Notify failed build
9575
needs: [code-quality, tests]

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ipython_config.py
8787
# pyenv
8888
# For a library or package, you might want to ignore these files since the code is
8989
# intended to run in multiple environments; otherwise, check them in:
90-
.python-version
90+
# .python-version
9191

9292
# pipenv
9393
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

CONTRIBUTING.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
# Contributing to repro-zipfile
22

3-
[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json)](https://github.com/charliermarsh/ruff) [![code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - mypy](https://img.shields.io/badge/types-mypy-blue.svg)](https://github.com/python/mypy)
3+
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
4+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
5+
[![types - mypy](https://img.shields.io/badge/types-mypy-blue.svg)](https://github.com/python/mypy)
46

57
## Report a bug or request a feature
68

79
Please file an issue in the [issue tracker](https://github.com/drivendataorg/repro-zipfile/issues).
810

911
## Developers guide
1012

11-
This project uses [Hatch](https://github.com/pypa/hatch) as its project management tool.
13+
This project uses [uv](https://github.com/astral-sh/uv) as its project management tool and [Just](https://github.com/casey/just) as a task runner.
1214

1315
### Directory structure
1416

1517
This is a monorepo containing both the repro-zipfile library package and the rpzip CLI package. The root of the repository contains files relevant to the library package, and the CLI package is in the subdirectory `cli/`.
1618

1719
Tests for both packages are combined in `tests/`.
1820

19-
### Tests
21+
### Configuring the development environment
2022

21-
To run tests in your current environment, you should install from source with the `tests` extra to additionally install test dependencies (pytest). Then, use pytest to run the tests.
23+
Run:
2224

2325
```bash
24-
# Install with test dependencies
25-
pip install .[tests]
26-
# Run tests
27-
pytest tests.py
26+
just sync
2827
```
2928

30-
To run tests on the full test matrix, you should use Hatch:
29+
This will create a virtual environment located at `.venv/`.
30+
31+
### Tests
32+
33+
To run tests for a single version of Python, use:
3134

3235
```bash
33-
hatch run tests:test
36+
just test
3437
```
3538

36-
To run on a specific test environment, you reference that environment's name:
39+
To specify a version of Python, use for example:
3740

3841
```bash
39-
hatch run tests.py3.11:test
42+
just python=3.11 test
4043
```
4144

42-
To see all test environment names, run:
45+
To run tests on the full test matrix, use:
4346

4447
```bash
45-
hatch env show tests
48+
just test-all
4649
```
4750

4851
### Code Quality: Linting and Static Typechecking
@@ -52,29 +55,26 @@ All code quality dependencies are installed in the default environment.
5255
To run linting:
5356

5457
```bash
55-
hatch run lint
58+
just lint
5659
```
5760

5861
To run static typechecking:
5962

6063
```bash
61-
hatch run typecheck
64+
just typecheck
6265
```
6366

64-
### Configuring IDEs with the Virtual Environment
65-
66-
The default hatch environment is configured to be located in `./venv/`. To configure your IDE to use it, point it at that environment's Python interpreter located at `./venv/bin/python`.
67-
6867
### Releases and publishing to PyPI
6968

7069
The release process of building and publishing the packages is done using GitHub Actions CI. There are two workflows:
7170

72-
- `release-lib` — for the repro-zipfile library package
73-
- `release-cli` — for the rpzip CLI package
71+
- **Release Library** — for the repro-zipfile library package
72+
- **Release CLI** — for the rpzip CLI package
7473

7574
Each package should be released independently.
7675

77-
To trigger a release, publish a release through the GitHub web UI. Use a different tag naming scheme to determine which release workflow you trigger:
76+
For both packages:
7877

79-
- `v*` (e.g., `v0.1.0`) to publish repro-zipfile
80-
- `cli-v*` (e.g., `cli-v0.1.0`) to publish rpzip
78+
1. Update the changelog
79+
2. Ensure the static version declared in associated `pyproject.toml` is the version number of the new release
80+
3. Run the appropriate release workflow using workflow dispatch, entering the intended versino number as an input parameter

cli/pyproject.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "rpzip"
7-
dynamic = ["version"]
7+
version = "0.1.2.dev"
88
description = "A lightweight command-line program for creating reproducible/deterministic ZIP archives."
99
readme = "README.md"
1010
requires-python = ">=3.8"
@@ -22,6 +22,7 @@ classifiers = [
2222
"Programming Language :: Python :: 3.10",
2323
"Programming Language :: Python :: 3.11",
2424
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
2526
"Topic :: System :: Archiving",
2627
"Topic :: System :: Archiving :: Compression",
2728
"Topic :: System :: Archiving :: Packaging",
@@ -36,10 +37,7 @@ Documentation = "https://github.com/drivendataorg/repro-zipfile#readme"
3637
Issues = "https://github.com/drivendataorg/repro-zipfile/issues"
3738
Source = "https://github.com/drivendataorg/repro-zipfile/tree/main/cli"
3839

39-
[tool.hatch.version]
40-
path = "rpzip.py"
41-
42-
## TOOLS ##
43-
44-
[tool.black]
45-
line-length = 99
40+
[dependency-groups]
41+
dev = [
42+
"vspect",
43+
]

cli/rpzip.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from importlib.metadata import version
12
import logging
23
from pathlib import Path
34
import sys
@@ -11,9 +12,8 @@
1112
import typer
1213

1314
from repro_zipfile import ReproducibleZipFile
14-
from repro_zipfile import __version__ as repro_zipfile_version
1515

16-
__version__ = "0.1.1"
16+
__version__ = version("rpzip")
1717

1818
app = typer.Typer()
1919

@@ -24,7 +24,7 @@
2424

2525
def version_callback(value: bool):
2626
if value:
27-
print(f"repro-zipfile v{repro_zipfile_version}")
27+
print(f"repro-zipfile v{version('repro-zipfile')}")
2828
print(f"rpzip v{__version__}")
2929
raise typer.Exit()
3030

justfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
python := shell("cat .python-version")
2+
3+
# Print this help documentation
4+
help:
5+
just --list
6+
7+
# Sync dev environment dependencies
8+
sync:
9+
uv sync --all-extras
10+
11+
# Run linting
12+
lint:
13+
ruff format --check
14+
ruff check
15+
16+
# Run formatting
17+
format:
18+
ruff format
19+
ruff check --fix
20+
21+
# Run static typechecking
22+
typecheck:
23+
# Standard type checking excluding stub file
24+
mypy . --install-types --non-interactive --exclude '\\.pyi$'
25+
# Strict type checking on repro_zipfile with stub file
26+
mypy repro_zipfile --install-types --non-interactive --strict
27+
# Check stub
28+
python -m mypy.stubtest repro_zipfile
29+
# Run tests
30+
test *args:
31+
uv run --python {{python}} --no-editable --all-extras --no-dev --group test --isolated \
32+
python -I -m pytest {{args}}
33+
34+
# Run all tests with Python version matrix
35+
test-all:
36+
for python in 3.8 3.9 3.10 3.11.3 3.11 3.12 3.13; do \
37+
just python=$python test; \
38+
done

0 commit comments

Comments
 (0)