Recommended new project workflow using pyproject.toml and

Hello Everyone,

I have been using python for a while. I also “live” a workflow with an existing project.

However, I’m about to start a new project to test some data processing tasks. I’m a big fan of pyproject.toml to configure setuptools. I also use asdf to create a virtual env. All this means, no more use of requirements.txt nor Pipfile.

That all said, I’ve gotten used to initializing a new project using some sort of tool (e.g., Rust’s cargo or CRA). What is an efficient way to get a local project “up-and-running” in python?

I typically just copy and paste old configs/other’s configs, so I am not familiar with the tools around. The one I hear the most about is Poetry, and I think it does the whole project setup thing. You can check it out and see 8f it works for you while you wait for someone more informed to answer you question.

1 Like

The “official” documentation on this currently lives at Packaging Python Projects — Python Packaging User Guide which avoids choosing one tool over another. Between the mentioned Hatchling, setuptools, Flit and PDM, all of them (except setuptools) come with a CLI to create skeletons and manage the file.

The main difference between them (as far as I can tell) is the CLI tool’s UI and interface - the pyproject.toml file they each generate should be compatible (following the relevant PEPs) and laregely identical (except the [build-system] section).

It also shouldn’t mater to an end-user of the project which was used as the tool defined in [build-system] will be fetched automatically by pip when installing the project.

2 Likes

Great input. @milliams indeed the documentation focuses more on the “end-game” versus getting there :)). Nothing wrong with “the end in mind”, but is the reason for my question. @ajoino I have heard of poetry. That said, I like your approach of just copying what I need. It doesn’t seem like I’m missing anything without engaging a new packaging strategy. Thank you both!

I hope I understood your question correctly…

There are some project generators (and templates) available:

Some templates:

I guess if you use a “development workflow tool” they often come with their own project generation command:

4 Likes

A few years ago I made a small wrapper (that I still use) around Poetry (specifically poetry new) to also initialize Git and set up some things that I like to have in each project:

1 Like