Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
47 changes: 22 additions & 25 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ concurrency:
env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
UV_LOCKED: 1

jobs:
validate:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -48,24 +50,19 @@ jobs:
- name: Create cache file
run: echo '${{ matrix.python-version }}' > ./matrix-file.txt

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: ${{ matrix.python-version }}
allow-python-prereleases: false
cache: true
cache-dependency-path: |
./pdm.lock
./matrix-file.txt
- name: Install uv
uses: astral-sh/setup-uv@v4
version: "0.5.10"
enable-cache: true

- name: Install base libraries
run: pip install nodeenv cython setuptools pip --upgrade --quiet --user

- name: Install dependencies
run: pdm install -G:all
run: uv sync --all-groups

- name: Test with Coverage
run: pdm run pytest tests --cov=app --cov-report=xml
run: uv run pytest tests --cov=app --cov-report=xml

- if: matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
Expand All @@ -87,18 +84,16 @@ jobs:
with:
python-version: "3.11"

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: "3.11"
allow-python-prereleases: false
cache: true
- name: Install uv
uses: astral-sh/setup-uv@v4
version: "0.5.10"
enable-cache: true

- name: Install dependencies
run: pdm install -G:all
run: uv sync --all-groups

- name: Build docs
run: pdm run make docs
run: uv run make docs

- name: Save PR number
env:
Expand Down Expand Up @@ -127,12 +122,14 @@ jobs:
uses: actions/checkout@v4
- name: Install base libraries
run: pip install nodeenv cython setuptools pip --upgrade --quiet --user
- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: "3.11"
cache: true

- name: Install uv
uses: astral-sh/setup-uv@v4
version: "0.5.10"
enable-cache: true

- name: Install dependencies
run: pdm install -G:all
run: uv sync --all-groups

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
19 changes: 10 additions & 9 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- main

env:
UV_LOCKED: 1

jobs:
docs:
permissions:
Expand All @@ -19,25 +22,23 @@ jobs:
with:
python-version: "3.11"

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: "3.11"
allow-python-prereleases: true
cache: true
- name: Install uv
uses: astral-sh/setup-uv@v4
version: "0.5.10"
enable-cache: true

- name: Install dependencies
run: pdm install -G:all
run: uv sync --all-groups

- name: Fetch gh pages
run: git fetch origin gh-pages --depth=1

- name: Build release docs
run: pdm run python scripts/build-docs.py docs-build
run: uv run python scripts/build-docs.py docs-build
if: github.event_name == 'release'

- name: Build dev docs
run: pdm run python scripts/build-docs.py docs-build
run: uv run python scripts/build-docs.py docs-build
if: github.event_name == 'push'

- name: Deploy
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Setting up the environment
--------------------------

1. Install `Pizza Delivery Man <https://pdm.fming.dev/latest/>`_
2. Run ``pdm install -G:all`` to create a `virtual environment <https://docs.python.org/3/tutorial/venv.html>`_ and install
2. Run ``uv sync --all-groups`` to create a `virtual environment <https://docs.python.org/3/tutorial/venv.html>`_ and install
the dependencies
3. If you're working on the documentation and need to build it locally, install the extra dependencies with ``pdm install -G:docs``
3. If you're working on the documentation and need to build it locally, install the extra dependencies with `` uv sync --group docs``
4. Install `pre-commit <https://pre-commit.com/>`_
5. Run ``pre-commit install`` to install pre-commit hooks

Expand Down Expand Up @@ -57,7 +57,7 @@ To run or build the docs locally, you need to first install the required depende

.. code-block:: console

pdm install -G:docs
uv sync --group docs

Then you can serve the documentation with ``make docs-serve``, or build them with ``make docs``

Expand Down
56 changes: 18 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ SHELL := /bin/bash

.DEFAULT_GOAL:=help
.ONESHELL:
USING_PDM = $(shell grep "tool.pdm" pyproject.toml && echo "yes")
USING_NPM = $(shell python3 -c "if __import__('pathlib').Path('package-lock.json').exists(): print('yes')")
ENV_PREFIX =.venv/bin/
VENV_EXISTS = $(shell python3 -c "if __import__('pathlib').Path('.venv/bin/activate').exists(): print('yes')")
NODE_MODULES_EXISTS = $(shell python3 -c "if __import__('pathlib').Path('node_modules').exists(): print('yes')")
SRC_DIR =src
BUILD_DIR =dist
PDM_OPTS ?=
PDM ?= pdm $(PDM_OPTS)

.EXPORT_ALL_VARIABLES:

