Project Layout & pyproject

A track of P35 · Packaging, Tooling & Automation.

Make code installable: write a real pyproject.toml, choose the src/ layout so you test what you ship (not uninstalled source), and add an entry point that turns a library into a command a user can type.

Your test suite passes. Then you install the package into a clean environment, run the same suite against it, and half of it fails on ImportError. Nothing regressed — the tests had never been importing your package, they were importing the folder sitting next to them, and the difference only became visible once somebody else tried to use it.

The first thing anyone else sees of your code is how it's laid out and what it declares — and both come down to pyproject.toml. This track has you write a real one from scratch, so the file that turns a folder of .py files into an installable package is not a template you copy but a structure you understand.

Two decisions carry the track. The src/ layout puts the importable code one directory down, so the only way to import the package is to install it — which means your tests exercise the real shipped shape instead of accidentally importing uninstalled source. And an entry point under [project.scripts] maps a command to a module:function target, turning a library into something a user can just type. You author the pyproject.toml, graded by parsing it, and then defend the layout choices in an interview rung.

pyproject.tomlthe single source of truthsrc/ layoutinstall to import; test what you shipeditable installpip install -e . while developingentry point[project.scripts] -> a command
A folder of .py files becomes an installable package.
Project Layout & pyproject — TransformerLab