diff --git a/README.md b/README.md index 3b42a5e1bf..a3f577ffd0 100644 --- a/README.md +++ b/README.md @@ -84,11 +84,11 @@ and then editing the results to include your name, email, and various configurat First, get Cookiecutter. Trust me, it's awesome: - $ pip install "cookiecutter>=1.7.0" + $ uv tool install "cookiecutter>=1.7.0" Now run it against this repo: - $ cookiecutter https://github.com/cookiecutter/cookiecutter-django + $ uvx cookiecutter https://github.com/cookiecutter/cookiecutter-django You'll be prompted for some values. Provide them, then a Django project will be created for you. diff --git a/docs/2-local-development/developing-locally-docker.rst b/docs/2-local-development/developing-locally-docker.rst index 05e188e527..5809532935 100644 --- a/docs/2-local-development/developing-locally-docker.rst +++ b/docs/2-local-development/developing-locally-docker.rst @@ -154,10 +154,10 @@ This tells our computer that all future commands are specifically for the dev1 m Add 3rd party python packages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To install a new 3rd party python package, you cannot use ``pip install ``, that would only add the package to the container. The container is ephemeral, so that new library won't be persisted if you run another container. Instead, you should modify the Docker image: -You have to modify the relevant requirement file: base, local or production by adding: :: +To install a new 3rd party python package, you cannot use ``uv add ``, that would only add the package to the container. The container is ephemeral, so that new library won't be persisted if you run another container. Instead, you should modify the Docker image: +You have to modify pyproject.toml and either add it to project.dependencies or to tool.uv.dev-dependencies by adding: :: - == + "==" To get this change picked up, you'll need to rebuild the image(s) and restart the running container: :: diff --git a/docs/2-local-development/developing-locally.rst b/docs/2-local-development/developing-locally.rst index b8484bfe0f..85abf6b4df 100644 --- a/docs/2-local-development/developing-locally.rst +++ b/docs/2-local-development/developing-locally.rst @@ -1,7 +1,7 @@ Getting Up and Running Locally ============================== -.. index:: pip, virtualenv, PostgreSQL +.. index:: PostgreSQL Setting Up Development Environment @@ -9,29 +9,19 @@ Setting Up Development Environment Make sure to have the following on your host: -* Python 3.12 +* uv https://docs.astral.sh/uv/getting-started/installation/ * PostgreSQL_. * Redis_, if using Celery * Cookiecutter_ -First things first. - -#. Create a virtualenv: :: - - $ python3.12 -m venv - -#. Activate the virtualenv you have just created: :: - - $ source /bin/activate - #. .. include:: generate-project-block.rst #. Install development requirements: :: $ cd - $ pip install -r requirements/local.txt + $ uv sync $ git init # A git repo is required for pre-commit to install - $ pre-commit install + $ uv run pre-commit install .. note:: @@ -71,15 +61,15 @@ First things first. #. Apply migrations: :: - $ python manage.py migrate + $ uv run python manage.py migrate #. If you're running synchronously, see the application being served through Django development server: :: - $ python manage.py runserver 0.0.0.0:8000 + $ uv run python manage.py runserver 0.0.0.0:8000 or if you're running asynchronously: :: - $ uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html' + $ uv run uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html' If you've opted for Webpack or Gulp as frontend pipeline, please see the :ref:`dedicated section ` below. @@ -136,7 +126,7 @@ Following this structured approach, here's how to add a new app: #. **Create the app** using Django's ``startapp`` command, replacing ```` with your desired app name: :: - $ python manage.py startapp + $ uv run python manage.py startapp #. **Move the app** to the Django Project Root, maintaining the project's two-tier structure: :: @@ -203,14 +193,14 @@ Next, make sure `redis-server` is installed (per the `Getting started with Redis Start the Celery worker by running the following command in another terminal:: - $ celery -A config.celery_app worker --loglevel=info + $ uv run celery -A config.celery_app worker --loglevel=info That Celery worker should be running whenever your app is running, typically as a background process, so that it can pick up any tasks that get queued. Learn more from the `Celery Workers Guide`_. The project comes with a simple task for manual testing purposes, inside `/users/tasks.py`. To queue that task locally, start the Django shell, import the task, and call `delay()` on it:: - $ python manage.py shell + $ uv run python manage.py shell >> from .users.tasks import get_users_count >> get_users_count.delay() diff --git a/docs/Makefile b/docs/Makefile index 722f50c7c8..fec1fc9656 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = -SPHINXBUILD = sphinx-build +SPHINXBUILD = uv run sphinx-build SOURCEDIR = . BUILDDIR = _build diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 081e806c58..c706d9abde 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -16,6 +16,7 @@ import random import shutil import string +from pathlib import Path try: # Inspired by @@ -100,7 +101,7 @@ def remove_utility_files(): def remove_heroku_files(): - file_names = ["Procfile", "runtime.txt", "requirements.txt"] + file_names = ["Procfile", "runtime.txt"] for file_name in file_names: if file_name == "requirements.txt" and "{{ cookiecutter.ci_tool }}".lower() == "travis": # don't remove the file if we are using travisci but not using heroku @@ -218,21 +219,25 @@ def handle_js_runner(choice, use_docker, use_async): def remove_prettier_pre_commit(): - with open(".pre-commit-config.yaml", "r") as fd: - content = fd.readlines() + remove_repo_from_pre_commit_config("mirrors-prettier") + + +def remove_repo_from_pre_commit_config(repo_to_remove: str): + pre_commit_config = Path(".pre-commit-config.yaml") + content = pre_commit_config.read_text().splitlines(True) removing = False - new_lines = [] + new_lines = "" + for line in content: if removing and "- repo:" in line: removing = False - if "mirrors-prettier" in line: + if repo_to_remove in line: removing = True if not removing: - new_lines.append(line) + new_lines += line - with open(".pre-commit-config.yaml", "w") as fd: - fd.writelines(new_lines) + pre_commit_config.write_text(new_lines) def remove_celery_files(): @@ -471,6 +476,7 @@ def main(): if "{{ cookiecutter.use_heroku }}".lower() == "n": remove_heroku_files() + remove_repo_from_pre_commit_config("uv-pre-commit") if "{{ cookiecutter.use_docker }}".lower() == "n" and "{{ cookiecutter.use_heroku }}".lower() == "n": if "{{ cookiecutter.keep_local_envs_in_vcs }}".lower() == "y": diff --git a/tests/test_bare.sh b/tests/test_bare.sh index f38c9357e7..58ac3d4578 100755 --- a/tests/test_bare.sh +++ b/tests/test_bare.sh @@ -18,13 +18,13 @@ cd my_awesome_project sudo utility/install_os_dependencies.sh install # Install Python deps -pip install -r requirements/local.txt +uv sync # run the project's tests -pytest +uv run pytest # Make sure the check doesn't raise any warnings -python manage.py check --fail-level WARNING +uv run python manage.py check --fail-level WARNING # Run npm build script if package.json is present if [ -f "package.json" ] @@ -34,4 +34,4 @@ then fi # Generate the HTML for the documentation -cd docs && make html +cd docs && uv run make html diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 9669d78bab..1a327737e7 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -2,6 +2,7 @@ import os import re import sys +import tomllib import pytest @@ -273,7 +274,7 @@ def test_djlint_check_passes(cookies, context_override): @pytest.mark.parametrize( ["use_docker", "expected_test_script"], [ - ("n", "pytest"), + ("n", "uv run pytest"), ("y", "docker compose -f docker-compose.local.yml run django pytest"), ], ) @@ -298,7 +299,7 @@ def test_travis_invokes_pytest(cookies, context, use_docker, expected_test_scrip @pytest.mark.parametrize( ["use_docker", "expected_test_script"], [ - ("n", "pytest"), + ("n", "uv run pytest"), ("y", "docker compose -f docker-compose.local.yml run django pytest"), ], ) @@ -315,7 +316,7 @@ def test_gitlab_invokes_precommit_and_pytest(cookies, context, use_docker, expec try: gitlab_config = yaml.safe_load(gitlab_yml) assert gitlab_config["precommit"]["script"] == [ - "pre-commit run --show-diff-on-failure --color=always --all-files" + "uv run pre-commit run --show-diff-on-failure --color=always --all-files" ] assert gitlab_config["pytest"]["script"] == [expected_test_script] except yaml.YAMLError as e: @@ -325,7 +326,7 @@ def test_gitlab_invokes_precommit_and_pytest(cookies, context, use_docker, expec @pytest.mark.parametrize( ["use_docker", "expected_test_script"], [ - ("n", "pytest"), + ("n", "uv run pytest"), ("y", "docker compose -f docker-compose.local.yml run django pytest"), ], ) @@ -412,3 +413,39 @@ def test_trim_domain_email(cookies, context): base_settings = result.project_path / "config" / "settings" / "base.py" assert '"me@example.com"' in base_settings.read_text() + + +def test_pyproject_toml(cookies, context): + author_name = "Project Author" + author_email = "me@example.com" + context.update( + { + "description": "DESCRIPTION", + "domain_name": "example.com", + "email": author_email, + "author_name": author_name, + } + ) + result = cookies.bake(extra_context=context) + assert result.exit_code == 0 + + pyproject_toml = result.project_path / "pyproject.toml" + + data = tomllib.loads(pyproject_toml.read_text()) + + assert data + assert data["project"]["authors"][0]["email"] == author_email + assert data["project"]["authors"][0]["name"] == author_name + assert data["project"]["name"] == context["project_slug"] + + +def test_pre_commit_without_heroku(cookies, context): + context.update({"use_heroku": "n"}) + result = cookies.bake(extra_context=context) + assert result.exit_code == 0 + + pre_commit_config = result.project_path / ".pre-commit-config.yaml" + + data = pre_commit_config.read_text() + + assert "uv-pre-commit" not in data diff --git a/tests/test_docker.sh b/tests/test_docker.sh index 326e583286..98a3f9622d 100755 --- a/tests/test_docker.sh +++ b/tests/test_docker.sh @@ -5,11 +5,22 @@ set -o errexit set -x +set -e + +finish() { + # Your cleanup code here + docker compose -f docker-compose.local.yml down --remove-orphans + docker volume rm my_awesome_project_my_awesome_project_local_postgres_data + +} +trap finish EXIT # create a cache directory mkdir -p .cache/docker cd .cache/docker +sudo rm -rf my_awesome_project + # create the project using the default settings in cookiecutter.json uv run cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y "$@" cd my_awesome_project @@ -20,6 +31,8 @@ docker compose -f docker-compose.local.yml build # run the project's type checks docker compose -f docker-compose.local.yml run django mypy my_awesome_project +docker compose -f docker-compose.local.yml run django uv lock + # run the project's tests docker compose -f docker-compose.local.yml run django pytest @@ -44,6 +57,7 @@ docker compose -f docker-compose.local.yml run \ # Generate the HTML for the documentation docker compose -f docker-compose.docs.yml run docs make html +docker build -f ./compose/production/django/Dockerfile . # Run npm build script if package.json is present if [ -f "package.json" ] then diff --git a/uv.lock b/uv.lock index 20b4fa0474..f0a5f59295 100644 --- a/uv.lock +++ b/uv.lock @@ -192,7 +192,7 @@ wheels = [ [[package]] name = "cookiecutter-django" -version = "2024.10.15" +version = "2024.10.25" source = { virtual = "." } dependencies = [ { name = "binaryornot" }, @@ -240,7 +240,7 @@ requires-dist = [ { name = "pytest-xdist", specifier = "==3.6.1" }, { name = "pyyaml", specifier = "==6.0.2" }, { name = "requests", specifier = "==2.32.3" }, - { name = "ruff", specifier = "==0.7.0" }, + { name = "ruff", specifier = "==0.7" }, { name = "sh", marker = "sys_platform != 'win23'", specifier = "==2.0.7" }, { name = "sphinx", marker = "extra == 'docs'", specifier = ">=8.0.2" }, { name = "sphinx-autobuild", marker = "extra == 'docs'", specifier = ">=2024.10.3" }, diff --git a/{{cookiecutter.project_slug}}/.drone.yml b/{{cookiecutter.project_slug}}/.drone.yml index 20d6fb1bbd..f8b654b12e 100644 --- a/{{cookiecutter.project_slug}}/.drone.yml +++ b/{{cookiecutter.project_slug}}/.drone.yml @@ -13,7 +13,7 @@ environment: steps: - name: lint pull: if-not-exists - image: python:3.12 + image: ghcr.io/astral-sh/uv:python3.12 environment: PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit volumes: @@ -21,8 +21,8 @@ steps: path: ${PRE_COMMIT_HOME} commands: - export PRE_COMMIT_HOME=$CI_PROJECT_DIR/.cache/pre-commit - - pip install -q pre-commit - - pre-commit run --show-diff-on-failure --color=always --all-files + - uv pip install -q pre-commit pre-commit-uv + - uv run pre-commit run --show-diff-on-failure --color=always --all-files - name: test pull: if-not-exists @@ -37,10 +37,10 @@ steps: - docker-compose -f docker-compose.local.yml up -d - docker-compose -f docker-compose.local.yml run django pytest {%- else %} - image: python:3.12 + image: ghcr.io/astral-sh/uv:python3.12 commands: - - pip install -r requirements/local.txt - - pytest + - uv sync --frozen + - uv run pytest {%- endif%} volumes: diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 6bb555063f..e8fdf35d0e 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -87,26 +87,20 @@ jobs: run: docker compose -f docker-compose.local.yml down {%- else %} - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - name: Install uv + uses: astral-sh/setup-uv@v2 with: - python-version: '3.12' - cache: pip - cache-dependency-path: | - requirements/base.txt - requirements/local.txt - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements/local.txt + enable-cache: "true" + - name: Install dependencies + run: uv sync - name: Check DB Migrations - run: python manage.py makemigrations --check + run: uv run python manage.py makemigrations --check - name: Run DB Migrations - run: python manage.py migrate + run: uv run python manage.py migrate - name: Test with pytest - run: pytest + run: uv run pytest {%- endif %} diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index 9c7cd53672..c881e22146 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -13,16 +13,16 @@ variables: precommit: stage: lint - image: python:3.12 + image: ghcr.io/astral-sh/uv:python3.12 variables: PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit cache: paths: - ${PRE_COMMIT_HOME} before_script: - - pip install -q pre-commit + - uv pip install -q pre-commit pre-commit-uv script: - - pre-commit run --show-diff-on-failure --color=always --all-files + - uv run pre-commit run --show-diff-on-failure --color=always --all-files pytest: stage: test @@ -39,13 +39,13 @@ pytest: script: - docker compose -f docker-compose.local.yml run django pytest {%- else %} - image: python:3.12 + image: ghcr.io/astral-sh/uv:python3.12 services: - postgres:{{ cookiecutter.postgresql_version }} variables: DATABASE_URL: pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB before_script: - - pip install -r requirements/local.txt + - uv sync --frozen script: - - pytest + - uv run pytest {%- endif %} diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 03adfccfa6..dc8b08a22a 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -49,6 +49,13 @@ repos: - id: djlint-reformat-django - id: djlint-django + - repo: https://github.com/astral-sh/uv-pre-commit + # uv version. + rev: 0.4.15 + hooks: + - id: uv-export + args: ['--frozen', '--no-dev'] + # sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date ci: autoupdate_schedule: weekly diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 97f9f60a27..942eea7651 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -40,7 +40,8 @@ jobs: python: - "3.12" install: - - pip install -r requirements/local.txt + - pip install uv + - uv sync script: - - pytest + - uv run pytest {%- endif %} diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 9ee864afbd..dca38279ff 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -22,7 +22,7 @@ Moved to [settings](https://cookiecutter-django.readthedocs.io/en/latest/1-getti - To create a **superuser account**, use this command: - $ python manage.py createsuperuser + $ uv run python manage.py createsuperuser For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users. @@ -30,19 +30,19 @@ For convenience, you can keep your normal user logged in on Chrome and your supe Running type checks with mypy: - $ mypy {{cookiecutter.project_slug}} + $ uv run mypy {{cookiecutter.project_slug}} ### Test coverage To run the tests, check your test coverage, and generate an HTML coverage report: - $ coverage run -m pytest - $ coverage html - $ open htmlcov/index.html + $ uv run coverage run -m pytest + $ uv run coverage html + $ uv run open htmlcov/index.html #### Running tests with pytest - $ pytest + $ uv run pytest ### Live reloading and Sass CSS compilation @@ -58,7 +58,7 @@ To run a celery worker: ```bash cd {{cookiecutter.project_slug}} -celery -A config.celery_app worker -l info +uv run celery -A config.celery_app worker -l info ``` Please note: For Celery's import magic to work, it is important _where_ the celery commands are run. If you are in the same folder with _manage.py_, you should be right. @@ -67,14 +67,14 @@ To run [periodic tasks](https://docs.celeryq.dev/en/stable/userguide/periodic-ta ```bash cd {{cookiecutter.project_slug}} -celery -A config.celery_app beat +uv run celery -A config.celery_app beat ``` or you can embed the beat service inside a worker with the `-B` option (not recommended for production use): ```bash cd {{cookiecutter.project_slug}} -celery -A config.celery_app worker -B -l info +uv run celery -A config.celery_app worker -B -l info ``` {%- endif %} diff --git a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile index d892c9dca1..8b21f48779 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile @@ -1,37 +1,32 @@ -# define an alias for the specific python version used in this file. -FROM docker.io/python:3.12.7-slim-bookworm AS python - # Python build stage -FROM python AS python-build-stage +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS python-build-stage + +ARG APP_HOME=/app + +WORKDIR ${APP_HOME} -ARG BUILD_ENVIRONMENT=local +# we need to move the virtualenv outside of the $APP_HOME directory because it will be overriden by the docker compose mount +ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy # Install apt packages RUN apt-get update && apt-get install --no-install-recommends -y \ # dependencies for building Python packages build-essential \ # psycopg dependencies - libpq-dev + libpq-dev \ + gettext \ + wait-for-it # Requirements are installed here to ensure they will be cached. -COPY ./requirements . - -# Create Python Dependency and Sub-Dependency Wheels. -RUN pip wheel --wheel-dir /usr/src/app/wheels \ - -r ${BUILD_ENVIRONMENT}.txt - - -# Python 'run' stage -FROM python AS python-run-stage - -ARG BUILD_ENVIRONMENT=local -ARG APP_HOME=/app +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + --mount=type=bind,source=uv.lock,target=uv.lock:rw \ + uv sync --no-install-project -ENV PYTHONUNBUFFERED=1 -ENV PYTHONDONTWRITEBYTECODE=1 -ENV BUILD_ENV=${BUILD_ENVIRONMENT} +COPY . ${APP_HOME} -WORKDIR ${APP_HOME} +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync {% if cookiecutter.use_docker == "y" %} # devcontainer dependencies and utils @@ -45,24 +40,7 @@ RUN groupadd --gid 1000 dev-user \ && chmod 0440 /etc/sudoers.d/dev-user {% endif %} -# Install required system dependencies -RUN apt-get update && apt-get install --no-install-recommends -y \ - # psycopg dependencies - libpq-dev \ - wait-for-it \ - # Translations dependencies - gettext \ - # cleaning up unused files - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ - && rm -rf /var/lib/apt/lists/* - -# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction -# copy python dependency wheels from python-build-stage -COPY --from=python-build-stage /usr/src/app/wheels /wheels/ - -# use wheels to install python dependencies -RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \ - && rm -rf /wheels/ +ENV PATH="/${APP_HOME}/.venv/bin:$PATH" COPY ./compose/production/django/entrypoint /entrypoint RUN sed -i 's/\r$//g' /entrypoint @@ -86,7 +64,4 @@ RUN sed -i 's/\r$//g' /start-flower RUN chmod +x /start-flower {% endif %} -# copy application code to WORKDIR -COPY . ${APP_HOME} - ENTRYPOINT ["/entrypoint"] diff --git a/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile index 40caf85117..768f3ef614 100644 --- a/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile @@ -1,11 +1,9 @@ -# define an alias for the specific python version used in this file. -FROM docker.io/python:3.12.7-slim-bookworm AS python - - # Python build stage -FROM python AS python-build-stage +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS python-build-stage -ENV PYTHONDONTWRITEBYTECODE=1 +ARG APP_HOME=/app + +WORKDIR ${APP_HOME} RUN apt-get update && apt-get install --no-install-recommends -y \ # dependencies for building Python packages @@ -17,16 +15,19 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && rm -rf /var/lib/apt/lists/* # Requirements are installed here to ensure they will be cached. -COPY ./requirements /requirements +RUN --mount=type=cache,target=/root/.cache/uv \ +# --mount=type=bind,source=uv.lock,target=uv.lock \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + uv sync --no-install-project -# create python dependency wheels -RUN pip wheel --no-cache-dir --wheel-dir /usr/src/app/wheels \ - -r /requirements/local.txt -r /requirements/production.txt \ - && rm -rf /requirements +COPY . ${APP_HOME} + +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync # Python 'run' stage -FROM python AS python-run-stage +FROM docker.io/python:3.12.7-slim-bookworm AS python-run-stage ARG BUILD_ENVIRONMENT ENV PYTHONUNBUFFERED=1 @@ -49,14 +50,12 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && rm -rf /var/lib/apt/lists/* # copy python dependency wheels from python-build-stage -COPY --from=python-build-stage /usr/src/app/wheels /wheels - -# use wheels to install python dependencies -RUN pip install --no-cache /wheels/* \ - && rm -rf /wheels +COPY --from=python-build-stage --chown=app:app /app /app COPY ./compose/local/docs/start /start-docs RUN sed -i 's/\r$//g' /start-docs RUN chmod +x /start-docs +ENV PATH="/app/.venv/bin:$PATH" + WORKDIR /docs diff --git a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile index a3908625cc..b2b558338d 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile @@ -22,15 +22,14 @@ ENV DJANGO_AZURE_ACCOUNT_NAME=${DJANGO_AZURE_ACCOUNT_NAME} {%- endif %} {%- endif %} RUN npm run build - {%- endif %} -# define an alias for the specific python version used in this file. -FROM docker.io/python:3.12.7-slim-bookworm AS python -# Python build stage -FROM python AS python-build-stage +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS python-build-stage +ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy + +ARG APP_HOME=/app -ARG BUILD_ENVIRONMENT=production +WORKDIR ${APP_HOME} # Install apt packages RUN apt-get update && apt-get install --no-install-recommends -y \ @@ -41,23 +40,24 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ # Requirements are installed here to ensure they will be cached. -COPY ./requirements . - -# Create Python Dependency and Sub-Dependency Wheels. -RUN pip wheel --wheel-dir /usr/src/app/wheels \ - -r ${BUILD_ENVIRONMENT}.txt +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=uv.lock,target=uv.lock \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + uv sync --frozen --no-install-project --no-dev +{%- if cookiecutter.frontend_pipeline in ['Gulp', 'Webpack'] %} +COPY --from=client-builder ${APP_HOME} ${APP_HOME} +{% else %} +COPY . ${APP_HOME} +{%- endif %} +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --frozen --no-dev # Python 'run' stage -FROM python AS python-run-stage +FROM docker.io/python:3.12.7-slim-bookworm AS python-run-stage -ARG BUILD_ENVIRONMENT=production ARG APP_HOME=/app -ENV PYTHONUNBUFFERED=1 -ENV PYTHONDONTWRITEBYTECODE=1 -ENV BUILD_ENV=${BUILD_ENVIRONMENT} - WORKDIR ${APP_HOME} RUN addgroup --system django \ @@ -76,14 +76,6 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* -# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction -# copy python dependency wheels from python-build-stage -COPY --from=python-build-stage /usr/src/app/wheels /wheels/ - -# use wheels to install python dependencies -RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \ - && rm -rf /wheels/ - COPY --chown=django:django ./compose/production/django/entrypoint /entrypoint RUN sed -i 's/\r$//g' /entrypoint @@ -111,16 +103,11 @@ RUN sed -i 's/\r$//g' /start-flower RUN chmod +x /start-flower {%- endif %} +# Copy the application from the builder +COPY --from=python-build-stage --chown=django:django ${APP_HOME} ${APP_HOME} -# copy application code to WORKDIR -{%- if cookiecutter.frontend_pipeline in ['Gulp', 'Webpack'] %} -COPY --from=client-builder --chown=django:django ${APP_HOME} ${APP_HOME} -{% else %} -COPY --chown=django:django . ${APP_HOME} -{%- endif %} - -# make django owner of the WORKDIR directory as well. -RUN chown -R django:django ${APP_HOME} +# Place executables in the environment at the front of the path +ENV PATH="/app/.venv/bin:$PATH" USER django diff --git a/{{cookiecutter.project_slug}}/docker-compose.docs.yml b/{{cookiecutter.project_slug}}/docker-compose.docs.yml index 215b6c3b77..011356c8a3 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.docs.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.docs.yml @@ -9,8 +9,6 @@ services: - ./.envs/.local/.django volumes: - ./docs:/docs:z - - ./config:/app/config:z - - ./{{ cookiecutter.project_slug }}:/app/{{ cookiecutter.project_slug }}:z ports: - '9000:9000' command: /start-docs diff --git a/{{cookiecutter.project_slug}}/docker-compose.local.yml b/{{cookiecutter.project_slug}}/docker-compose.local.yml index eced08ee8c..154f79608a 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.local.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.local.yml @@ -10,6 +10,9 @@ services: dockerfile: ./compose/local/django/Dockerfile image: {{ cookiecutter.project_slug }}_local_django container_name: {{ cookiecutter.project_slug }}_local_django + volumes: + - /app/.venv + - .:/app:z depends_on: - postgres {%- if cookiecutter.use_celery == 'y' %} @@ -18,8 +21,6 @@ services: {%- if cookiecutter.use_mailpit == 'y' %} - mailpit {%- endif %} - volumes: - - .:/app:z env_file: - ./.envs/.local/.django - ./.envs/.local/.postgres diff --git a/{{cookiecutter.project_slug}}/docs/howto.rst b/{{cookiecutter.project_slug}}/docs/howto.rst index 944c2b7318..2ad20966b0 100644 --- a/{{cookiecutter.project_slug}}/docs/howto.rst +++ b/{{cookiecutter.project_slug}}/docs/howto.rst @@ -9,7 +9,7 @@ Documentation can be written as rst files in `{{cookiecutter.project_slug}}/docs {% if cookiecutter.use_docker == 'n' %} To build and serve docs, use the command:: - make livehtml + uv run make livehtml from inside the `{{cookiecutter.project_slug}}/docs` directory. {% else %} @@ -35,7 +35,7 @@ For an in-use example, see the `page source <_sources/users.rst.txt>`_ for :ref: To compile all docstrings automatically into documentation source files, use the command: :: - make apidocs + uv run make apidocs {% if cookiecutter.use_docker == 'y' %} This can be done in the docker container: diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 98a883b620..f261223b7d 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -26,9 +26,9 @@ warn_redundant_casts = true warn_unused_configs = true plugins = [ "mypy_django_plugin.main", -{%- if cookiecutter.use_drf == "y" %} + {%- if cookiecutter.use_drf == "y" %} "mypy_drf_plugin.main", -{%- endif %} + {%- endif %} ] [[tool.mypy.overrides]] @@ -68,69 +68,69 @@ extend-exclude = [ [tool.ruff.lint] select = [ - "F", - "E", - "W", - "C90", - "I", - "N", - "UP", - "YTT", - # "ANN", # flake8-annotations: we should support this in the future but 100+ errors atm - "ASYNC", - "S", - "BLE", - "FBT", - "B", - "A", - "COM", - "C4", - "DTZ", - "T10", - "DJ", - "EM", - "EXE", - "FA", - 'ISC', - "ICN", - "G", - 'INP', - 'PIE', - "T20", - 'PYI', - 'PT', - "Q", - "RSE", - "RET", - "SLF", - "SLOT", - "SIM", - "TID", - "TCH", - "INT", - # "ARG", # Unused function argument - "PTH", - "ERA", - "PD", - "PGH", - "PL", - "TRY", - "FLY", - # "NPY", - # "AIR", - "PERF", - # "FURB", - # "LOG", - "RUF", + "F", + "E", + "W", + "C90", + "I", + "N", + "UP", + "YTT", + # "ANN", # flake8-annotations: we should support this in the future but 100+ errors atm + "ASYNC", + "S", + "BLE", + "FBT", + "B", + "A", + "COM", + "C4", + "DTZ", + "T10", + "DJ", + "EM", + "EXE", + "FA", + 'ISC', + "ICN", + "G", + 'INP', + 'PIE', + "T20", + 'PYI', + 'PT', + "Q", + "RSE", + "RET", + "SLF", + "SLOT", + "SIM", + "TID", + "TCH", + "INT", + # "ARG", # Unused function argument + "PTH", + "ERA", + "PD", + "PGH", + "PL", + "TRY", + "FLY", + # "NPY", + # "AIR", + "PERF", + # "FURB", + # "LOG", + "RUF", ] ignore = [ - "S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/ - "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` - "SIM102", # sometimes it's better to nest - "UP038", # Checks for uses of isinstance/issubclass that take a tuple - # of types for comparison. - # Deactivated because it can make the code slow: - # https://github.com/astral-sh/ruff/issues/7871 + "S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/ + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + "SIM102", # sometimes it's better to nest + "UP038", # Checks for uses of isinstance/issubclass that take a tuple + # of types for comparison. + # Deactivated because it can make the code slow: + # https://github.com/astral-sh/ruff/issues/7871 ] # The fixes in extend-unsafe-fixes will require # provide the `--unsafe-fixes` flag when fixing. @@ -140,3 +140,146 @@ extend-unsafe-fixes = [ [tool.ruff.lint.isort] force-single-line = true + +[dependency-groups] +dev = [ + "Werkzeug[watchdog]==3.0.6", # https://github.com/pallets/werkzeug + "ipdb==0.13.13", # https://github.com/gotcha/ipdb + {%- if cookiecutter.use_docker == 'y' %} + "psycopg[c]==3.2.3", # https://github.com/psycopg/psycopg + {%- else %} + "psycopg[binary]==3.2.3", # https://github.com/psycopg/psycopg + {%- endif %} + {%- if cookiecutter.use_async == 'y' or cookiecutter.use_celery == 'y' %} + "watchfiles==0.24.0", # https://github.com/samuelcolvin/watchfiles + {%- endif %} + # Testing + # ------------------------------------------------------------------------------ + "mypy==1.11.2", # https://github.com/python/mypy + "django-stubs[compatible-mypy]==5.1.0", # https://github.com/typeddjango/django-stubs + "pytest==8.3.3", # https://github.com/pytest-dev/pytest + "pytest-sugar==1.0.0", # https://github.com/Frozenball/pytest-sugar + {%- if cookiecutter.use_drf == "y" %} + "djangorestframework-stubs==3.15.1", # https://github.com/typeddjango/djangorestframework-stubs + {%- endif %} + # Documentation + # ------------------------------------------------------------------------------ + "sphinx==7.4.7", # https://github.com/sphinx-doc/sphinx + "sphinx-autobuild==2024.10.3", # https://github.com/GaretJax/sphinx-autobuild + # Code quality + # ------------------------------------------------------------------------------ + "ruff==0.6.9", # https://github.com/astral-sh/ruff + "coverage==7.6.1", # https://github.com/nedbat/coveragepy + "djlint==1.35.2", # https://github.com/Riverside-Healthcare/djLint + "pre-commit==3.8.0", # https://github.com/pre-commit/pre-commit + # Django + # ------------------------------------------------------------------------------ + "factory-boy==3.3.1", # https://github.com/FactoryBoy/factory_boy + "django-debug-toolbar==4.4.6", # https://github.com/jazzband/django-debug-toolbar + "django-extensions==3.2.3", # https://github.com/django-extensions/django-extensions + "django-coverage-plugin==3.1.0", # https://github.com/nedbat/django_coverage_plugin + "pytest-django==4.9.0", # https://github.com/pytest-dev/pytest-django +] + +[project] +name = "{{ cookiecutter.project_slug }}" +version = "{{ cookiecutter.version }}" +description = "{{ cookiecutter.description }}" +readme = "README.md" + +license = { text = "{{ cookiecutter.open_source_license }}" } +authors = [ + { name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.email }}" }, +] +requires-python = "==3.12.*" +dependencies = [ + "python-slugify==8.0.4", # https://github.com/un33k/python-slugify + "Pillow==10.4.0", # https://github.com/python-pillow/Pillow + {%- if cookiecutter.frontend_pipeline == 'Django Compressor' %} + {%- if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %} + "rcssmin==1.1.2", # --install-option="--without-c-extensions" # https://github.com/ndparker/rcssmin + {%- else %} + "rcssmin==1.1.2", # https://github.com/ndparker/rcssmin + {%- endif %} + {%- endif %} + "argon2-cffi==23.1.0", # https://github.com/hynek/argon2_cffi + {%- if cookiecutter.use_whitenoise == 'y' %} + "whitenoise==6.7.0", # https://github.com/evansd/whitenoise + {%- endif %} + "redis==5.1.1", # https://github.com/redis/redis-py + {%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "n" %} + "hiredis==3.0.0", # https://github.com/redis/hiredis-py + {%- endif %} + {%- if cookiecutter.use_celery == "y" %} + "celery==5.4.0", # pyup: < 6.0 # https://github.com/celery/celery + "django-celery-beat==2.7.0", # https://github.com/celery/django-celery-beat + {%- if cookiecutter.use_docker == 'y' %} + "flower==2.0.1", # https://github.com/mher/flower + {%- endif %} + {%- endif %} + {%- if cookiecutter.use_async == 'y' %} + "uvicorn[standard]==0.31.0", # https://github.com/encode/uvicorn + "uvicorn-worker==0.2.0", # https://github.com/Kludex/uvicorn-worker + {%- endif %} + # Django + # ------------------------------------------------------------------------------ + "django==5.0.9", # pyup: < 5.1 # https://www.djangoproject.com/ + "django-environ==0.11.2", # https://github.com/joke2k/django-environ + "django-model-utils==5.0.0", # https://github.com/jazzband/django-model-utils + "django-allauth[mfa]==65.0.2", # https://github.com/pennersr/django-allauth + "django-crispy-forms==2.3", # https://github.com/django-crispy-forms/django-crispy-forms + "crispy-bootstrap5==2024.10", # https://github.com/django-crispy-forms/crispy-bootstrap5 + {%- if cookiecutter.frontend_pipeline == 'Django Compressor' %} + "django-compressor==4.5.1", # https://github.com/django-compressor/django-compressor + {%- endif %} + "django-redis==5.4.0", # https://github.com/jazzband/django-redis + {%- if cookiecutter.use_drf == 'y' %} + # Django REST Framework + "djangorestframework==3.15.2", # https://github.com/encode/django-rest-framework + "django-cors-headers==4.4.0", # https://github.com/adamchainz/django-cors-headers + # DRF-spectacular for api documentation + "drf-spectacular==0.27.2", # https://github.com/tfranzel/drf-spectacular + {%- endif %} + {%- if cookiecutter.frontend_pipeline == 'Webpack' %} + "django-webpack-loader==3.1.1", # https://github.com/django-webpack/django-webpack-loader + {%- endif %} + "gunicorn==23.0.0", # https://github.com/benoitc/gunicorn + "psycopg[c]==3.2.3", # https://github.com/psycopg/psycopg + {%- if cookiecutter.use_whitenoise == 'n' %} + "Collectfasta==3.2.0", # https://github.com/jasongi/collectfasta + {%- endif %} + {%- if cookiecutter.use_sentry == "y" %} + "sentry-sdk==2.15.0", # https://github.com/getsentry/sentry-python + {%- endif %} + {%- if cookiecutter.use_docker == "n" and cookiecutter.windows == "y" %} + "hiredis==3.0.0", # https://github.com/redis/hiredis-py + {%- endif %} + # Django + # ------------------------------------------------------------------------------ + {%- if cookiecutter.cloud_provider == 'AWS' %} + "django-storages[s3]==1.14.4", # https://github.com/jschneier/django-storages + {%- elif cookiecutter.cloud_provider == 'GCP' %} + "django-storages[google]==1.14.4", # https://github.com/jschneier/django-storages + {%- elif cookiecutter.cloud_provider == 'Azure' %} + "django-storages[azure]==1.14.4", # https://github.com/jschneier/django-storages + {%- endif %} + {%- if cookiecutter.mail_service == 'Mailgun' %} + "django-anymail[mailgun]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'Amazon SES' %} + "django-anymail[amazon-ses]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'Mailjet' %} + "django-anymail[mailjet]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'Mandrill' %} + "django-anymail[mandrill]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'Postmark' %} + "django-anymail[postmark]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'Sendgrid' %} + "django-anymail[sendgrid]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'Brevo' %} + "django-anymail[brevo]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'SparkPost' %} + "django-anymail[sparkpost]==12.0", # https://github.com/anymail/django-anymail + {%- elif cookiecutter.mail_service == 'Other SMTP' %} + "django-anymail==12.0", # https://github.com/anymail/django-anymail + {%- endif %} +] diff --git a/{{cookiecutter.project_slug}}/requirements.txt b/{{cookiecutter.project_slug}}/requirements.txt deleted file mode 100644 index c1b500c2b4..0000000000 --- a/{{cookiecutter.project_slug}}/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -# This file is expected by Heroku. - --r requirements/production.txt diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt deleted file mode 100644 index ea74cf0d5d..0000000000 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ /dev/null @@ -1,51 +0,0 @@ -python-slugify==8.0.4 # https://github.com/un33k/python-slugify -Pillow==11.0.0 # https://github.com/python-pillow/Pillow -{%- if cookiecutter.frontend_pipeline == 'Django Compressor' %} -{%- if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %} -rcssmin==1.1.2 --install-option="--without-c-extensions" # https://github.com/ndparker/rcssmin -{%- else %} -rcssmin==1.1.2 # https://github.com/ndparker/rcssmin -{%- endif %} -{%- endif %} -argon2-cffi==23.1.0 # https://github.com/hynek/argon2_cffi -{%- if cookiecutter.use_whitenoise == 'y' %} -whitenoise==6.7.0 # https://github.com/evansd/whitenoise -{%- endif %} -redis==5.2.0 # https://github.com/redis/redis-py -{%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "n" %} -hiredis==3.0.0 # https://github.com/redis/hiredis-py -{%- endif %} -{%- if cookiecutter.use_celery == "y" %} -celery==5.4.0 # pyup: < 6.0 # https://github.com/celery/celery -django-celery-beat==2.7.0 # https://github.com/celery/django-celery-beat -{%- if cookiecutter.use_docker == 'y' %} -flower==2.0.1 # https://github.com/mher/flower -{%- endif %} -{%- endif %} -{%- if cookiecutter.use_async == 'y' %} -uvicorn[standard]==0.32.0 # https://github.com/encode/uvicorn -uvicorn-worker==0.2.0 # https://github.com/Kludex/uvicorn-worker -{%- endif %} - -# Django -# ------------------------------------------------------------------------------ -django==5.0.9 # pyup: < 5.1 # https://www.djangoproject.com/ -django-environ==0.11.2 # https://github.com/joke2k/django-environ -django-model-utils==5.0.0 # https://github.com/jazzband/django-model-utils -django-allauth[mfa]==65.1.0 # https://github.com/pennersr/django-allauth -django-crispy-forms==2.3 # https://github.com/django-crispy-forms/django-crispy-forms -crispy-bootstrap5==2024.10 # https://github.com/django-crispy-forms/crispy-bootstrap5 -{%- if cookiecutter.frontend_pipeline == 'Django Compressor' %} -django-compressor==4.5.1 # https://github.com/django-compressor/django-compressor -{%- endif %} -django-redis==5.4.0 # https://github.com/jazzband/django-redis -{%- if cookiecutter.use_drf == 'y' %} -# Django REST Framework -djangorestframework==3.15.2 # https://github.com/encode/django-rest-framework -django-cors-headers==4.5.0 # https://github.com/adamchainz/django-cors-headers -# DRF-spectacular for api documentation -drf-spectacular==0.27.2 # https://github.com/tfranzel/drf-spectacular -{%- endif %} -{%- if cookiecutter.frontend_pipeline == 'Webpack' %} -django-webpack-loader==3.1.1 # https://github.com/django-webpack/django-webpack-loader -{%- endif %} diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt deleted file mode 100644 index e94a71f5ac..0000000000 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ /dev/null @@ -1,43 +0,0 @@ --r production.txt - -Werkzeug[watchdog]==3.0.6 # https://github.com/pallets/werkzeug -ipdb==0.13.13 # https://github.com/gotcha/ipdb -{%- if cookiecutter.use_docker == 'y' %} -psycopg[c]==3.2.3 # https://github.com/psycopg/psycopg -{%- else %} -psycopg[binary]==3.2.3 # https://github.com/psycopg/psycopg -{%- endif %} -{%- if cookiecutter.use_async == 'y' or cookiecutter.use_celery == 'y' %} -watchfiles==0.24.0 # https://github.com/samuelcolvin/watchfiles -{%- endif %} - -# Testing -# ------------------------------------------------------------------------------ -mypy==1.13.0 # https://github.com/python/mypy -django-stubs[compatible-mypy]==5.1.1 # https://github.com/typeddjango/django-stubs -pytest==8.3.3 # https://github.com/pytest-dev/pytest -pytest-sugar==1.0.0 # https://github.com/Frozenball/pytest-sugar -{%- if cookiecutter.use_drf == "y" %} -djangorestframework-stubs==3.15.1 # https://github.com/typeddjango/djangorestframework-stubs -{%- endif %} - -# Documentation -# ------------------------------------------------------------------------------ -sphinx==8.1.3 # https://github.com/sphinx-doc/sphinx -sphinx-autobuild==2024.10.3 # https://github.com/GaretJax/sphinx-autobuild - -# Code quality -# ------------------------------------------------------------------------------ -ruff==0.7.1 # https://github.com/astral-sh/ruff -coverage==7.6.4 # https://github.com/nedbat/coveragepy -djlint==1.35.2 # https://github.com/Riverside-Healthcare/djLint -pre-commit==4.0.1 # https://github.com/pre-commit/pre-commit - -# Django -# ------------------------------------------------------------------------------ -factory-boy==3.3.1 # https://github.com/FactoryBoy/factory_boy - -django-debug-toolbar==4.4.6 # https://github.com/jazzband/django-debug-toolbar -django-extensions==3.2.3 # https://github.com/django-extensions/django-extensions -django-coverage-plugin==3.1.0 # https://github.com/nedbat/django_coverage_plugin -pytest-django==4.9.0 # https://github.com/pytest-dev/pytest-django diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt deleted file mode 100644 index b6f22db451..0000000000 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ /dev/null @@ -1,44 +0,0 @@ -# PRECAUTION: avoid production dependencies that aren't in development - --r base.txt - -gunicorn==23.0.0 # https://github.com/benoitc/gunicorn -psycopg[c]==3.2.3 # https://github.com/psycopg/psycopg -{%- if cookiecutter.use_whitenoise == 'n'and cookiecutter.cloud_provider in ('AWS', 'GCP') %} -Collectfasta==3.2.0 # https://github.com/jasongi/collectfasta -{%- endif %} -{%- if cookiecutter.use_sentry == "y" %} -sentry-sdk==2.17.0 # https://github.com/getsentry/sentry-python -{%- endif %} -{%- if cookiecutter.use_docker == "n" and cookiecutter.windows == "y" %} -hiredis==3.0.0 # https://github.com/redis/hiredis-py -{%- endif %} - -# Django -# ------------------------------------------------------------------------------ -{%- if cookiecutter.cloud_provider == 'AWS' %} -django-storages[s3]==1.14.4 # https://github.com/jschneier/django-storages -{%- elif cookiecutter.cloud_provider == 'GCP' %} -django-storages[google]==1.14.4 # https://github.com/jschneier/django-storages -{%- elif cookiecutter.cloud_provider == 'Azure' %} -django-storages[azure]==1.14.4 # https://github.com/jschneier/django-storages -{%- endif %} -{%- if cookiecutter.mail_service == 'Mailgun' %} -django-anymail[mailgun]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Amazon SES' %} -django-anymail[amazon-ses]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Mailjet' %} -django-anymail[mailjet]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Mandrill' %} -django-anymail[mandrill]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Postmark' %} -django-anymail[postmark]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Sendgrid' %} -django-anymail[sendgrid]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Brevo' %} -django-anymail[brevo]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'SparkPost' %} -django-anymail[sparkpost]==12.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Other SMTP' %} -django-anymail==12.0 # https://github.com/anymail/django-anymail -{%- endif %} diff --git a/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh b/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh index e09ebf6f85..d340bc454d 100755 --- a/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh +++ b/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh @@ -33,7 +33,7 @@ if [ -z "$VIRTUAL_ENV" ]; then echo >&2 -e "\n" exit 1; else - pip install -r $PROJECT_DIR/requirements/local.txt + uv sync --frozen {%- if cookiecutter.use_heroku == "y" -%} pip install -r $PROJECT_DIR/requirements.txt {%- endif %} diff --git a/{{cookiecutter.project_slug}}/uv.lock b/{{cookiecutter.project_slug}}/uv.lock new file mode 100644 index 0000000000..975be54ebb --- /dev/null +++ b/{{cookiecutter.project_slug}}/uv.lock @@ -0,0 +1,2 @@ +version = 1 +requires-python = "==3.12.*"