Skip to content

Commit 6f0a367

Browse files
authored
Merge branch 'main' into update-pre-commit
2 parents 91072ba + 43c8e2a commit 6f0a367

1,153 files changed

Lines changed: 37647 additions & 32018 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coveragerc

Lines changed: 0 additions & 24 deletions
This file was deleted.

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ruff linting and formatting (#2882)
2+
2cf268f0c3b35973cfb6d5bbcfec5de09954eae7
3+
4+
# Move apps under apps/ namespace and update all imports (#2883)
5+
31bc7e3698333333397292dc01d88e61e41761ab

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828
uses: actions/cache@v5
2929
with:
3030
path: ~/.cache/pip
31-
key: ${{ runner.os }}-pip-${{ hashFiles('*-requirements.txt') }}
31+
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
3232
restore-keys: ${{ runner.os }}-pip-
3333

3434
- name: Install dependencies
35-
run: pip install -r dev-requirements.txt
35+
run: pip install -e '.[dev]'
3636

3737
- name: Check for ungenerated migrations
3838
run: python manage.py makemigrations --check --dry-run
@@ -78,13 +78,13 @@ jobs:
7878
uses: actions/cache@v5
7979
with:
8080
path: ~/.cache/pip
81-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt', '*-requirements.txt') }}
81+
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
8282
restore-keys: ${{ runner.os }}-pip-
8383

8484
- name: Install dependencies
8585
run: |
8686
pip install -U pip setuptools wheel
87-
pip install -r dev-requirements.txt
87+
pip install -e '.[dev]'
8888
8989
- name: Run tests
9090
run: python -Wd -m coverage run manage.py test -v2

.github/workflows/static.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919
cache-name: pythondotorg-cache-pip
2020
with:
2121
path: ~/.cache/pip
22-
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt', '*-requirements.txt') }}
22+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('pyproject.toml') }}
2323
restore-keys: |
2424
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
2525
${{ runner.os }}-${{ github.job }}-
2626
${{ runner.os }}-
2727
- name: Install Python dependencies
2828
run: |
2929
pip install -U pip setuptools wheel
30-
pip install -r requirements.txt -r prod-requirements.txt
30+
pip install '.[prod]'
3131
- name: Run Tests
3232
run: |
3333
DJANGO_SETTINGS_MODULE=pydotorg.settings.static python manage.py collectstatic --noinput

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.15.0
4+
hooks:
5+
- id: ruff-check
6+
args: [--fix]
7+
- id: ruff-format
8+
29
- repo: https://github.com/adamchainz/django-upgrade
310
rev: 1.29.1
411
hooks:

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ build:
1010
python: "3"
1111

1212
commands:
13-
- python -m pip install -r docs-requirements.txt
13+
- python -m pip install '.[docs]'
1414
- make -C docs html JOBS=$(nproc) BUILDDIR=_readthedocs
1515
- mv docs/_readthedocs _readthedocs

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ RUN case $(uname -m) in \
3232
RUN mkdir /code
3333
WORKDIR /code
3434

35-
COPY dev-requirements.txt /code/
36-
COPY base-requirements.txt /code/
37-
COPY prod-requirements.txt /code/
38-
COPY requirements.txt /code/
39-
4035
RUN pip --no-cache-dir --disable-pip-version-check install --upgrade pip setuptools wheel
4136

37+
COPY pyproject.toml /code/
38+
4239
RUN --mount=type=cache,target=/root/.cache/pip \
4340
set -x \
4441
&& pip --disable-pip-version-check \
4542
install \
46-
-r dev-requirements.txt
43+
'.[dev]'
4744

4845
COPY . /code/
46+
47+
RUN pip --disable-pip-version-check install --no-deps -e '.'

Dockerfile.cabotage

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ RUN case $(uname -m) in \
3333
RUN mkdir /code
3434
WORKDIR /code
3535

