Skip to main content

Work library for Plain

Project description

plain-dev

A single command to run everything you need for local Plain development.

Plain work command example

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

View on YouTube →

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plain_dev-0.0.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

plain_dev-0.0.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file plain_dev-0.0.0.tar.gz.

File metadata

  • Download URL: plain_dev-0.0.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.5.0

File hashes

Hashes for plain_dev-0.0.0.tar.gz
Algorithm Hash digest
SHA256 18941b06e0019dd4a899d86c512e6be036b01e173509843f16f4d7617842e246
MD5 9cbf78cf64ce660a15bb8c8b2d283f10
BLAKE2b-256 dc1444d6f8249f570abdf8f8db994a5e13ca8e77ec28612e3e32138d4f438348

See more details on using hashes here.

File details

Details for the file plain_dev-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: plain_dev-0.0.0-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

Hashes for plain_dev-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8917f0639acf7d61c66714d774c23421f685a285b89caf7abb99b95a2011152
MD5 7c72306a045c53e92002707ff50d9f81
BLAKE2b-256 6178c7e8f0a6e4138310c1e7eb0096f3dfff57694ba40d476d0e3e726556d381

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page