Skip to content
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

Upgrade to UV 0.4.x #951

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
- name: Install Python requirements
run: |
pip install --upgrade uv
uv pip install --system -r config/requirements/dev_lock.txt
uv sync --frozen
- name: Run linting
run: |
PYTHON_CMD_PREFIX="" NODE_CMD_PREFIX="" just lint
PATH=$(pwd)/.venv/bin/:${PATH} just lint
env:
SECRET_KEY: secret-key-for-testing-only
DEBUG: on
Expand Down
17 changes: 12 additions & 5 deletions config/docker/Dockerfile.web
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@ FROM python:3.12-bookworm as python-requirements

ARG ENV_NAME=dev

ENV VIRTUAL_ENV=/opt/venv
ENV \
# This prevents Python from writing out pyc files \
PYTHONDONTWRITEBYTECODE=1 \
# This keeps Python from buffering stdin/stdout \
PYTHONUNBUFFERED=1 \
VIRTUAL_ENV=/opt/venv
UV_PROJECT_ENVIRONMENT=$VIRTUAL_ENV

RUN set -ex \
&& python3 -m venv $VIRTUAL_ENV \
&& $VIRTUAL_ENV/bin/pip install -U setuptools wheel pip uv

# Install Python packages
COPY config/requirements/${ENV_NAME}_lock.txt ./config/requirements/${ENV_NAME}_lock.txt
COPY uv.lock pyproject.toml ./

RUN set -ex \
&& $VIRTUAL_ENV/bin/uv pip install -r config/requirements/${ENV_NAME}_lock.txt \
&& if [ "$ENV_NAME" = "prod" ]; then \
$VIRTUAL_ENV/bin/uv sync --no-dev; \
else \
$VIRTUAL_ENV/bin/uv sync; \
fi \
&& rm -rf /root/.cache/


Expand All @@ -39,7 +44,8 @@ RUN apt-get update \
&& echo "LANG=en_US.UTF-8" > /etc/locale.conf \
&& locale-gen en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/* \
&& echo "\nsource /srv/app/config/bash/bashrc" >> /root/.bashrc
&& echo "\nsource /srv/app/config/bash/bashrc" >> /root/.bashrc \
&& echo "\nsource /opt/venv/bin/activate" >> /root/.bashrc

ENV VIRTUAL_ENV=/opt/venv
ENV LANG=en_US.UTF-8 \
Expand Down Expand Up @@ -85,7 +91,8 @@ WORKDIR /srv/app

RUN set -ex \
&& groupadd -r app --gid=1000 && useradd --uid=1000 --create-home --home-dir=/home/app --no-log-init -r -g app app \
&& echo "\nsource ./config/bash/bashrc" >> /home/app/.bashrc
&& echo "\nsource ./config/bash/bashrc" >> /home/app/.bashrc \
&& echo "\nsource /opt/venv/bin/activate" >> /home/app/.bashrc

COPY --chown=app:app . .

Expand Down
19 changes: 0 additions & 19 deletions config/requirements/dev.in

This file was deleted.

1,510 changes: 0 additions & 1,510 deletions config/requirements/dev_lock.txt

This file was deleted.

20 changes: 0 additions & 20 deletions config/requirements/prod.in

This file was deleted.

446 changes: 0 additions & 446 deletions config/requirements/prod_lock.txt

This file was deleted.

61 changes: 38 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
[project]
name = "django-base-site"
description = "A Django project template for creating new Django projects."
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"Django~=5.0",
"boto3~=1.34",
"celery~=5.3",
"crispy-bootstrap5~=2024.2",
"django-alive~=2.0",
"django-allauth~=64.0",
"django-crispy-forms~=2.2",
"django-maintenance-mode~=0.19",
"django-storages~=1.8",
"environs[django]~=11.0",
"hiredis~=3.0", # needed for Django's native cache and sessions
"psycopg2-binary~=2.8",
"pytest-cov~=5.0",
"pytest-django~=4.5",
"redis~=5.0", # needed for celery
"uwsgi~=2.0",
]

#[tool.black]
#line-length = 120
#target-version = ['py311']
#skip-string-normalization = false
#exclude = '''
#(
# /(
# | \.git
# | node_modules
# )/
#)
#'''

#[tool.isort]
#line_length = 120
#multi_line_output = 5
#balanced_wrapping = true
#known_django = 'django'
#sections = 'FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER'
#skip = 'node_modules'

[tool.uv]
dev-dependencies = [
"django-debug-toolbar",
"django-stubs",
"django-test-plus",
# importlib-metadata is a dependency of djlint there is a PR to upgrade it in this issue (https://github.com/Riverside-Healthcare/djLint/pull/504) from 5.2.0 to 6.0.0
"djlint",
"ipdb",
"mkdocs-include-markdown-plugin",
"mkdocs-linkcheck",
"mkdocs-material",
"mkdocstrings[python]",
"model-bakery",
"mypy",
"ruff",
"ruff-lsp",
]

[tool.mypy]
# The mypy configurations: https://mypy.readthedocs.io/en/latest/config_file.html
Expand All @@ -46,11 +63,9 @@ plugins = [
"mypy_django_plugin.main",
]


[tool.django-stubs]
django_settings_module = "config.settings.test_runner"


[tool.pytest.ini_options]
addopts = "--nomigrations --ds config.settings.test_runner --cov-config=config/coverage.ini"

Expand Down
Loading