Expand All @@ -30,43 +26,20 @@ help: ## Display this help text for Makefile
.PHONY: upgrade
upgrade: ## Upgrade all dependencies to the latest stable versions
@echo "=> Updating all dependencies"
@if [ "$(USING_PDM)" ]; then $(PDM) update; fi
@uv lock --upgrade
@echo "=> Python Dependencies Updated"
@if [ "$(USING_NPM)" ]; then npm upgrade --latest; fi
@echo "=> Node Dependencies Updated"
@$(ENV_PREFIX)pre-commit autoupdate
@echo "=> Updated Pre-commit"

.PHONY: uninstall
uninstall:
@echo "=> Uninstalling PDM"
ifeq ($(OS),Windows_NT)
@echo "=> Removing PDM from %APPDATA%\Python\Scripts"
@if exist "%APPDATA%\Python\Scripts\pdm" (del "%APPDATA%\Python\Scripts\pdm")
else
@echo "=> Removing PDM from ~/.local/bin"
@rm -f ~/.local/bin/pdm
endif
@echo "=> PDM removal complete"
@echo "=> Uninstallation complete!"

# =============================================================================
# Developer Utils
# =============================================================================
install-pdm: ## Install latest version of PDM
@curl -sSLO https://pdm.fming.dev/install-pdm.py && \
curl -sSL https://pdm.fming.dev/install-pdm.py.sha256 | shasum -a 256 -c - && \
python3 install-pdm.py

install: ## Install the project and
@if ! $(PDM) --version > /dev/null; then echo '=> Installing PDM'; $(MAKE) install-pdm; fi
@if [ "$(VENV_EXISTS)" ]; then echo "=> Removing existing virtual environment"; fi
if [ "$(VENV_EXISTS)" ]; then $(MAKE) destroy-venv; fi
if [ "$(VENV_EXISTS)" ]; then $(MAKE) clean; fi
@uv sync
@if [ "$(NODE_MODULES_EXISTS)" ]; then echo "=> Removing existing node modules"; fi
if [ "$(NODE_MODULES_EXISTS)" ]; then $(MAKE) destroy-node_modules; fi
@if [ "$(USING_PDM)" ]; then $(PDM) config venv.in_project true && python3 -m venv --copies .venv && . $(ENV_PREFIX)/activate && $(ENV_PREFIX)/pip install --quiet -U wheel setuptools cython pip mypy nodeenv; fi
@if [ "$(USING_PDM)" ]; then $(PDM) install -G:all; fi
@echo "=> Install complete! Note: If you want to re-install re-run 'make install'"


Expand Down Expand Up @@ -105,17 +78,24 @@ migrate: ## Generate database migrations
.PHONY: build
build:
@echo "=> Building package..."
@if [ "$(USING_PDM)" ]; then pdm build; fi
@uv build
@echo "=> Package build complete..."

.PHONY: refresh-lockfiles
refresh-lockfiles: ## Sync lockfiles with requirements files.
@pdm update --update-reuse --group :all

.PHONY: lock
lock: ## Rebuild lockfiles from scratch, updating all dependencies
@pdm update --update-eager --group :all
@uv lock

start-infra:
docker compose -f docker-compose.infra.yml up --force-recreate -d

stop-infra:
docker compose -f docker-compose.infra.yml down --remove-orphans

post_install:
uv run python scripts/pre-build.py --install-packages

pre_build:
uv run python scripts/pre-build.py --build-assets
# =============================================================================
# Tests, Linting, Coverage
# =============================================================================
Expand Down Expand Up @@ -151,7 +131,7 @@ test: ## Run the tests
.PHONY: docs-install
docs-install: ## Install docs dependencies
@echo "=> Installing documentation dependencies"
@$(PDM) install -dG:docs
@uv sync --group docs
@echo "=> Installed documentation dependencies"

docs-clean: ## Dump the existing built docs
Expand All @@ -161,8 +141,8 @@ docs-clean: ## Dump the existing built docs

docs-serve: docs-clean ## Serve the docs locally
@echo "=> Serving documentation"
$(PDM_RUN_BIN) sphinx-autobuild docs docs/_build/ -j auto --watch src --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002
$uv run sphinx-autobuild docs docs/_build/ -j auto --watch src --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002

docs: docs-clean ## Dump the existing built docs and rebuild them
@echo "=> Building documentation"
@$(PDM_RUN_BIN) sphinx-build -M html docs docs/_build/ -E -a -j auto --keep-going
@uv run sphinx-build -M html docs docs/_build/ -E -a -j auto --keep-going
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ make install

