Skip to content

Commit

Permalink
Merge pull request #5356 from foarsitter/uv
Browse files Browse the repository at this point in the history
Replace pip with uv for the project files
  • Loading branch information
foarsitter authored Oct 5, 2024
2 parents a0af461 + 9a3e7eb commit 0cac725
Show file tree
Hide file tree
Showing 11 changed files with 1,014 additions and 90 deletions.
30 changes: 13 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
cache: pip
enable-cache: "true"
- name: Install dependencies
run: pip install -r requirements.txt
run: uv sync
- name: Run tests
run: pytest -n auto tests
run: uv run pytest -n auto tests

docker:
strategy:
Expand All @@ -54,12 +54,12 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
cache: pip
enable-cache: "true"
- name: Install dependencies
run: pip install -r requirements.txt
run: uv sync
- name: Docker ${{ matrix.script.name }}
run: sh tests/test_docker.sh ${{ matrix.script.args }}

Expand Down Expand Up @@ -98,16 +98,12 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
requirements.txt
{{cookiecutter.project_slug}}/requirements/base.txt
{{cookiecutter.project_slug}}/requirements/local.txt
enable-cache: "true"
- name: Install dependencies
run: pip install -r requirements.txt
run: uv sync
- uses: actions/setup-node@v4
with:
node-version: "22"
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/django-issue-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
enable-cache: "true"
- name: Create Django Major Issue
run: python scripts/create_django_issue.py
run: uv run --frozen scripts/create_django_issue.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 4 additions & 9 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
enable-cache: "true"
- name: Set git details
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
- name: Update list
run: python scripts/update_changelog.py
run: uv run --frozen scripts/update_changelog.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 4 additions & 9 deletions .github/workflows/update-contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
enable-cache: "true"
- name: Update list
run: python scripts/update_contributors.py
run: uv run --frozen scripts/update_contributors.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
19 changes: 3 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,20 @@ We'll also run the tests on GitHub actions when you send your pull request, but

### Installation

First, make sure that your version of Python is 3.12:

```bash
$ python --version
Python 3.12.2
```

Any version that starts with 3.12 will do. If you need to install it, you can get it from [python.org](https://www.python.org/downloads/).

Then install `tox`, if not already installed:

```bash
$ python -m pip install tox
```
We use uv to manage our environment and manage our Python installation. You can install it following the instructions at https://docs.astral.sh/uv/getting-started/installation/

### Run the template's test suite

To run the tests of the template using the current Python version:

```bash
$ tox -e py
$ uv run tox run -e py
```

This uses `pytest `under the hood, and you can pass options to it after a `--`. So to run a particular test:

```bash
$ tox -e py -- -k test_default_configuration
$ uv run tox run -e py -- -k test_default_configuration
```

For further information, please consult the [pytest usage docs](https://pytest.org/en/latest/how-to/usage.html#specifying-which-tests-to-run).
Expand Down
25 changes: 22 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,33 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development",
]
dependencies = [
"binaryornot==0.4.4",
"cookiecutter==2.6",
"django-upgrade==1.21",
"djlint==1.35.2",
"gitpython==3.1.43",
"jinja2==3.1.4",
"pre-commit==3.8",
"pygithub==2.4",
"pytest==8.3.3",
"pytest-cookies==0.7",
"pytest-instafail==0.5",
"pytest-xdist==3.6.1",
"pyyaml==6.0.2",
"requests==2.32.3",
"ruff==0.6.9",
"sh==2.0.7; sys_platform!='win23'",
"tox==4.21.2",
"tox-uv>=1.11.2",
]
urls = { Repository = "https://github.com/cookiecutter/cookiecutter-django" }

[tool.black]
line-length = 119
target-version = [
'py312',
]

# ==== isort ====

[tool.isort]
Expand All @@ -47,7 +66,7 @@ known_first_party = [
"hooks",
]

# ==== djLint ====
# ==== pytest ====

[tool.pytest.ini_options]
addopts = "-v --tb=short"
Expand All @@ -61,7 +80,7 @@ norecursedirs = [
"*/{{cookiecutter.project_slug}}/*",
]

# ==== black ====
# ==== djLint ====

[tool.djlint]
blank_line_after_tag = "load,extends"
Expand Down
26 changes: 0 additions & 26 deletions requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_bare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir -p .cache/bare
cd .cache/bare

# create the project using the default settings in cookiecutter.json
cookiecutter ../../ --no-input --overwrite-if-exists use_docker=n "$@"
uv run cookiecutter ../../ --no-input --overwrite-if-exists use_docker=n "$@"
cd my_awesome_project

# Install OS deps
Expand Down
2 changes: 1 addition & 1 deletion tests/test_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir -p .cache/docker
cd .cache/docker

# create the project using the default settings in cookiecutter.json
cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y "$@"
uv run cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y "$@"
cd my_awesome_project

# make sure all images build
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ skipsdist = true
envlist = py312,black-template

[testenv]
deps = -rrequirements.txt
passenv = AUTOFIXABLE_STYLES
commands = pytest -n auto {posargs:./tests}

Expand Down
Loading

0 comments on commit 0cac725

Please sign in to comment.