Search code examples
pythonpython-poetrypackage-management

Use poetry to create templated Python projects


Having struggled with Python package management, I have come to like Poetry. I am (mostly) able to use it without issues and installing packages is working well for me.

However, I find myself repeating the same pattern over and over again:

poetry new my_new_package
cd my_new_package
poetry add numpy pandas matplotlib rich ipython black scikit-learn scipy mypy
rm README.rst
touch README.md
git init 

I.e., there are a few packages that I always want installed, I always want to run git init, and I prefer the .md readme over the .rst one.

Oh, and I also change python = "^3.10" to python = "~3.10" in the pyproject.toml.

My wish is that I can do something like poetry from template pyproject.toml instead of all of the above. Now I get that, if I just run poetry install pyproject.toml with the pyproject.toml file from above, poetry would install all packages. But it would not create the folder structure, the readme, the git folders, etc.

Question: Is there a way to achieve what I want? Ideally, I could also have a dynamic project name, e.g. poetry from template pyproject.toml my_other_project. Is this possible with poetry? Or am I just using the wrong tool?

Thanks in advance!


Solution

  • This kind of flexibility is out of scope for Poetry. Use cookiecutter instead.