I found that python can use pyproject.toml to list dependencies instead of requirements.txt file. It's more convenient and is very similar to package.json for node.However, I could not find a documentation to init the pyproject.toml file much like the npm init
command. How to autogenerate the file with virtualenv or pip?
also, is there a way to autoupdate the toml file, as the packagaes get installed, much like npm --save tag, that saves the package to the package.json as its installed?
How to init the pyproject.toml file
Asked Answered
Look at poetry. It can do it for you nicely. Actually I think its the only project that handles this already that I know of.
Yeah, the toml files are not natively supported by python –
Confectionery
TOML is now natively supported in Python (as of 3.11). :-) An alternative to poetry that has full support for the
pyproject.toml
file is pdm: pdm.fming.dev/latest –
Perseid © 2022 - 2024 — McMap. All rights reserved.
poetry init
in the project root dir, answer the questions, done. – Eucharistpoetry
is one of them, so isflit
, and a bunch of others. Some can cohabit peacefully, some might not. From the details in your question,poetry
might be indeed a strong candidate, but it has its own quirks and limitations, so you have to make sure it is what you want to buy. But really apyproject.toml
is just 2 or 3 lines (the[build-system]
section) as per the specification @Dimorph linked to in its comment. Every other section in that file is most likely specific to a tool and non standard. – Buoyantcookiecutter
somewhere that allows you to choose a build-system (poetry, filt, setuptools, etc.) interactively and populate thepyproject.toml
accordingly. – Buoyant