Skip to main content

An interface for managing playground projects.

Project description

playgroundtools

PyPI PyPI - Python Version Test Code style: black

An interface for managing playground projects.

Overview

This package is intended to provide a quick and easy way to set up Python "projects," each containing their own files, folders, virtual environment, and installed packages. This also includes the ability to run these projects (called playgrounds) and delete them. This can be done either through the CLI or through the interactive GUI (with limited capabilities). The exact configuration for the creation and execution of these playgrounds are found here, in the package's configuration file.

For example, creating an api playground results in the following file structure:

playground
│   .env
│   main.py
│   reset.py
│   settings.json
│
├───.venv
│       ...
│
├───api
│       config.py
│       crud.py
│       database.py
│       deps.py
│       models.py
│       schemas.py
│       __init__.py
│
└───requirements
        requirements.in

Commands

new: Creates a playground.

$ playground new [-h] [-i LIB [LIB ...]] [-v] -n NAME type

For example, to create an api project:

# We can specify a list of optional packages to install via pip by using the `-i` option
$ playground new api -n my_api -i requests -v  # verbosity can be set with the -v option

run: Runs a playground.

$ playground run [-h] [-m MODULE] [-a ARGS [ARGS ...]] name

For example:

$ playground run console_app

delete: Deletes a playground.

$ playground delete [-h] name

For example:

$ playground delete jupyter_tests

config: Reads or modifies the configuration.

$ playground config [-h] [-k READ] {add,delete,edit}

For example:

$ playground config edit api.folders "[\"api\", \"api/routers\"]"

Graphical User Interface

Invoking playground-gui will open the interactive GUI, allowing for the creation and deletion of playgrounds.

Playground Settings

Settings for a playground can be configured via its settings.json file. The available options are:

  • python: a path that points to the Python installation used to run the playground.
  • module: the module to run (by invocation of -m {module})
  • args: the arguments to pass to the module (-m {module} {args ...})

Configuration

To configure the installation of playgroundtools, utilize the config command in the CLI or manually edit the config.json file.

The available options are:

  • folders: a list of folders that should be placed inside the playground upon creation.
  • files: maps file names to lists containing the contents of the file by line.
  • lib: the packages to be installed upon creation of the playground.
  • module: the module to run when the playground is executed via -m {module}.
  • args: the arguments to pass to the module upon execution (-m {module} {args ...}).

Using the CLI

config add: Adds a new playground type to the configuration.

$ playground config add [-h] [-t TYPE] [-v VALUE] [-f FILE]

For example:

$ playground config add "package" "{\"folders\": [\"src\"], \"files\": {\"setup.cfg\": []}...}"

Configuration can also be added from a custom JSON file:

$ playground config add -f user_config.json

config delete: Deletes a playground type from the configuration.

$ playground config delete [-h] [-t TYPE] [-f FILE]

For example:

$ playground config delete "package"

Keys from a custom config file can also be deleted:

$ playground config delete -f user_config.json

config edit: Modifies an existing key in the configuration.

$ playground config edit [-h] key value

For example:

$ playground config edit "api.folders" "[\"api\", \"api/routers\", \"api/db\"]"

Using JSON

The config.json file simply contains configurations for different types of playgrounds. The settings for each type are specified by the available options aforementioned.

For example, to create a package type, one could use:

{
    // ...
    "package": {
        "folders": [
            "src",
            "tests"
        ],
        "files": {
            "setup.cfg": [
                // File contents go here...
            ],
            "pyproject.toml": [
                // File contents go here...
            ],
            "setup.py": [
                // File contents go here...
            ]
        },
        "lib": [
            "setuptools",
            "black",
            "flake8",
            "isort",
            "build",
            "twine"
        ],
        "module": "",
        "args": []
    }
}

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

playgroundtools-1.7.0.tar.gz (20.2 kB view hashes)

Uploaded Source

Built Distribution

playgroundtools-1.7.0-py3-none-any.whl (23.6 kB view hashes)

Uploaded Python 3

Supported by

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