Skip to content

Commit

Permalink
Swithch over from pipenv to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisadams committed Oct 6, 2024
1 parent 9298d8c commit f65f033
Show file tree
Hide file tree
Showing 7 changed files with 2,217 additions and 2,602 deletions.
73 changes: 0 additions & 73 deletions Pipfile

This file was deleted.

2,496 changes: 0 additions & 2,496 deletions Pipfile.lock

This file was deleted.

5 changes: 1 addition & 4 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
APPS_DIR = ROOT_DIR / "cl8"
env = environ.Env()

READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False)
if READ_DOT_ENV_FILE:
# OS environment variables take precedence over variables from .env
env.read_env(str(ROOT_DIR / ".env"))
env.read_env(ROOT_DIR / ".env")

# GENERAL
# ------------------------------------------------------------------------------
Expand Down
23 changes: 10 additions & 13 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
Constellate is a Django application, that connects to a Postgres database.
It also relies on a front end toolchain, Tailwind for generating minimal CSS, and on MJML generating the markup for sent emails.

While you can run commands directly, it's also easier to use just for running commands, to avoid needing to remember
While you can run commands directly, it's also easier to use just for running commands, to avoid needing to remember
each invocation. Download it from - https://just.systems

### Setting up your server
### Setting up your server

#### Create or connect to an existing a database

```
createdb yourdatabase_cl8
```

Once you have the database set up, you'll need to list it in your .env file. You should consult .env.sample
Once you have the database set up, you'll need to list it in your .env file. You should consult .env.sample
for explanations of all the settings listed, for now, add the database name into your database connection string like below.

```
Expand All @@ -24,14 +24,14 @@ DATABASE_URL=postgres://localhost:5432/your_database_cl8

### Set up front end toolchains

Constellate uses a toolchain based around Tailwind for generating CSS files for the front end, and MJML to make
Constellate uses a toolchain based around Tailwind for generating CSS files for the front end, and th to make
html emails easier to maintain. Assuming you have a recent version of nodejs installed (18+), you can run the following command

```
just install
```

### Run any migrations
### Run any migrations

You will need to run migrations to set up your blank database

Expand All @@ -42,7 +42,7 @@ just manage migrate
### Run a local server

You can now run a local server. If you're running locally you will want to generate the css needed for your site
using tailwind
using tailwind

```
just tailwind-build
Expand All @@ -60,15 +60,15 @@ Finally, run the django server itself:
just serve
```

### Working with files stored in object storage
### Working with files stored in object storage

Constellate is set up to work with S3-compatible object storage, and in production, the application is assumed to be stateless and disposable, with the important state stored in object storage or the database.

** Working in development **

To make working with files in development easier the AWS CLI is installed in the development dependencies. However to make this work with S3 compatible providers like Scaleway, Digital Ocean, Cloudflare and so on, you need to add two files to the project directory then set two environment variables.

**An aws.config file**
**An aws.config file**

This is needed by the `awscli_plugin_endpoint` python package that makes the aws-cli project work with multiple providers.

Expand Down Expand Up @@ -100,7 +100,7 @@ You can copy the `aws.config.sample` file in this repo to get a head start.

Once this is set up, you set the `AWS_CONFIG_FILE` environment variable to point to the absolute path for this file on your server. Setting this with a `.env` file is convenient for development.

**An aws.credentials file**
**An aws.credentials file**

You then need to do the same for a credentials file, so requests to the object storage service use the correct credentials. Copy the `aws.credentials.sample` file, and add your own credentials from your provider. It should look like so:

Expand All @@ -110,12 +110,10 @@ aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

Set the `AWS_SHARED_CREDENTIALS_FILE` environment variable to point to the absolute path for this file on your server too.

Set the `AWS_SHARED_CREDENTIALS_FILE` environment variable to point to the absolute path for this file on your server too.

Once you have these you should be able to run common AWS S3 commands against your preferred provider:


```shell

