Skip to content

Commit

Permalink
feat: migrate migrate packaging to uv (#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke authored Dec 20, 2024
1 parent 81c8622 commit d9e26bd
Show file tree
Hide file tree
Showing 10 changed files with 938 additions and 1,133 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
cache: poetry
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: poetry install
- uses: astral-sh/setup-uv@v5
- run: uv sync --no-python-downloads
shell: bash
- name: Test with Pytest
run: poetry run pytest --cov-report=xml
- run: uv run pytest --cov-report=xml
shell: bash
- uses: codecov/[email protected]
with:
Expand All @@ -50,8 +46,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/setup-python@v5
with:
cache: pip
python-version: "3.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ on:

jobs:
upgrade:
uses: browniebroke/github-actions/.github/workflows/poetry-upgrade.yml@v1
uses: browniebroke/github-actions/.github/workflows/uv-upgrade.yml@v1
secrets:
gh_pat: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
4 changes: 2 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tasks:
- command: |
pip install poetry
PIP_USER=false poetry install
pip install uv
PIP_USER=false uv sync
- command: |
pip install pre-commit
pre-commit install
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "CHANGELOG.md|.all-contributorsrc"
default_stages: [commit]
default_stages: [pre-commit]

ci:
autofix_commit_msg: "chore(pre-commit.ci): auto fixes"
Expand All @@ -26,10 +26,10 @@ repos:
rev: "v2.5.0"
hooks:
- id: pyproject-fmt
- repo: https://github.com/python-poetry/poetry
rev: 1.8.5
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.11
hooks:
- id: poetry-check
- id: uv-lock
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
Expand Down
13 changes: 6 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ build:
os: ubuntu-22.04
tools:
python: "3.12"
jobs:
post_create_environment:
# Install poetry
- python -m pip install poetry
post_install:
# Install dependencies, reusing RTD virtualenv
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv sync --only-group docs --frozen
- uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html

# Build documentation in the docs directory with Sphinx
sphinx:
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ Ready to contribute? Here's how to set yourself up for local development.
$ git clone [email protected]:your_name_here/django-codemod.git
```

3. Install the project dependencies with [Poetry](https://python-poetry.org):
3. Install the project dependencies with [uv](https://docs.astral.sh/uv/):

```shell
$ poetry install
$ uv sync
```

4. Create a branch for local development:
Expand All @@ -63,7 +63,7 @@ Ready to contribute? Here's how to set yourself up for local development.
5. When you're done making changes, check that your changes pass our tests:

```shell
$ poetry run pytest
$ uv run pytest
```

6. Linting is done through [pre-commit](https://pre-commit.com). Provided you have the tool installed globally, you can run them all as one-off:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</a>
</p>
<p align="center">
<a href="https://python-poetry.org/">
<img src="https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json" alt="Poetry">
<a href="https://github.com/astral-sh/uv">
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
</a>
<a href="https://github.com/astral-sh/ruff">
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
Expand Down
1,060 changes: 0 additions & 1,060 deletions poetry.lock

This file was deleted.

98 changes: 53 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
[build-system]
build-backend = "poetry.core.masonry.api"
requires = [ "poetry-core>=1" ]
build-backend = "setuptools.build_meta"
requires = [ "setuptools" ]

[tool.poetry]
[project]
name = "django-codemod"
version = "2.2.2"
description = "A command line tool to automatically fix Django deprecations."
authors = [ "Bruno Alla <[email protected]>" ]
license = "MIT"
readme = "README.md"
keywords = [ "django", "codemod", "libCST" ]
repository = "https://github.com/browniebroke/django-codemod"
documentation = "https://django-codemod.readthedocs.io"
keywords = [
"codemod",
"django",
"libCST",
]
license = { text = "MIT" }
authors = [
{ name = "Bruno Alla", email = "[email protected]" },
]
requires-python = ">=3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
packages = [
{ include = "django_codemod", from = "src" },
{ include = "tests", format = "sdist" },
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
]

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/browniebroke/django-codemod/issues"
"Changelog" = "https://django-codemod.readthedocs.io/en/stable/changelog.html"
"Twitter" = "https://twitter.com/_BrunoAlla"
"Mastodon" = "https://fosstodon.org/@browniebroke"

[tool.poetry.scripts]
djcodemod = "django_codemod.cli:djcodemod"

[tool.poetry.dependencies]
python = "^3.9"
click = "<9"
libcst = "==1.5.1"
pathspec = ">=0.6,<1"
rich = ">=10"
rich-click = ">=1.0"

[tool.poetry.dev-dependencies]
parameterized = "^0.9.0"
pytest = "^8.0.0"
pytest-cov = "^6.0.0"
pytest-mock = "^3.3"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
myst-parser = { version = ">=0.16", python = ">=3.11" }
sphinx = { version = ">=4.0", python = ">=3.11" }
furo = { version = ">=2023.5.20", python = ">=3.11" }
dependencies = [
"click<9",
"libcst==1.5.1",
"pathspec>=0.6,<1",
"rich>=10",
"rich-click>=1",
]
urls."Bug Tracker" = "https://github.com/browniebroke/django-codemod/issues"
urls.Changelog = "https://django-codemod.readthedocs.io/en/stable/changelog.html"
urls.documentation = "https://django-codemod.readthedocs.io"
urls.Mastodon = "https://fosstodon.org/@browniebroke"
urls.repository = "https://github.com/browniebroke/django-codemod"
urls.Twitter = "https://twitter.com/_BrunoAlla"
scripts.djcodemod = "django_codemod.cli:djcodemod"

[dependency-groups]
dev = [
"parameterized>=0.9,<1",
"pytest>=8,<9",
"pytest-cov>=6,<7",
"pytest-mock>=3.3,<4",
]
docs = [
"furo>=2023.5.20; python_version>='3.11'",
"myst-parser>=0.16; python_version>='3.11'",
"sphinx>=4; python_version>='3.11'",
]

[tool.ruff]
target-version = "py39"
Expand Down Expand Up @@ -120,11 +123,16 @@ warn_no_return = true
show_error_codes = true

[tool.semantic_release]
version_toml = [ "pyproject.toml:tool.poetry.version" ]
version_toml = [ "pyproject.toml:project.version" ]
version_variables = [
"src/django_codemod/__init__.py:__version__",
]
build_command = "pip install poetry && poetry build"
build_command = """
pip install uv
uv lock
git add uv.lock
uv build
"""

[tool.semantic_release.changelog]
exclude_commit_patterns = [
Expand Down
Loading

0 comments on commit d9e26bd

Please sign in to comment.