Skip to content

Commit 9c7a4a9

Browse files
feat: replace poetry to uv
1 parent f80fb26 commit 9c7a4a9

File tree

9 files changed

+784
-1005
lines changed

9 files changed

+784
-1005
lines changed

.github/workflows/lint.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ jobs:
2424
with:
2525
python-version: "3.12"
2626

27-
- uses: abatilo/actions-poetry@v2
28-
with:
29-
poetry-version: "latest"
30-
31-
- name: install depends
27+
- name: Install uv
3228
run: |
33-
pip install nox
34-
poetry install
29+
curl -LsSf https://astral.sh/uv/install.sh | sh
30+
uv --version
31+
32+
- name: Install dependencies
33+
run: uv sync --extras dev
3534

3635
- name: Run lint checks
37-
run: poetry run nox -s lint
36+
run: uvx nox -s lint
3837

3938
- name: Run tests
40-
run: poetry run nox -s test
39+
run: uvx nox -s test

.github/workflows/release_build.yaml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,27 @@ jobs:
2424
with:
2525
python-version: "3.12"
2626

27-
- uses: abatilo/actions-poetry@v2
28-
with:
29-
poetry-version: "latest"
27+
- name: Install uv
28+
run: |
29+
curl -LsSf https://astral.sh/uv/install.sh | sh
30+
uv --version
3031
31-
- name: Install nox
32-
run: pip install nox
32+
- name: Install dependencies
33+
run: uv sync --extras dev
3334

34-
- name: build and publish
35+
- name: Build and test
36+
run: |
37+
uvx nox -s lint
38+
uvx nox -s test
39+
uvx nox -s build
40+
41+
- name: Publish to PyPI
42+
env:
43+
TWINE_USERNAME: __token__
44+
TWINE_PASSWORD: ${{ env.PYPI_TOKEN }}
3545
run: |
36-
poetry config pypi-token.pypi ${{ env.PYPI_TOKEN }}
37-
poetry install
38-
poetry run nox -s lint
39-
poetry run nox -s test
40-
poetry run nox -s build
41-
poetry publish
46+
pip install twine
47+
twine upload dist/*
4248
4349
- name: Release
4450
uses: softprops/action-gh-release@v2

.python-version

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

__pycache__/noxfile.cpython-312.pyc

4.58 KB
Binary file not shown.

hello.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main():
2+
print("Hello from repo-scaffold!")
3+
4+
5+
if __name__ == "__main__":
6+
main()

noxfile.py

Lines changed: 72 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,31 @@
44
- Code linting and formatting
55
- Unit testing with coverage reporting
66
- Package building
7-
- Executable creation
7+
- Project cleaning
88
99
Typical usage example:
10-
nox -s lint # Run linting
11-
nox -s test # Run tests
12-
nox -s build # Build package
13-
nox -s build_exe # Build package with standalone executable
10+
nox -s lint # Run linting
11+
nox -s test # Run tests
12+
nox -s build # Build package
13+
nox -s clean # Clean project
1414
"""
1515
import nox
16+
import shutil
17+
from pathlib import Path
18+
19+
20+
def install_with_uv(session: nox.Session, editable: bool = False) -> None:
21+
"""Helper function to install packages using uv.
22+
23+
Args:
24+
session: Nox session object for running commands
25+
editable: Whether to install in editable mode
26+
"""
27+
session.install("uv")
28+
if editable:
29+
session.run("uv", "pip", "install", "-e", ".[dev]")
30+
else:
31+
session.run("uv", "pip", "install", ".")
1632

1733

1834
@nox.session(reuse_venv=True)
@@ -25,9 +41,11 @@ def lint(session: nox.Session) -> None:
2541
Args:
2642
session: Nox session object for running commands
2743
"""
28-
session.install("poetry")
44+
# Install dependencies
2945
session.install("ruff")
30-
session.run("poetry", "install", "--only", "dev")
46+
install_with_uv(session, editable=True)
47+
48+
# Run linting checks
3149
session.run(
3250
"ruff",
3351
"check",
@@ -42,18 +60,22 @@ def lint(session: nox.Session) -> None:
4260
"--diff"
4361
)
4462

63+
4564
@nox.session(reuse_venv=True)
4665
def test(session: nox.Session) -> None:
4766
"""Run the test suite with coverage reporting.
4867
49-
Executes pytest with coverage reporting for the github_action_test package.
68+
Executes pytest with coverage reporting for the repo_scaffold package.
5069
Generates both terminal and XML coverage reports.
5170
5271
Args:
5372
session: Nox session object for running commands
5473
"""
55-
session.install("poetry")
56-
session.run("poetry", "install")
74+
# Install dependencies
75+
install_with_uv(session, editable=True)
76+
session.install("pytest", "pytest-cov", "pytest-mock")
77+
78+
# Run tests
5779
session.run(
5880
"pytest",
5981
"--cov=repo_scaffold",
@@ -68,28 +90,53 @@ def test(session: nox.Session) -> None:
6890
def build(session: nox.Session) -> None:
6991
"""Build the Python package.
7092
71-
Creates a distributable package using poetry build command
72-
with verbose output and excluding dev dependencies.
93+
Creates a distributable package using uv build command.
7394
7495
Args:
7596
session: Nox session object for running commands
7697
"""
77-
session.install("poetry")
78-
session.run("poetry", "install", "--without", "dev")
79-
session.run("poetry", "build", "-vvv")
98+
session.install("uv")
99+
session.run("uv", "build", "--wheel", "--sdist")
80100

81101

82102
@nox.session(reuse_venv=True)
83-
def build_exe(session: nox.Session) -> None:
84-
"""Build the Python package with standalone executable.
85-
86-
Creates an executable using poetry-pyinstaller-plugin.
87-
Installs required plugin and builds without dev dependencies.
103+
def clean(session: nox.Session) -> None: # pylint: disable=unused-argument
104+
"""Clean the project directory.
105+
106+
Removes build artifacts, cache directories, and other temporary files:
107+
- build/: Build artifacts
108+
- dist/: Distribution packages
109+
- .nox/: Nox virtual environments
110+
- .pytest_cache/: Pytest cache
111+
- .ruff_cache/: Ruff cache
112+
- .coverage: Coverage data
113+
- coverage.xml: Coverage report
114+
- **/*.pyc: Python bytecode
115+
- **/__pycache__/: Python cache directories
116+
- **/*.egg-info: Package metadata
88117
89118
Args:
90-
session: Nox session object for running commands
119+
session: Nox session object (unused)
91120
"""
92-
session.install("poetry")
93-
session.install("poetry", "self", "add", "poetry-pyinstaller-plugin")
94-
session.run("poetry", "install", "--without", "dev")
95-
session.run("poetry", "build", "-vvv")
121+
root = Path(".")
122+
patterns = [
123+
"build",
124+
"dist",
125+
".nox",
126+
".pytest_cache",
127+
".ruff_cache",
128+
".coverage",
129+
"coverage.xml",
130+
"**/*.pyc",
131+
"**/__pycache__",
132+
"**/*.egg-info",
133+
]
134+
135+
for pattern in patterns:
136+
for path in root.glob(pattern):
137+
if path.is_file():
138+
path.unlink()
139+
print(f"Removed file: {path}")
140+
elif path.is_dir():
141+
shutil.rmtree(path)
142+
print(f"Removed directory: {path}")

0 commit comments

Comments
 (0)