Flit-like project tool for Setuptools

So I got galaxy-brained by a feature request on pip’s issue tracker, and tried to fill that gap between Setuptools and PEP 518. The end result:

Some summaries and random thoughts:

  • Build commands uses an isolated environment, like how pip implements PEP 517, but instead of being one-off, the environment is persisted in build/.isoenvs and reused for each call.
  • setl develop is a proxy call to setup.py develop against the build env, and with run-time requirements installed with pip (instead of easy install). This ties back to the discussions in Specification of editable installation.
  • setl build is a proxy call to setup.py build (and other various build_* calls). This might be a good place to get an understanding for Drawing a line to the scope of Python packaging, where we want to get an idea what a PEP 518 backend needs for incremental builds.
  • setl dist uses PEP 517 hooks to build the sdist and wheel (but again reusing the persisted isolated environments).
  • setl publish is a proxy to Twine.

I tested it on some internal packages (including extension ones), and everything seems to work okay (with many rough edges in UI). I’m sure there are a lot of edge cases I failed to cover though, any feedback would be awesome.

3 Likes

Can you explain what it brings over running python setup.py ... directly?

1 Like

I think isolated build environments and one tool API to do all packaging operations :man_shrugging:

Sure! I should probably explain in the project README as well.

The main difference is how build and runtime dependencies are installed. setup.py build (and friends) uses setup_requires, but that has various problems (e.g. fetch the dependencies as eggs) so pip discourages using it. Packages using PEP 518 are encouraged to specify build time dependencies in pyproject.toml instead. But Setuptools does not recognise that declaration, leading to the pip feature request I mentioned in the top post (otherwise users need to install those build dependencies manually). setl build mimics pip install’s build setup behaviour, but calls setup.py build in the end (instead of installing the package).

Similarly, Setuptools also use itself to install runtime dependencies, instead of pip. pip reads the same fields as Setuptools here, but uses a different/better format (.dist-info). setl develop works around this by first installing dependencies with pip before calling setup.py install --no-deps, so dependencies are installed in the modern format.

The rest are more or less cosmetics. A common complaint I see when developing with Setuptools nowadays is that you need to remember a lot of commands:

  • DO NOT setup.py install, use pip
  • DO setup.py sdist bdist_wheel for packaging (not perfect but nothing better AFAIK)
  • DO NOT setup.py upload, use Twine

We know all of these by heart, but for the majority of people this is a little disorienting.

3 Likes

im using this to package my code folder into zip however its excluding extensions like .txt,.bat,.xml,.jpeg etc .

setup.py sdist