What do you think of having a scripts described in pyproject.toml ? Something like Procfile or script section in packages.json.
Here is a suggestion of configuration & usage:
[tools.poetry.proc]
build = "python manage.py collectstatic"
test = "pytest tests/unit/"
serve = "flask run"
$ poetry proc build
...
$ poetry proc serve
...
I think it would help project to not require Makefile nor tox to share commands and in the same time, ensure commands are properly executed in selected environment.
What do you think of this ?
See https://github.com/python-poetry/poetry/issues/2310 for a broader spec.
@SanketDG I think it's something else.
This has been discussed in #591 which was closed with https://github.com/python-poetry/poetry/pull/591#issuecomment-504762152.
As was stated there, this might be a candidate feature for a plugin once we have that baked into poetry >=v1.1.0.
@abn yes, that's exactly the subject of this PR :-) A plugin is a good fit for this feature.
@bersace in the mean time I'd suggest checking out a project I'm working on that solves this problem in a slightly different way
It provides a flexible system for defining tasks in the pyroject.toml and executing them with a dedicated executable. Basic usage looks like:
Example configuration with different task types:
[tool.poe.tasks]
test = "pytest --cov=poethepoet" # simple command based task
mksandwich = { script = "my_package.sandwich:build" } # python script based task
tunnel = { shell = "ssh -N -L 0.0.0.0:8080:$PROD:8080 $PROD &" } # shell script based task
Example invocation:
# extra argument is passed to the underlying pytest command
poe test -v
# If poethepoet is added as a dev-dependency
poetry run poe tunnel
And it supports zsh command completion!
Most helpful comment
@SanketDG I think it's something else.