Skip to content

Commit

Permalink
Replace pdm with uv in the root project dir
Browse files Browse the repository at this point in the history
  • Loading branch information
olzhasar-reef committed Dec 26, 2024
1 parent 6a881c8 commit 19adc6e
Show file tree
Hide file tree
Showing 4 changed files with 622 additions and 560 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.11"
- name: Install dependencies
run: python -m pip install --upgrade nox pdm
run: python -m pip install --upgrade nox
- name: Run linters
run: nox -vs lint
check_crufted_project:
Expand All @@ -34,7 +38,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.11"
- name: Install dependencies
run: python -m pip install --upgrade nox pdm
run: python -m pip install --upgrade nox
- name: Run checks on project created from template
run: nox -vt crufted_project
39 changes: 29 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,9 @@
}
CRUFT_TESTED_CONFIGS = os.getenv("CRUFT_TESTED_CONFIGS", ",".join(CRUFT_TESTED_CONFIG_MATRIX)).split(",")

nox.options.default_venv_backend = "venv"
nox.options.default_venv_backend = "uv"
nox.options.reuse_existing_virtualenvs = True


# In CI, use Python interpreter provided by GitHub Actions
if CI:
nox.options.force_venv_backend = "none"


MD_PATHS = ["*.md"]


Expand Down Expand Up @@ -155,7 +149,16 @@ def run_shellcheck(session, mode="check"):
@nox.session(name="format", python=PYTHON_DEFAULT_VERSION)
def format_(session):
"""Lint the code and apply fixes in-place whenever possible."""
session.run("pip", "install", "-e", ".[format]")
uv_env = getattr(session.virtualenv, "location", os.getenv("VIRTUAL_ENV"))
session.run_install(
"uv",
"sync",
"--locked",
"--extra",
"format",
env={"UV_PROJECT_ENVIRONMENT": uv_env},
)

session.run("ruff", "check", "--fix", ".")
run_shellcheck(session, mode="fmt")
run_readable(session, mode="fmt")
Expand All @@ -165,7 +168,16 @@ def format_(session):
@nox.session(python=PYTHON_DEFAULT_VERSION)
def lint(session):
"""Run linters in readonly mode."""
session.run("pip", "install", "-e", ".[lint]")
uv_env = getattr(session.virtualenv, "location", os.getenv("VIRTUAL_ENV"))
session.run_install(
"uv",
"sync",
"--locked",
"--extra",
"lint",
env={"UV_PROJECT_ENVIRONMENT": uv_env},
)

session.run("ruff", "check", "--diff", "--unsafe-fixes", ".")
session.run("codespell", ".")
run_shellcheck(session, mode="check")
Expand All @@ -175,7 +187,14 @@ def lint(session):

@contextlib.contextmanager
def crufted_project(session, cruft_config):
session.run("pip", "install", "-e", ".")
uv_env = getattr(session.virtualenv, "location", os.getenv("VIRTUAL_ENV"))
session.run_install(
"uv",
"sync",
"--locked",
env={"UV_PROJECT_ENVIRONMENT": uv_env},
)

tmpdir = crufted_project.tmpdir
if not tmpdir:
session.notify("cleanup_crufted_project")
Expand Down
Loading

0 comments on commit 19adc6e

Please sign in to comment.