Undertone0809 / P3G

๐Ÿš€Python Packages Project Generator-Your next Python package needs a bleeding-edge project structure.
MIT License
51 stars 6 forks source link

Use Taskfile instead or in addition of Makefile #13

Open Rjdrenth opened 11 months ago

Rjdrenth commented 11 months ago

๐Ÿš€ Feature Request

You mentioned improving the Makefile for windows support. I'd like to suggest using a Taskfile](https://taskfile.dev/) instead of a Makefile, which provides all the functionality of a Makefile and more. It also allows for distinctive commands based on the OS. Another great feature is that it can load .env files.

As an example, see the Taskfile I use in my own cookiecutter template: Taskfile

Undertone0809 commented 11 months ago

I am glad to hear it. It seems more elegant. I will try to learn about it. Thanks for you suggestion!

Undertone0809 commented 10 months ago

There are some problem if we use Taskfile:

I have been research some other solution. The best way to build project may be poetry run xxx. We can use poetry test to test the project and using poetry build to build the project.

All command in poetry means we should not maintain excess files like makefile. So the question is how to run script in poetry. Poetry can only run python script originally, https://github.com/python-poetry/poetry/pull/591 and https://github.com/python-poetry/poetry/issues/241 has talk about it. We can using poe the poet plugin to implement it. A simple example is as follows:

Install poe the poet plugin in poetry

poetry self add poethepoet[poetry_plugin]

Next, write these in pyproject.toml

[tool.poe.tasks]
test = "pytest --cov=poethepoet"                                # command based
mksandwich = { script = "my_package.sandwich:build" }                 # python script based
tunnel = { shell = "ssh -N -L 0.0.0.0:8080:$PROD:8080 $PROD &" }  # shell script based

So we can use the following commands to invoke.

poetry run poe test -v   
poetry run poe tunnel

Add the poetry_command

[tool.poe]
poetry_command = ""

Now we can use poetry test to run test = "pytest --cov=poethepoet".

We can use poe the poet. It can be installed in poetry but it still need learning cost. Makefile seems also a good way to build the project if we make some compatibility in Makefile.