# see the buckets available to you
Expand Down Expand Up @@ -149,4 +147,3 @@ DJANGO_AWS_STORAGE_BUCKET_NAME=my-bucket
DJANGO_AWS_S3_REGION_NAME=nl-ams
DJANGO_AWS_S3_ENDPOINT_URL=https://s3.nl-ams.scw.cloud
```

31 changes: 15 additions & 16 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,39 @@
# more intuitive to use
# https://github.com/casey/just


default:
just --list

just --list

@test *options:
pipenv run pytest {{options}}
uv run pytest {{ options }}

@install:
#!/usr/bin/env sh
pipenv install --dev
uv sync
cd theme/static_src/ && npm install && cd ../..
pipenv run ./manage.py migrate
pipenv run ./manage.py collectstatic --no-input
uv run ./manage.py migrate
uv run ./manage.py collectstatic --no-input

@ci:
pipenv run pytest
uv run pytest

@serve *options:
pipenv run ./manage.py runserver {{options}}
uv run ./manage.py runserver {{ options }}

@manage *options:
pipenv run ./manage.py {{options}}
uv run ./manage.py {{ options }}

@tailwind-dev:
pipenv run ./manage.py tailwind start
uv run ./manage.py tailwind start

@tailwind-build:
pipenv run ./manage.py tailwind build
uv run ./manage.py tailwind build

@run *options:
# run gunicorn in production
pipenv run gunicorn config.wsgi --bind :8000 --workers 2 {{options}}
# pipenv run gunicorn config.wsgi -b :9000 --timeout 300 {{options}}
uv run gunicorn config.wsgi --bind :8000 --workers 2 {{ options }}
# pipenv run gunicorn config.wsgi -b :9000 --timeout 300 {{ options }}

@docker-build:
# create a docker image, tagged as cl8
Expand All @@ -47,4 +45,5 @@ default:
docker run --env-file .env -p 8000:8000 -p 5432:5432 cl8

@caddy:
caddy run
# run caddy in the current directory, using the Caddyfile
caddy run
73 changes: 73 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[project]
name = "constellate-cat"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"airtable-python>=0.1.1",
"argon2-cffi>=23.1.0",
"awscli-plugin-endpoint>=0.4",
"awscli>=1.35.0",
"dj-taggit-serializer>=0.1.7",
"django-allauth[socialaccount]==0.63.5",
"django-anymail[mailgun]>=12.0",
"django-autocomplete-light>=3.11.0",
"django-browser-reload>=1.15.0",
"django-cors-headers>=4.4.0",
"django-debug-toolbar>=4.3.0",
"django-environ>=0.11.2",
"django-extensions>=3.2.3",
"django-filter>=23.5",
"django-gravatar2>=1.4.5",
"django-htmx>=1.19.0",
"django-model-utils>=5.0.0",
"django-storages[boto3]>=1.14.4",
"django-stubs>=5.1.0",
"django-taggit-labels>=0.7.0",
"django-taggit>=6.1.0",
"django-tailwind>=3.8.0",
"django-upgrade>=1.21.0",
"django-waffle>=4.1.0",
"django-widget-tweaks>=1.5.0",
"djangorestframework>=3.15.1",
"django~=4.1.0",
"drfpasswordless>=1.5.9",
"gspread>=6.1.3",
"gunicorn>=23.0.0",
"ipdb>=0.13.13",
"markdown-it-py>=3.0.0",
"markdown>=3.7",
"mjml-python>=1.3.3",
"pillow>=10.4.0",
"psycopg2-binary>=2.9.9",
"pyairtable>=2.3.3",
"python-slugify>=8.0.4",
"pytz",
"rich>=13.9.2",
"sentry-sdk>=2.15.0",
"shortuuid>=1.0.13",
"slackclient>=2.9.4",
"sorl-thumbnail==12.10.0",
"typing-extensions>=4.12.2",
"vobject>=0.9.8",
"whitenoise>=6.7.0",
]

[tool.uv]
dev-dependencies = [
"coverage>=7.6.1",
"django-coverage-plugin>=3.1.0",
"djlint>=1.35.2",
"factory-boy>=3.3.1",
"flake8-isort>=6.1.1",
"flake8>=7.1.1",
"mypy>=1.11.2",
"pylint-django>=2.5.5",
"pytest-django>=4.9.0",
"pytest-factoryboy>=2.7.0",
"pytest-mock>=3.14.0",
"pytest-notifier>=1.0.4",
"pytest-sugar>=1.0.0",
"pytest>=8.3.3",
]
Loading

0 comments on commit f65f033

Please sign in to comment.