Run commands quickly from the pyproject.toml (or pyqwe.toml) file.
Project description
🏎️💨 pyqwe
The Quick Work Environment for Python.
Run commands quickly from the pyproject.toml (or pyqwe.toml) file.
pip install pyqwe
-- New in 2.1.x ↓
Advanced environment variable functionality Using environment variables.
Usage
Add commands to the pyproject.toml or pyqwe.toml file.
[tool.pyqwe]
flask = "flask_app:run"
say_hello = "*:echo Hello World"
If you're using a pyqwe.toml file you can drop the [tool.pyqwe]
flask = "flask_app:run"
say_hello = "*:echo Hello World"
🚨 NOTE 🚨
If you have both a pyproject.toml and a pyqwe.toml file, the pyqwe.toml file will be used and the pyproject.toml file will be ignored.
You will be able to see what commands you have set in the pyproject.toml file by running:
pyqwe list
# or
pyqwe ls
You can run the commands by using the command name:
pyqwe flask
Running pyqwe without any option or command will show all available commands in a menu you can choose from.
pyqwe
🚥|🏎️
0 : Exit
1 : flask
2 : say_hello
Select a command to run [0]:
Choosing 1 will run the flask command.
Python commands
For Python, the commands are structured like (package &/ module):function
Package example
project/
flask_app/
__init__.py
[tool.pyqwe]
flask = "flask_app:run"
This command will run the function
run() from the __init__.py file in the flask_app package.
Module example
project/
app.py
[tool.pyqwe]
flask = "app:run"
This command will run the function
run() from the app.py file.
Now run the pyqwe command:
pyqwe flask
This will start the Flask app.
*:... commands (terminal)
Any command that starts with * will be run using subprocess.
For example:
[tool.pyqwe]
say_hello = "*:echo Hello World"
Now running the pyqwe command:
pyqwe say_hello
Will print Hello World.
Run as shell
To run the command as a subprocess shell command, add the shell key to the command.
[tool.pyqwe]
say_hello = "*shell:echo Hello World"
Change the working directory
You can change the working directory of a subprocess by adding the folder
within parentheses to the command, (node_app) for example.
The folder must be relative to the pyproject.toml file.
Absolute paths are not supported.
Moving up directories is not supported, ../node_app for example.
[tool.pyqwe]
npm_install = "*(node_app):npm install"
The shell key is still available when changing the directory.
[tool.pyqwe]
npm_install = "*shell(node_app):npm i"
Grouped commands
You can group commands together in a list to have one pyqwe command run multiple commands.
Grouped commands can also be run in Step, Sync, or Async mode. Async being the default.
This will run the commands in the group in sequence, pausing for confirmation between each command:
[tool.pyqwe]
group = [
"@step",
"*:echo 'Hello, World! 1'",
"*:echo 'Hello, World! 2'",
"*:echo 'Hello, World! 3'"
]
This will run the commands in the group in sequence, one after the other:
[tool.pyqwe]
group = [
"@sync",
"*:echo 'Hello, World! 1'",
"*:echo 'Hello, World! 2'",
"*:echo 'Hello, World! 3'"
]
This will run the commands in the group in parallel:
[tool.pyqwe]
group = [
"@async",
"*:echo 'Hello, World! 1'",
"*:echo 'Hello, World! 2'",
"*:echo 'Hello, World! 3'"
]
Of course, you can leave out the @step, @sync or @async to use the default async mode.
For example, this will also run the commands in the group in parallel:
[tool.pyqwe]
group = [
"*:echo 'Hello, World! 1'",
"*:echo 'Hello, World! 2'",
"*:echo 'Hello, World! 3'"
]
Using environment variables
To use environment variables in the command, use the {{ }}
markers, these markers are the default but can be changed.
pyqwe will evaluate any environment variables that are set before running any commands.
If pyqwe detects an environment variable that is not set, it will raise an error. An error will
also be raised if environment variables are detected, and you do not have python-dotenv installed.
Here's an example of setting an environment variable in a command:
[tool.pyqwe]
talk = "*shell:echo {{MESSAGE}}"
You can change the environment variable markers by changing the __env_marker_start__ and __env_marker_end__ settings
keys.
[tool.pyqwe]
__env_marker_start__ = "*"
__env_marker_end__ = "*"
talk = "*shell:echo *MESSAGE*"
pyqwe uses load_dotenv() from python-dotenv to load the .env file. You can change the name of the file to load, or
add multiple env files by setting the __env_files__ settings key.
[tool.pyqwe]
__env_files__ = [".env", ".env.local"]
talk = "*shell:echo *MESSAGE*"
This is the same as running load_dotenv(".env") and load_dotenv(".env.local").
If you want to disable pyqwe from doing anything with environment variables, you can set the __env_ignore__ settings
key to true.
[tool.pyqwe]
__env_ignore__ = true
talk = "*shell:echo {{MESSAGE}}"
This will disable the environment variable evaluation and loading of the .env file, and result in {{MESSAGE}} being
printed to the console in this case.
Other commands
pyqwe -h or --help will display help information.
pyqwe --version or -v will display the version of pyqwe.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyqwe-2.1.0.tar.gz.
File metadata
- Download URL: pyqwe-2.1.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b98edf82bcb675b3a3c1798cc4e68b56f577dc6765ba03e2f3ea08f610f703a
|
|
| MD5 |
272bad7b82a8c537b36b2d91ba2f68fe
|
|
| BLAKE2b-256 |
cc17d2c4913a72af949536fa1b492ebc6c32e3c97c786f722d73dd8445c4bab1
|
File details
Details for the file pyqwe-2.1.0-py3-none-any.whl.
File metadata
- Download URL: pyqwe-2.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c97203974f1a016b8bd9e8668a648450a950059530983af7dc0ede8f4b73f1a
|
|
| MD5 |
568354c79278a89e204dbd46d5d5547c
|
|
| BLAKE2b-256 |
5120b7b4fc7101ae3fb2eeaac23ce0087cea0cbf81acb05f042e9030494cda44
|