Work library for Plain
Project description
plain-dev
A single command to run everything you need for local Plain development.
The plain dev
command runs a combination of local commands + a Docker container for your database.
The following processes will run simultaneously (some will only run if they are detected as available):
Installation
pip install plain-dev
If you have plain-models
installed (i.e. you're using a database),
then add DATABASE_URL
to your .env
file.
DATABASE_URL=postgres://postgres:postgres@localhost:54321/postgres
# pyproject.toml
[tool.plain.dev.services]
postgres = {cmd = "docker run --name app-postgres --rm -p 54321:5432 -v $(pwd)/.plain/dev/pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=postgres postgres:15 postgres"}
plain dev
plain dev
Default processes
- plain preflight
- gunicorn
- migrations
- tailwind
Custom processes
- package.json "dev" script
- pyproject.toml
tool.plain.dev.run = {command = "..."}
GitHub Codespaces
The BASE_URL
setting is automatically set to the Codespace URL.
TODO
plain dev db
Only supports Postgres currently.
- snapshot
- import
- export
Development processes
Gunicorn
The key process here is still manage.py runserver
.
But, before that runs, it will also wait for the database to be available and run manage.py migrate
.
plain-models
If plain-models
is installed, it will automatically start and show the logs of the running database container.
plain-tailwind
If plain-tailwind
is installed, it will automatically run the Tailwind compile --watch
process.
Debugging
Since plain work
runs multiple processes at once, the regular pdb debuggers can be hard to use.
Instead, we include microsoft/debugpy and an attach
function to make it even easier to use VS Code's debugger.
First, import and run the debug.attach()
function:
class HomeView(TemplateView):
template_name = "home.html"
def get_context(self, **kwargs):
context = super().get_context(**kwargs)
# Make sure the debugger is attached (will need to be if runserver reloads)
from plain.work import debug; debug.attach()
# Add a breakpoint (or use the gutter in VSCode to add one)
breakpoint()
return context
When you load the page, you'll see "Waiting for debugger to attach...".
Add a new VS Code debug configuration (using localhost and port 5768) by saving this to .vscode/launch.json
or using the GUI:
// .vscode/launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Plain: Attach to Django",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
],
"justMyCode": true,
"django": true
}
]
}
Then in the "Run and Debug" tab, you can click the green arrow next to "Plain: Attach to Django" to start the debugger.
In your terminal is should tell you it was attached, and when you hit a breakpoint you'll see the debugger information in VS Code. If Django's runserver reloads, you'll be prompted to reattach by clicking the green arrow again.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file plain_dev-0.0.1.tar.gz
.
File metadata
- Download URL: plain_dev-0.0.1.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5103d67c6afa8053f3bfe4c65ae56632bff5bc336700127676c32155eed7db4 |
|
MD5 | 70879fc34e8079a608499314d020c72f |
|
BLAKE2b-256 | 0ce63a16423a3252a7873335f49f1047c6525329e74f227b6b141bc0354ca8c8 |
File details
Details for the file plain_dev-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: plain_dev-0.0.1-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b58804f829e36e0ad02b948db4800d29603177c6e60d52a5e30d2dc399aa855 |
|
MD5 | 5ba9c371128f9dab4fe8c2a9eb3e8583 |
|
BLAKE2b-256 | 3275f301805b1df29aa4a5f5ff4b951041c07382487a16015437b516ae4d94c2 |