Skip to content

Commit a9df617

Browse files
feat: add --exclude flag to pcu
1 parent ed3590b commit a9df617

9 files changed

Lines changed: 990 additions & 1102 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install dependencies
3434
# Install the package with uv in system mode
3535
# This installs ruff and other tools defined in dependencies
36-
run: uv pip install --system . --group dev
36+
run: uv pip install --system --group dev
3737

3838
- name: Run ruff check
3939
run: ruff check --config ./afterpython/ruff.toml .

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# AfterPython: Python Package Maintenance Toolkit and Project Website Generator
22

33
[![afterpython](https://afterpython.org/shield.svg)](https://afterpython.org)
4-
![PyPI downloads](https://img.shields.io/pypi/dm/afterpython)
5-
[![PyPI](https://img.shields.io/pypi/v/afterpython.svg)](https://pypi.org/project/afterpython)
6-
![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/afterpython)
4+
[![Downloads](https://static.pepy.tech/badge/afterpython/month)](https://pepy.tech/project/afterpython)
5+
[![PyPI](https://img.shields.io/pypi/v/afterpython.svg?cacheSeconds=300)](https://pypi.org/project/afterpython)
6+
![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/afterpython?cacheSeconds=300)
77
[![Discussions](https://img.shields.io/badge/Discussions-Let's%20Chat-green)](https://github.com/AfterPythonOrg/afterpython/discussions)
88
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/AfterPythonOrg/afterpython)
9+
[![View Code Wiki](https://assets.codewiki.google/readme-badge/static.svg)](https://codewiki.google/github.com/afterpythonorg/afterpython?utm_source=badge&utm_medium=github&utm_campaign=github.com/afterpythonorg/afterpython)
10+
<!-- ![PyPI downloads](https://img.shields.io/pypi/dm/afterpython) -->
911
<!-- [![Pixi Badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json)](https://pixi.sh) -->
1012

1113

afterpython/.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
stages:
2626
- pre-commit
2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.14.8
28+
rev: v0.15.12
2929
hooks:
3030
- id: ruff-check
3131
stages:
@@ -40,7 +40,7 @@ repos:
4040
- --config
4141
- ./afterpython/ruff.toml
4242
- repo: https://github.com/commitizen-tools/commitizen
43-
rev: v4.10.0
43+
rev: v4.13.10
4444
hooks:
4545
- id: commitizen
4646
stages:

pixi.lock

Lines changed: 866 additions & 955 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,27 @@ depends-on = [
1818

1919
[dependencies]
2020
python = ">=3.11.14"
21-
uv = ">=0.9.26"
22-
gh = ">=2.83.1"
21+
uv = ">=0.11.8"
22+
gh = ">=2.92.0"
2323

2424
# `pixi config set pinning-strategy latest-up` removes the upper bound on the versions of the dependencies
2525
[pypi-dependencies]
26-
afterpython = { path = ".", editable = true }
2726
click = ">=8.2.1"
2827
trogon = ">=0.6.0"
2928
httpx = ">=0.28.1"
30-
tomlkit = ">=0.13.3"
31-
ruamel-yaml = ">=0.18.16"
32-
gitpython = ">=3.1.45"
29+
tomlkit = ">=0.14.0"
30+
ruamel-yaml = ">=0.19.1"
31+
gitpython = ">=3.1.49"
3332
# pygithub = ">=2.8.1"
34-
python-dotenv = ">=1.2.1"
35-
pyproject-metadata = ">=0.10.0"
33+
python-dotenv = ">=1.2.2"
34+
pyproject-metadata = ">=0.11.0"
3635
# jupytext = ">=1.18.1"
3736
# jinja2 = ">=3.1.6"
38-
mystmd = ">=1.8.0"
37+
mystmd = ">=1.9.0"
3938
pdoc = ">=16.0.0"
40-
ruff = ">=0.14.14"
41-
pre-commit = ">=4.5.1"
42-
commitizen = ">=4.12.1"
39+
ruff = ">=0.15.12"
40+
pre-commit = ">=4.6.0"
41+
commitizen = ">=4.13.10"
4342
# python-semantic-release = ">=10.5.2"
4443

4544
# [pypi-options.dependency-overrides]
@@ -56,11 +55,12 @@ py314 = ["py314", "test", "optional"]
5655
[feature.optional.pypi-dependencies]
5756

5857
[feature.dev.pypi-dependencies]
59-
notebook = ">=7.5.0"
58+
afterpython = { path = ".", editable = true }
59+
notebook = ">=7.5.6"
6060

6161
[feature.test.pypi-dependencies]
62-
pytest = ">=9.0.2"
63-
pytest-cov = ">=7.0.0"
62+
pytest = ">=9.0.3"
63+
pytest-cov = ">=7.1.0"
6464
pytest-mock = ">=3.15.1"
6565
pytest-xdist = ">=3.8.0"
6666
[feature.test.tasks]

pyproject.toml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ dependencies = [
3535
"click>=8.2.1",
3636
"trogon>=0.6.0",
3737
"httpx>=0.28.1",
38-
"tomlkit>=0.13.3",
39-
"ruamel-yaml>=0.18.16",
40-
"gitpython>=3.1.45",
38+
"tomlkit>=0.14.0",
39+
"ruamel-yaml>=0.19.1",
40+
"gitpython>=3.1.49",
4141
# "pygithub>=2.8.1",
42-
"python-dotenv>=1.2.1",
43-
"pyproject-metadata>=0.10.0",
42+
"python-dotenv>=1.2.2",
43+
"pyproject-metadata>=0.11.0",
4444
# "jupytext>=1.18.1",
4545
# "jinja2>=3.1.6",
46-
"mystmd>=1.8.0",
46+
"mystmd>=1.9.0",
4747
"pdoc>=16.0.0",
48-
"ruff>=0.14.14",
49-
"pre-commit>=4.5.1",
50-
"commitizen>=4.12.1",
48+
"ruff>=0.15.12",
49+
"pre-commit>=4.6.0",
50+
"commitizen>=4.13.10",
5151
# "python-semantic-release>=10.5.2",
5252
]
5353

@@ -69,12 +69,15 @@ pcu = "afterpython.main:run_pcu"
6969
# override-dependencies = ["platformdirs>=4.5.0", "nodeenv>=1.9.1"]
7070

7171
[build-system]
72-
requires = ["uv_build>=0.9.26,<0.10.0"]
72+
requires = ["uv_build>=0.11.8,<0.12.0"]
7373
build-backend = "uv_build"
7474

7575
[tool.uv.build-backend]
7676
module-name = "afterpython"
7777
module-root = "src"
7878

7979
[tool.uv.sources]
80-
afterpython = { workspace = true }
80+
afterpython = { path = ".", editable = true }
81+
82+
[tool.pyright]
83+
typeCheckingMode = "basic"

src/afterpython/cli/commands/update.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ def update():
3131
is_flag=True,
3232
help="Also update pre-commit hooks and pixi dependencies",
3333
)
34-
def dependencies(upgrade: bool, all: bool):
34+
@click.option(
35+
"--exclude",
36+
"exclude",
37+
multiple=True,
38+
metavar="PACKAGE",
39+
help="Package to exclude from upgrade (can be passed multiple times)",
40+
)
41+
def dependencies(upgrade: bool, all: bool, exclude: tuple[str, ...]):
3542
"""Check and update project dependencies to latest versions"""
3643
from afterpython.pcu import get_dependencies, update_dependencies
3744
from afterpython.utils import has_pixi, has_uv
3845

46+
excluded = set(exclude)
3947
dependencies: Dependencies = get_dependencies()
4048
has_at_least_one_update = False
4149
for dep_type in dependencies:
@@ -55,18 +63,31 @@ def dependencies(upgrade: bool, all: bool):
5563
for dep in deps:
5664
msg = f" {dep.requirement.name}: {dep.min_version}"
5765
has_update = dep.min_version != dep.latest_version
66+
is_excluded = dep.requirement.name in excluded
5867
if has_update:
59-
has_at_least_one_update = True
68+
if not is_excluded:
69+
has_at_least_one_update = True
6070
msg += (
6171
f" → {click.style(dep.latest_version, fg='green', bold=True)}"
6272
)
73+
if is_excluded:
74+
msg += f" {click.style('(excluded)', fg='yellow')}"
6375
if category_name:
6476
msg += f" ({category_name})"
6577
click.echo(msg)
6678
if not has_at_least_one_update:
6779
click.echo(f"\n{click.style('No dependencies to update.', bold=True)}")
6880
return
6981
if has_at_least_one_update and upgrade:
82+
if excluded:
83+
for dep_type in dependencies:
84+
for category, deps in dependencies[dep_type].items():
85+
dependencies[dep_type][category] = [
86+
dep._replace(latest_version=dep.min_version)
87+
if dep.requirement.name in excluded
88+
else dep
89+
for dep in deps
90+
]
7091
update_dependencies(dependencies) # write the latest versions to pyproject.toml
7192
if has_uv():
7293
click.echo("Upgrading dependencies with uv...")
@@ -89,13 +110,16 @@ def dependencies(upgrade: bool, all: bool):
89110
click.echo(
90111
"uv not found. Updated pyproject.toml only (packages not installed)."
91112
)
92-
if all:
113+
if upgrade and all:
93114
subprocess.run(["ap", "pre-commit", "autoupdate"])
94115
click.echo("All pre-commit hooks updated successfully.")
95116
if has_pixi():
96117
click.echo("Upgrading dependencies with pixi...")
118+
pixi_exclude_args = ["--exclude", "python"]
119+
for pkg in excluded:
120+
pixi_exclude_args += ["--exclude", pkg]
97121
result = subprocess.run(
98-
["pixi", "upgrade", "--exclude", "python"], check=False
122+
["pixi", "upgrade", *pixi_exclude_args], check=False
99123
)
100124
if result.returncode != 0:
101125
raise Exit(result.returncode)

src/afterpython/templates/ci-workflow-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install dependencies
3434
# Install the package with uv in system mode
3535
# This installs ruff and other tools defined in dependencies
36-
run: uv pip install --system . --group dev
36+
run: uv pip install --system --group dev
3737

3838
- name: Run ruff check
3939
run: ruff check --config ./afterpython/ruff.toml .

0 commit comments

Comments
 (0)