36-
COPY dev-requirements.txt /code/
37-
COPY base-requirements.txt /code/
38-
COPY prod-requirements.txt /code/
39-
COPY requirements.txt /code/
40-
4136
RUN pip --no-cache-dir --disable-pip-version-check install --upgrade pip setuptools wheel
4237

38+
COPY pyproject.toml /code/
39+
4340
RUN --mount=type=cache,target=/root/.cache/pip \
4441
set -x \
4542
&& pip --disable-pip-version-check \
4643
install \
47-
-r requirements.txt -r prod-requirements.txt
44+
'.[prod]'
45+
4846
COPY . /code/
47+
48+
RUN pip --disable-pip-version-check install --no-deps '.'
4949
RUN DJANGO_SETTINGS_MODULE=pydotorg.settings.static python manage.py collectstatic --noinput

Makefile

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,90 @@
1-
help:
2-
@echo "Call a specific subcommand:"
3-
@echo
4-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
5-
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6-
@echo
1+
.DEFAULT_GOAL := help
72

8-
default: help
3+
help: ## Display this help text
4+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
95

10-
.state/docker-build-web: Dockerfile dev-requirements.txt base-requirements.txt
11-
# Build web container for this project
12-
docker compose build --force-rm web
6+
# =============================================================================
7+
# Docker State
8+
# =============================================================================
139

14-
# Mark the state so we don't rebuild this needlessly.
10+
.state/docker-build-web: Dockerfile pyproject.toml
11+
docker compose build --force-rm web
1512
mkdir -p .state && touch .state/docker-build-web
1613

1714
.state/db-migrated:
18-
# Call migrate target
19-
make migrate
20-
21-
# Mark the state so we don't rebuild this needlessly.
15+
make migrate
2216
mkdir -p .state && touch .state/db-migrated
2317

