Skip to content

Update Python to use UV for project managment #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ jobs:
python-version: 3.9
- name: Install svdtools
run: |
python -m pip install --upgrade pip
pip install -r dev-requirements.txt
pip install .
uv venv
- name: Check
run: |
black --check --diff svdtools
isort --check-only svdtools
uv run black --check --diff svdtools
uv run isort --check-only svdtools
- name: Test
run: pytest svdtools
run: uv run pytest
check:
name: Check
runs-on: ubuntu-latest
Expand All @@ -55,12 +53,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v4
uses: astral-sh/setup-uv@5
with:
python-version: 3.9
- name: Install svdtools
run: |
python -m pip install --upgrade pip
pip install .
uv tool install .
- name: Check
run: bash tools/check_${{ matrix.target }}.sh
32 changes: 17 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.PHONY: example

# setup development environment
setup: update-venv
setup: venv

install-svd2rust-form-rustfmt:
rustup component add rustfmt
cargo install svd2rust form

# example usage
example:
venv/bin/svd patch example/incomplete-stm32l4x2.yaml
uv run svd patch example/incomplete-stm32l4x2.yaml

# ensure this passes before commiting
check: check-black check-isort
Expand All @@ -18,22 +18,22 @@ check: check-black check-isort
fix: apply-black apply-isort

check-black:
venv/bin/black --check svdtools/
uv run black --check --diff svdtools/

apply-black:
venv/bin/black svdtools/
uv run black svdtools/

apply-isort:
venv/bin/isort svdtools/
uv run isort svdtools/

check-isort:
venv/bin/isort --check-only svdtools/
uv run isort --check-only svdtools/

semi-clean:
rm -rf **/__pycache__
uv cache clean

clean: semi-clean
rm -rf venv
rm -rf .venv
rm -rf dist


Expand All @@ -45,17 +45,19 @@ tag:
git tag -a $(VERSION) -m"v$(VERSION)"

build: check
flit build
uv build

publish: check
flit --repository pypi publish
uv publish

# UV automatically uses a venv located at ./.venv for all commands.
# This venv can be activated to put the tools and project
# in PATH
venv:
python3 -m venv venv
uv venv

# re-run if dev or runtime dependencies change,
# or when adding new scripts
update-venv: venv
venv/bin/pip install -U pip
venv/bin/pip install -U -r dev-requirements.txt
venv/bin/flit install --symlink
update-venv:
uv lock
uv sync
4 changes: 0 additions & 4 deletions dev-requirements.txt

This file was deleted.

50 changes: 32 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
[build-system]
requires = ["black", "flit_core >=2,<4", "isort"]
build-backend = "flit_core.buildapi"

[tool.flit.metadata]
module = "svdtools"
# dist-name = "svdtools"
author = "Adam Greig"
author-email = "[email protected]"
maintainer = "Nicolas Stalder"
maintainer-email = "[email protected]"
home-page = "https://github.com/rust-embedded/svdtools"
[project]
name = "svdtools"
license = "MIT OR Apache-2.0"
description = "svdtools is a set of tools for modifying vendor-supplied, often buggy SVD files."
readme = "README.md"
requires-python = ">=3.9"
description-file = "README.md"
requires = [
dependencies = [
"click ~= 8.0",
"PyYAML >= 5.3, < 7",
"lxml ~= 4.6",
"braceexpand ~= 0.1.7",
]
classifiers=[
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
authors = [
{ name = "Adam Grieg", email = "[email protected]" },
]
maintainers = [
{ name = "Nicolas Stalder", email = "[email protected]" }
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/rust-embedded/svdtools"
Repository = "https://github.com/rust-embedded/svdtools"
Issues = "https://github.com/rust-embedded/svdtools/issues"
Changelog = "https://github.com/rust-embedded/svdtools/blob/master/CHANGELOG-python.md"

[tool.flit.scripts]
[project.scripts]
svd = "svdtools.cli:svdtools_cli"

[dependency-groups]
dev = [ "black >= 23.1", "isort >= 5.0", "pytest >= 7.0"]

[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[tool.pytest.ini_options]
minversion = "7.0"
testpaths = [ "svdtools" ]
Loading