Skip to content

feat(dev): Migrate project to uv #783

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

Merged
merged 10 commits into from
Mar 26, 2025
Merged
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
29 changes: 14 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ jobs:
python: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install 'poetry~=1.8'
- name: Install uv
run: pipx install 'uv~=0.6.9'
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python }}
cache: 'poetry'
cache-dependency-path: 'poetry.lock'
- name: Install deps
run: poetry install --sync --no-root
run: uv sync --group dev
- name: Run linters
run: |
source $(poetry env info --path)/bin/activate
source .venv/bin/activate
make lint
- name: Run type checking
run: |
source $(poetry env info --path)/bin/activate
source .venv/bin/activate
make typecheck
- name: Test package install
run: |
python setup.py sdist
pip install dist/*

python -m build
pip install dist/*.whl
pip install dist/*.tar.gz
Test:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -87,18 +86,18 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
- name: Set up env
run: |
if [[ $DB == mysql ]]; then
pip install -q mysqlclient
uv pip install -q mysqlclient
fi
if [[ $DB == postgres ]]; then
pip install -q psycopg2-binary
uv pip install -q psycopg2-binary
fi
pip install django_stubs_ext typing-extensions coverage pytest pytest-django pytest-cov parameterized $(./get-django-version.py ${{ matrix.django }})
uv pip install django_stubs_ext typing-extensions coverage pytest pytest-django pytest-cov parameterized $(./get-django-version.py ${{ matrix.django }})
- name: Run tests
run: |
pytest --cov-report term
8 changes: 4 additions & 4 deletions docs/modeltranslation/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ Unittests

To test Modeltranslation, you can use the comprehensive test suite that comes
with the package. First, make sure you have installed the project's requirements
using Poetry. Once the requirements are installed,
using uv. Once the requirements are installed,
you can run the tests using pytest. This will run all of the tests in the test
suite and report any failures or errors.

.. code-block:: console

$ pip install poetry
$ poetry install
$ poetry run pytest
$ pip install uv
$ uv sync --group dev --group lsp --no-install-project
$ uv run pytest

Non trivial changes and new features should always be accompanied by a unittest.
Pull requests which add unittests for uncovered code or rare edge cases are also
Expand Down
1,036 changes: 0 additions & 1,036 deletions poetry.lock

This file was deleted.

105 changes: 70 additions & 35 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,82 @@
[tool.poetry]
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "django-modeltranslation"
version = "0.19.0"
dynamic = ["version"]
description = "Translates Django models using a registration approach."
authors = ["Peter Eschler <[email protected]>"]
maintainers = ["Serhii Tereshchenko <[email protected]>"]
packages = [
{ include = "modeltranslation" },
readme = "README.rst"
authors = [
{ name = "Peter Eschler", email = "[email protected]" },
{ name = "Dirk Eschler", email = "[email protected]" },
]
maintainers = [
{ name = "Sergiy Tereshchenko", email = "[email protected]" },
]
license = "BSD-3-Clause"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peschler @deschler Hey folks, I'm doing migration from poetry to uv here, and also updating build backend configuration.

And we had "New BSD" as license name in old config. But, this is not something exactly from this list https://spdx.org/licenses/

That's probably BSD 3-Clause "New" or "Revised" License, aka BSD-3-Clause. Right?

requires-python = "<4,>=3.9"
dependencies = [
"Django>=4.2",
"typing-extensions>=4.0.1; python_version < \"3.11\"",
]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Framework :: Django",
]
[project.urls]
"Homepage" = "https://github.com/deschler/django-modeltranslation"
"Source" = "https://github.com/deschler/django-modeltranslation"
"Documentation" = "https://django-modeltranslation.readthedocs.org/en/latest"
"Mailing List" = "http://groups.google.com/group/django-modeltranslation"
"Changelog" = "https://github.com/deschler/django-modeltranslation/blob/master/CHANGELOG.md"

[tool.poetry.dependencies]
python = ">=3.9,<4"
django = ">=4.2"
typing-extensions = {version = ">=4.0.1", python = "<3.11"}
[tool.setuptools]
packages = [
"modeltranslation",
"modeltranslation.management",
"modeltranslation.management.commands",
]

[tool.poetry.group.dev.dependencies]
ruff = "*"
pdbpp = "*"
parameterized = "*"
pytest-cov = "*"
pytest = "*"
pytest-sugar = "*"
pytest-django = "*"
django-stubs = "^5.0.2"
mypy = "*"
build = "*"
pillow = "^11.1.0"
[tool.setuptools.package-data]
modeltranslation = [
"static/modeltranslation/css/*.css",
"static/modeltranslation/js/*.js",
"py.typed",
]

[tool.poetry.group.lsp]
optional = true
[tool.setuptools.dynamic]
version = {file = "VERSION"}

[tool.poetry.group.lsp.dependencies]
python-lsp-server = {extras = ["rope"], version = "^1.11.0"}
pylsp-mypy = "^0.6.8"
[dependency-groups]
dev = [
"ruff",
"pdbpp",
"parameterized",
"pytest-cov",
"pytest",
"pytest-sugar",
"pytest-django",
"django-stubs<6.0.0,>=5.0.2",
"mypy",
"build",
"pillow",
]
lsp = ["python-lsp-server[rope]", "pylsp-mypy"]

[tool.ruff]
line-length = 100
target-version = "py39"
[tool.ruff.lint]
ignore = [
"E501", # line length is handled by formatter
"E501", # line length is handled by formatter
]

[tool.ruff.lint.pyflakes]
Expand All @@ -57,23 +95,20 @@ warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
show_error_context = true
exclude = [
'tests/migrations/',
'tests/urls.py',
]
exclude = ['tests/migrations/', 'tests/urls.py']
disable_error_code = ["method-assign"]
plugins = ["mypy_django_plugin.main"]

[[tool.mypy.overrides]]
module = ["modeltranslation.fields"]
module = ["modeltranslation.fields"]
disable_error_code = ["attr-defined", "has-type", "misc"]

[[tool.mypy.overrides]]
module = ["modeltranslation.admin"]
module = ["modeltranslation.admin"]
disable_error_code = ["override", "attr-defined"]

[[tool.mypy.overrides]]
module = ["modeltranslation.translator"]
module = ["modeltranslation.translator"]
disable_error_code = ["override", "attr-defined"]

[[tool.mypy.overrides]]
Expand Down
41 changes: 0 additions & 41 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

Loading