The Quick Work Environment for Python.
Run commands quickly from the pyproject.toml (or pyqwe.toml) file.
pip install pyqwe
For .env
file support using python-dotenv:
pip install pyqwe[dotenv]
# If zsh install extra using:
pip install 'pyqwe[dotenv]'
See using environment variables for more information.
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"
-- New in 1.8.0 ↓
Commands can be grouped and run together as one. ctrl
+ c
will stop all runners in the group at once.
[tool.pyqwe]
group = [
"flask_app:run",
"*: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.
For Python, the commands are structured like (package &/ module):function
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.
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.
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
.
To run the command as a subprocess shell command, add the shell
key to the command.
[tool.pyqwe]
say_hello = "*shell:echo Hello World"
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"
To use environment variables in the command, use the {{ }}
syntax.
[tool.pyqwe]
talk = "*shell:echo {{MESSAGE}}"
Now running the pyqwe command:
pyqwe talk
Will print the value of the MESSAGE
environment variable.
pyqwe will not look for the .env
file by default. To enable this, install the pyqwe-extra-dotenv
package.
pip install pyqwe-extra-dotenv
or
pip install pyqwe[dotenv]
To stop the behavior of looking for the .env
when using pyqwe, uninstall the pyqwe-extra-dotenv
package.
pip uninstall pyqwe-extra-dotenv
pyqwe
-h
or --help
will display all the commands set in the pyproject.toml file.
pyqwe
__version__
will display the version of pyqwe.