-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Background and Links * Django imports at the top level, like `allowedflare.LoginView`, are problematic because they depend on Django setup ### Changes and Testing * Rename `allowedflare.allowedflare` to `allowedflare.core` for brevity * Drop Django-specific imports from the top level. This is a breaking change. All users will need to update their imports as demonstrated in `demodj/settings.py` * Fix warning for backslash dot in plain string `'\.'` * Improve the example JupyterHub configuration * Upgrade dependencies and move from `requirements.in` to `pyproject.toml` because of issues with the `djangorestframework-stubs[compatible-mypy]` extra seemingly forcing the oldest version to be chosen; the UV docs say "Note extras are not supported with the requirements.in format." * Use uv in the container
- Loading branch information
Showing
18 changed files
with
336 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
jobs: | ||
check: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: source includes.sh && ghas | ||
- run: source includes.sh dcb | ||
# Ideally this would come from default.settings_module() | ||
- run: source includes.sh dcr web python -m pytest --ds=demodj.settings | ||
|
||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: npm | ||
node-version-file: .nvmrc | ||
- run: npm install --frozen-lockfile | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: .python-version | ||
|
||
- run: pip install --upgrade pip uv | ||
env: | ||
PIP_PROGRESS_BAR: 'off' | ||
- run: | | ||
pip install --disable-pip-version-check --progress-bar off --upgrade \ | ||
"$(grep ^uv requirements.txt)" | ||
- run: uv venv | ||
- run: source includes.sh && ups && a && pcam --color always --show-diff-on-failure | ||
- run: .venv/bin/python -m build | ||
- run: .venv/bin/twine check dist/* | ||
- run: .venv/bin/python -m manage check | ||
- run: .venv/bin/python -m manage makemigrations --check | ||
- run: source includes.sh dcb | ||
# Ideally this would come from default.settings_module() | ||
- run: source includes.sh dcr web pytest --ds=demodj.settings | ||
|
||
summarize: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: source includes.sh summarize | ||
|
||
on: # yamllint disable-line rule:truthy | ||
- pull_request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
FROM python:3.12 | ||
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim | ||
|
||
# TODO assert C.UTF8 and PYTHONUNBUFFERED are set correctly | ||
# TODO assert C.UTF8 locale and PYTHONUNBUFFERED are set correctly | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
WORKDIR /srv | ||
RUN --mount=type=cache,target=/root/.cache pip install --upgrade pip-tools wheel | ||
COPY requirements.txt . | ||
RUN --mount=type=cache,target=/root/.cache pip-sync | ||
|
||
# TODO multi-stage for faster development builds? | ||
RUN mkdir -p static | ||
# hadolint ignore=DL3008,SC2046 | ||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
--mount=type=bind,source=includes.sh,target=includes.sh \ | ||
rm /etc/apt/apt.conf.d/docker-clean \ | ||
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "1";' > /etc/apt/apt.conf.d/99cache \ | ||
&& apt-get update \ | ||
&& apt-get install -qq --no-install-recommends --yes nodejs npm \ | ||
$(sed -En 's/"$//; s/^PACKAGES="//p' includes.sh) \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Bind mount caused "EROFS: read-only file system, open '/srv/package-lock.json'" | ||
COPY package-lock.json ./ | ||
RUN --mount=type=cache,target=/root/.npm \ | ||
--mount=type=bind,source=package.json,target=package.json \ | ||
npm install --frozen-lockfile | ||
|
||
COPY . . | ||
# Not using /srv/.venv because it would make volume-mounting /srv harder | ||
ENV UV_COMPILE_BYTECODE=1 | ||
ENV UV_LINK_MODE=copy | ||
ENV UV_SYSTEM_PYTHON=1 | ||
# hadolint ignore=DL3013,DL3042 | ||
RUN --mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,source=requirements.txt,target=requirements.txt \ | ||
uv pip sync --quiet requirements.txt | ||
|
||
COPY . ./ | ||
|
||
ARG STATIC_URL | ||
ENV STATIC_URL ${STATIC_URL:-/static/} | ||
RUN STATIC_URL=${STATIC_URL} python -m manage collectstatic --no-input | ||
RUN mkdir -p static && STATIC_URL=${STATIC_URL} python -m manage collectstatic --no-input | ||
|
||
EXPOSE 8001 | ||
ENV PYTHONUNBUFFERED 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,6 @@ | ||
# TODO Avoid "AppRegistryNotReady: Apps aren't loaded yet." | ||
# To avoid "AppRegistryNotReady: Apps aren't loaded yet." and similar problems, this file must | ||
# only import from the likes of allowedflare.core, not the likes of allowedflare.django. | ||
|
||
from allowedflare.allowedflare import clean_username | ||
from allowedflare.core import authenticate, clean_username | ||
|
||
# Django REST Framework authentication class | ||
from allowedflare.django import Authentication | ||
|
||
# Django Admin authentication backend | ||
from allowedflare.django import Backend | ||
|
||
# Django Admin login view | ||
from allowedflare.django import LoginView | ||
|
||
# SQL Explorer login view wrapper | ||
from allowedflare.django import login_view_wrapper | ||
|
||
__all__ = ( | ||
Authentication.__name__, | ||
Backend.__name__, | ||
LoginView.__name__, | ||
clean_username.__name__, | ||
login_view_wrapper.__name__, | ||
) | ||
__all__ = (authenticate.__name__, clean_username.__name__) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"@jupyterlab/apputils-extension:themes": { | ||
"theme": "JupyterLab Dark" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.