Skip to content

Commit 1ee3b56

Browse files
authored
Merge pull request #18 from roskakori/16-change-to-uv-and-ruff
#16 Change to uv and ruff
2 parents 5668c77 + a91d88a commit 1ee3b56

File tree

15 files changed

+623
-1315
lines changed

15 files changed

+623
-1315
lines changed

.github/workflows/build.yaml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,51 @@ jobs:
99
strategy:
1010
matrix:
1111
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
12-
env:
13-
MAIN_PYTHON_VERSION: "3.12" # Same as Ubuntu 24 LTS
1412

1513
steps:
16-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1715
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v5
16+
uses: actions/setup-python@v4
1917
with:
2018
python-version: ${{ matrix.python-version }}
21-
- name: Install Poetry
22-
uses: snok/install-poetry@v1
23-
with:
24-
virtualenvs-create: true
25-
virtualenvs-in-project: true
26-
- name: Load cached venv
27-
id: cached-poetry-dependencies
28-
uses: actions/cache@v3
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
2921
with:
30-
path: .venv
31-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
22+
enable-cache: true
23+
cache-dependency-glob: "uv.lock"
24+
# NOTE Using the "latest" version of uv is risky, but for the time being uv is updated
25+
# regularly, so a specific version would be outdated rather quickly. Once uv goes
26+
# version 1.0, this should be changed to something like ">=1 <2".
27+
version: "latest"
3228
- name: Install dependencies
33-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
29+
if: steps.cached-uv-dependencies.outputs.cache-hit != 'true'
3430
run: |
35-
poetry install --no-interaction
31+
uv sync
3632
- name: Build sanpo package
3733
run: |
38-
poetry build
34+
uv build
3935
- name: Run the test suite
4036
run: |
41-
poetry run pytest --cov=sanpo --cov-branch
42-
37+
uv run pytest --cov=sanpo --cov-branch
4338
4439
check-style:
4540
runs-on: ubuntu-latest
4641
# Disable pre-commit check on main and production to prevent
47-
# pull request merges to fail with "don't commit to branch".
42+
# pull request merges to fail with don't commit to branch".
4843
if: github.ref != 'refs/heads/main'
4944
steps:
5045
- uses: actions/checkout@v4
51-
- name: Install pre-commit
52-
run: |
53-
sudo apt-get install python3
54-
python -m pip install --upgrade pip
55-
pip install pre-commit
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v5
48+
with:
49+
enable-cache: true
50+
cache-dependency-glob: ".pre-commit-config.yaml"
51+
# NOTE Using the "latest" version of uv is risky, but for the time being uv is updated
52+
# regularly, so a specific version would be outdated rather quickly. Once uv goes
53+
# version 1.0, this should be changed to something like ">=1 <2".
54+
version: "latest"
55+
- name: Set up Python
56+
run: uv python install
5657
- name: Load cached pre-commit
5758
id: cached-pre-commit
5859
uses: actions/cache@v4
@@ -61,6 +62,6 @@ jobs:
6162
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
6263
- name: Install pre-commit hooks
6364
if: steps.cached-pre-commit.outputs.cache-hit != 'true'
64-
run: pre-commit install --install-hooks
65+
run: uv run pre-commit install --install-hooks
6566
- name: Check coding style
66-
run: pre-commit run --all-files
67+
run: uv run pre-commit run --all-files

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ cython_debug/
251251
# End of https://www.toptal.com/developers/gitignore/api/python,pycharm
252252

253253
.DS_Store
254+
/.idea/misc.xml
254255
/.idea/ruff.xml
255256
/tests/temp
256257
!/tests/temp/.keep

.idea/misc.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.idea/sanpo.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.pre-commit-config.yaml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
1-
# See https://pre-commit.com for more information
2-
# See https://pre-commit.com/hooks.html for more hooks
31
exclude: "^.idea"
42

53
repos:
6-
- repo: https://github.com/pre-commit/mirrors-isort
7-
rev: v5.10.1
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.11.0
86
hooks:
9-
- id: isort
7+
- id: ruff
8+
args: ["--fix"]
9+
- id: ruff-format
1010

11-
- repo: https://github.com/psf/black
12-
rev: 24.10.0
11+
- repo: https://github.com/pre-commit/mirrors-prettier
12+
rev: v3.1.0
1313
hooks:
14-
- id: black
14+
- id: prettier
1515

1616
- repo: https://github.com/pre-commit/pre-commit-hooks
1717
rev: v5.0.0
1818
hooks:
19+
- id: fix-byte-order-marker
1920
- id: trailing-whitespace
2021
- id: end-of-file-fixer
2122
- id: mixed-line-ending
22-
- id: check-yaml
23-
- id: check-xml
2423
- id: check-added-large-files
2524
- id: check-ast
26-
- id: debug-statements
27-
- id: fix-byte-order-marker
25+
- id: check-json
2826
- id: check-merge-conflict
29-
30-
- repo: https://github.com/asottile/pyupgrade
31-
rev: v3.19.0
32-
hooks:
33-
- id: pyupgrade
34-
args: ["--py39-plus"]
35-
36-
- repo: https://github.com/PyCQA/flake8
37-
rev: 7.1.1
38-
hooks:
39-
- id: flake8
40-
additional_dependencies: ["pep8-naming==0.13.3"]
27+
- id: check-xml
28+
- id: check-yaml
29+
- id: debug-statements
30+
- id: no-commit-to-branch
31+
args: ["--branch", "main"]

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changes
22

3+
Version 0.2.3, 2025-ß3-25
4+
5+
- Change build and packaging to uv (#16)
6+
- Change linting to ruff (#16)
7+
38
Version 0.2.2, 2024-12-10
49

510
- Remove support for Python 3.8 and update dependencies (#14)

CONTRIBUTING.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,41 @@
55
To set up a developer environment perform the following steps:
66

77
1. Check out the source code and change into its folder.
8-
2. Set up the [poetry](https://python-poetry.org/) environment:
8+
2. Install [uv](https://docs.astral.sh/uv/).
9+
3. Set up the virtual environment and pre-commit hooks:
910
```bash
10-
poetry install
11-
```
12-
3. Set up the [pre-commit](https://pre-commit.com/) checks:
13-
```bash
14-
poetry run pre-commit install --install-hooks
11+
sh scripts/set_up_project.sh
1512
```
1613

1714
## Testing
1815

1916
To run the test suite:
2017

2118
```bash
22-
poetry run pytest
19+
uv run pytest
2320
```
2421

2522
## Publishing a release
2623

2724
1. Update the version number in `pyproject.toml`:
2825
```toml
29-
[tool.poetry]
26+
[project]
3027
name = "sanpo"
3128
version = "0.x.x"
3229
```
3330
2. Test and build the distribution archives:
3431
```bash
35-
$ poetry run pytest
36-
$ poetry build
32+
$ uv run pytest
33+
$ uv build
3734
```
38-
3. Tag a release (simply replace 0.9.x with the current version number):
35+
3. Tag a release (simply replace 0.x.x with the current version number):
3936
```bash
4037
$ git tag -a -m "Tag version 0.x.x" v0.x.x
4138
$ git push --tags
4239
```
4340
4. Upload the release to PyPI:
4441
```bash
45-
$ poetry publish
42+
$ uv publish
4643
```
4744
5. Publish the related
4845
[GitHub release](https://github.com/roskakori/sanpo/releases/new).

0 commit comments

Comments
 (0)