2418
.state/db-initialized: .state/docker-build-web .state/db-migrated
25-
# Load all fixtures
2619
docker compose run --rm web ./manage.py loaddata fixtures/*.json
27-
28-
# Mark the state so we don't rebuild this needlessly.
2920
mkdir -p .state && touch .state/db-initialized
3021

22+
# =============================================================================
23+
# Development
24+
# =============================================================================
25+
26+
##@ Development
27+
3128
serve: .state/db-initialized ## Start the application
3229
docker compose up --remove-orphans
3330

3431
migrations: .state/db-initialized ## Generate migrations from models
35-
docker compose run --rm web ./manage.py makemigrations
36-
32+
docker compose run --rm web ./manage.py makemigrations
33+
3734
migrate: .state/docker-build-web ## Run Django migrate
38-
docker compose run --rm web ./manage.py migrate
35+
docker compose run --rm web ./manage.py migrate
3936

40-
manage: .state/db-initialized ## Run Django manage to accept arbitrary arguments
37+
manage: .state/db-initialized ## Run arbitrary manage.py commands
4138
docker compose run --rm web ./manage.py $(filter-out $@,$(MAKECMDGOALS))
4239

4340
shell: .state/db-initialized ## Open Django interactive shell
4441
docker compose run --rm web ./manage.py shell
4542

43+
docker_shell: .state/db-initialized ## Open bash in web container
44+
docker compose run --rm web /bin/bash
45+
4646
clean: ## Clean up the environment
4747
docker compose down -v
48-
rm -f .state/docker-build-web .state/db-initialized .state/db-migrated
48+
rm -f .state/docker-build-web .state/db-initialized .state/db-migrated
49+
50+
# =============================================================================
51+
# Code Quality
52+
# =============================================================================
4953

50-
test: .state/db-initialized ## Run tests
54+
##@ Code Quality
55+
56+
lint: ## Run ruff linter (--fix enabled)
57+
@if command -v ruff >/dev/null 2>&1; then ruff check --fix .; else docker compose run --rm web ruff check --fix .; fi
58+
59+
fmt: ## Run ruff formatter
60+
@if command -v ruff >/dev/null 2>&1; then ruff format .; else docker compose run --rm web ruff format .; fi
61+
62+
test: .state/db-initialized ## Run test suite
5163
docker compose run --rm web ./manage.py test
5264

53-
docker_shell: .state/db-initialized ## Open a bash shell in the web container
54-
docker compose run --rm web /bin/bash
65+
ci: lint fmt test ## Run lint, fmt, then tests
66+
67+
# =============================================================================
68+
# Documentation
69+
# =============================================================================
70+
71+
##@ Documentation
72+
73+
docs: docs-clean ## Build documentation
74+
@echo "=> Building documentation"
75+
@uv sync --group docs
76+
@uv run sphinx-build -M html docs/source docs/_build/ -E -a -j auto --keep-going
77+
78+
docs-serve: docs-clean ## Serve documentation with live reload
79+
@echo "=> Serving documentation"
80+
@uv sync --group docs
81+
@uv run sphinx-autobuild docs/source docs/_build/ -j auto --port 0
82+
83+
docs-clean: ## Clean built documentation
84+
@echo "=> Cleaning documentation build assets"
85+
@rm -rf docs/_build
86+
@echo "=> Removed existing documentation build assets"
5587

56-
.PHONY: help serve migrations migrate manage shell clean test docker_shell
88+
.PHONY: help serve migrations migrate manage shell docker_shell clean
89+
.PHONY: lint fmt test ci
90+
.PHONY: docs docs-serve docs-clean

README.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,37 @@
33
[![CI](https://github.com/python/pythondotorg/actions/workflows/ci.yml/badge.svg)](https://github.com/python/pythondotorg/actions/workflows/ci.yml)
44
[![Documentation Status](https://readthedocs.org/projects/pythondotorg/badge/?version=latest)](https://pythondotorg.readthedocs.io/?badge=latest)
55

6-
### General information
7-
8-
This is the repository and issue tracker for [python.org](https://www.python.org).
6+
The codebase behind [python.org](https://www.python.org). Built with Django, PostgreSQL, Redis, and Celery.
97

108
> [!NOTE]
11-
> The repository for CPython itself is at https://github.com/python/cpython, and the
12-
> issue tracker is at https://github.com/python/cpython/issues/.
13-
>
9+
> The repository for CPython itself is at https://github.com/python/cpython, and the
10+
> issue tracker is at https://github.com/python/cpython/issues/.
11+
>
1412
> Similarly, issues related to [Python's documentation](https://docs.python.org) can be filed in
1513
> https://github.com/python/cpython/issues/.
1614
15+
### Quick start
16+
17+
```bash
18+
make serve
19+
```
20+
21+
Then visit http://localhost:8000. See the [full setup docs](https://pythondotorg.readthedocs.io/en/latest/install.html) for prerequisites.
22+
1723
### Contributing
1824

19-
* Source code: https://github.com/python/pythondotorg
20-
* Issue tracker: https://github.com/python/pythondotorg/issues
21-
* Documentation: https://pythondotorg.readthedocs.io/
22-
* Mailing list: [pydotorg-www](https://mail.python.org/mailman/listinfo/pydotorg-www)
23-
* IRC: `#pydotorg` on Freenode
24-
* License: Apache License
25+
Fork the repo, create a branch, and open a pull request. Before submitting:
26+
27+
- Run `make test` and make sure the suite passes
28+
- Run `make lint` and `make fmt`
29+
- Write tests for any new or changed code
30+
- Check for missing migrations with `make migrations`
31+
32+
CI runs on every PR — it checks for ungenerated migrations and enforces a 75%
33+
test coverage minimum. PRs that fail CI won't be merged.
34+
35+
See the full [contributing guide](https://pythondotorg.readthedocs.io/en/latest/contributing.html) for details.
36+
37+
### License
38+
39+
Apache License

0 commit comments

Comments
 (0)