Skip to content

Commit

Permalink
Update to use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
dansahagian committed Sep 14, 2024
1 parent 1c9bc1f commit f11d834
Show file tree
Hide file tree
Showing 18 changed files with 663 additions and 705 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
10 changes: 5 additions & 5 deletions bin/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ run_command() {

echo -e "\nLinting and Formatting 🐍 ...\n"

run_command "linting" .venv/bin/ruff check .
run_command "imports" .venv/bin/ruff check --select I
run_command "format" .venv/bin/ruff format --check
run_command "linting" ruff check .
run_command "imports" ruff check --select I
run_command "format" ruff format --check

echo -e "\nRunning Tests 🧪...\n"

run_command "tests" .venv/bin/pytest -p no:warnings .
run_command "tests" uv run pytest -p no:warnings .

echo "\nDeploying...\n"

rsync -a ./fbsurvivor dan@linode:/opt/fbsurvivor
rsync -a ./requirements dan@linode:/opt/fbsurvivor
rsync -a ./pyproject.toml dan@linode:/opt/fbsurvivor
rsync -a ./manage.py dan@linode:/opt/fbsurvivor
rsync -a ./bin dan@linode:/opt/fbsurvivor
rsync -a ./prod.env dan@linode:/opt/fbsurvivor/.env
Expand Down
9 changes: 4 additions & 5 deletions bin/deploy-on-server
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

echo "\nInstalling Dependencies...\n"
cd /opt/fbsurvivor
.venv/bin/uv pip install --upgrade pip
.venv/bin/uv pip sync requirements/prod.txt
/home/dan/.cargo/bin/uv sync

echo "\nStopping services...\n"
sudo systemctl stop wsgi-server-fbsurvivor.service

.venv/bin/python manage.py migrate
.venv/bin/python manage.py collectstatic --no-input
.venv/bin/python manage.py check --deploy
/home/dan/.cargo/bin/uv run python manage.py migrate
/home/dan/.cargo/bin/uv run python manage.py collectstatic --no-input
/home/dan/.cargo/bin/uv run python manage.py check --deploy

echo "\nStarting services...\n"
sudo systemctl start wsgi-server-fbsurvivor.service
Expand Down
2 changes: 0 additions & 2 deletions bin/restart-service
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/zsh

rsync -a ./prod.env dan@linode:/opt/fbsurvivor/.env

echo "\nStopping services...\n"
ssh linode sudo systemctl stop wsgi-server-fbsurvivor.service

Expand Down
5 changes: 0 additions & 5 deletions dev/create-virtualenv

This file was deleted.

6 changes: 3 additions & 3 deletions dev/format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/zsh
#!/usr/bin/env sh

.venv/bin/ruff check --select I --fix
.venv/bin/ruff format
ruff check --select I --fix
ruff format
4 changes: 2 additions & 2 deletions dev/init-db → dev/initialize-db
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/zsh
#!/usr/bin/env sh

ssh dan@linode "pg_dump -U fbsurvivor2 fbsurvivor2 > /tmp/fbsurvivor_dump"
scp dan@linode:/tmp/fbsurvivor_dump ~/d/code/dansahagian/fbsurvivor/tmp/fbsurvivor_dump
Expand All @@ -14,4 +14,4 @@ psql -U postgres -d postgres -c "GRANT ALL ON DATABASE fbsurvivor2 to fbsurvivor
psql -U postgres -d fbsurvivor2 -c "DROP SCHEMA IF EXISTS public;"
psql -U postgres -d fbsurvivor2 -c "CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION fbsurvivor2;"

psql fbsurvivor2 < ~/d/code/dansahagian/fbsurvivor/tmp/fbsurvivor_dump
psql fbsurvivor2 < ~/d/code/dansahagian/fbsurvivor/tmp/fbsurvivor_dump
6 changes: 6 additions & 0 deletions dev/initialize-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

rm -rf .venv
uv venv
uv sync
pre-commit install
4 changes: 0 additions & 4 deletions dev/sync-dependencies

This file was deleted.

4 changes: 0 additions & 4 deletions dev/update-requirements

This file was deleted.

29 changes: 28 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
[project]
name = "fbsurvivor"
version = "3.0"
description = "Run an NFL Survivor Pool"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"arrow>=1.3.0",
"django>=5.1.1",
"django-extensions>=3.2.3",
"django-htmlmin>=0.11.0",
"pyjwt>=2.9.0",
"python-decouple>=3.8",
"requests>=2.32.3",
"gunicorn>=23.0.0",
"sentry-sdk[django]==2.12.0",
"psycopg[c]>=3.2.1",
]

[tool.uv]
dev-dependencies = [
"django-debug-toolbar>=4.4.6",
"factory-boy>=3.3.1",
"ipython>=8.27.0",
"pytest>=8.3.3",
"pytest-django>=4.9.0",
]

[tool.ruff]
line-length = 99
target-version = "py312"
Expand All @@ -6,7 +34,6 @@ target-version = "py312"
quote-style = "double"
indent-style = "space"
docstring-code-format = true

exclude = [
".git",
".pytest_cache",
Expand Down
453 changes: 0 additions & 453 deletions requirements/dev.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements/in/base.in

This file was deleted.

9 changes: 0 additions & 9 deletions requirements/in/dev.in

This file was deleted.

3 changes: 0 additions & 3 deletions requirements/in/prod.in

This file was deleted.

200 changes: 0 additions & 200 deletions requirements/prod.txt

This file was deleted.

2 changes: 1 addition & 1 deletion server-config/run-wsgi-server-fbsurvivor
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ DATE=`date '+%Y-%m-%d %H:%M:%S'`
echo "fbsurvivor wsgi started at ${DATE}" | systemd-cat -p info

cd /opt/fbsurvivor
DJANGO_SETTINGS_MODULE=fbsurvivor.settings /opt/fbsurvivor/.venv/bin/python -m gunicorn fbsurvivor.wsgi
DJANGO_SETTINGS_MODULE=fbsurvivor.settings uv run python -m gunicorn fbsurvivor.wsgi
Loading

0 comments on commit f11d834

Please sign in to comment.