```bash
cp .env.local.example .env
pdm run start-infra # this starts a database and redis instance only
make start-infra # this starts a database and redis instance only
# this will start the SAQ worker, Vite development process, and Litestar
pdm run app run
uv run app run

# to stop the database and redis, run
pdm run stop-infra
make stop-infra
```

### Docker
Expand Down
12 changes: 6 additions & 6 deletions deploy/docker/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ RUN apt-get update \
## ------------------------- Python build base -------------------------------------- ##
## ---------------------------------------------------------------------------------- ##
FROM python-base AS build-base
ARG PDM_INSTALL_ARGS="-G:all"
ENV PDM_INSTALL_ARGS="${PDM_INSTALL_ARGS}" \
ARG UV_INSTALL_ARGS="--all-groups"
ENV UV_INSTALL_ARGS="${UV_INSTALL_ARGS}" \
GRPC_PYTHON_BUILD_WITH_CYTHON=1 \
PATH="/workspace/app/.venv/bin:/usr/local/bin:$PATH"
## -------------------------- add build packages ----------------------------------- ##
Expand All @@ -45,16 +45,16 @@ RUN apt-get install -y --no-install-recommends build-essential curl \

## -------------------------- install application ----------------------------------- ##
WORKDIR /workspace/app
COPY pyproject.toml pdm.lock README.md .pre-commit-config.yaml LICENSE Makefile \
COPY pyproject.toml uv.lock README.md .pre-commit-config.yaml LICENSE Makefile \
package.json package-lock.json vite.config.ts tsconfig.json tsconfig.node.json \
tailwind.config.cjs postcss.config.cjs components.json \
./
COPY scripts ./scripts/
COPY public ./public/
COPY resources ./resources/
RUN python -m venv --copies /workspace/app/.venv \
&& /workspace/app/.venv/bin/pip install cython pdm nodeenv \
&& pdm install ${PDM_INSTALL_ARGS} --no-self
&& /workspace/app/.venv/bin/pip install cython uv nodeenv \
&& uv install ${UV_INSTALL_ARGS}
COPY src ./src/

## ---------------------------------------------------------------------------------- ##
Expand Down Expand Up @@ -82,7 +82,7 @@ WORKDIR /workspace/app
COPY docs/ docs/
COPY tests/ tests/
COPY src src/
RUN pdm install $PDM_INSTALL_ARGS
RUN uv install $UV_INSTALL_ARGS
STOPSIGNAL SIGINT
EXPOSE 8000
ENTRYPOINT ["tini","--" ]
Expand Down
14 changes: 7 additions & 7 deletions deploy/docker/run/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ RUN apt-get update \
## ------------------------- Python build base -------------------------------------- ##
## ---------------------------------------------------------------------------------- ##
FROM python-base AS build-base
ARG PDM_INSTALL_ARGS=""
ENV PDM_INSTALL_ARGS="${PDM_INSTALL_ARGS}" \
ARG UV_INSTALL_ARGS=""
ENV UV_INSTALL_ARGS="${UV_INSTALL_ARGS}" \
GRPC_PYTHON_BUILD_WITH_CYTHON=1 \
PATH="/workspace/app/.venv/bin:/usr/local/bin:$PATH"
## -------------------------- add build packages ----------------------------------- ##
Expand All @@ -45,19 +45,19 @@ RUN apt-get install -y --no-install-recommends build-essential curl \

## -------------------------- install application ----------------------------------- ##
WORKDIR /workspace/app
COPY pyproject.toml pdm.lock README.md .pre-commit-config.yaml LICENSE Makefile \
COPY pyproject.toml uv.lock README.md .pre-commit-config.yaml LICENSE Makefile \
package.json package-lock.json vite.config.ts tsconfig.json tsconfig.node.json \
tailwind.config.cjs postcss.config.cjs components.json \
./
COPY scripts ./scripts/
COPY public ./public/
COPY resources ./resources/
RUN python -m venv --copies /workspace/app/.venv \
&& /workspace/app/.venv/bin/pip install --quiet pdm nodeenv cython \
&& pdm install ${PDM_INSTALL_ARGS} --no-self \
&& pdm export ${PDM_INSTALL_ARGS} --without-hashes --prod --output=requirements.txt
&& /workspace/app/.venv/bin/pip install --quiet uv nodeenv cython \
&& uv install ${UV_INSTALL_ARGS} \
&& uv export ${UV_INSTALL_ARGS} --no-hashes --no-dev --output-file=requirements.txt
COPY src ./src/
RUN pdm build
RUN uv build


## ---------------------------------------------------------------------------------- ##
Expand Down
Loading
Loading