Code generation before packaging, migration from setup.py to pyproject.toml

So far, there is no standard practice for that.
Depending on the build backend you select, you will have to use a different strategy.

If your code generation requires you to write imperative code you might end up with a different .py file in your project implementing the necessary steps.

In the case you want to use setuptools you can try to add a custom build step (which would require you to have a setup.py - however please have in mind that the setup.py file itself is not deprecated, it is a perfectly valid configuration file, what is deprecated is running it directly as a script or CLI tool - you can always keep all your static metadata in pyproject.toml and use setup.py just for the imperative code that describes the custom build step).

1 Like