pythonpipsetuptoolspython-packagingflit

How to build an sdist with pip?


I'm in the process of converting my projects to use flit as their build backend using pyroject.toml as defined in PEP517.

I still have some projects that will continue to use setuptools as their build backend. Some projects may not be PEP 517 compliant and will use the legacy setup.py build system.

I'm using the latest pip (20.1) as the build frontend, regardless of whether the build backend for a particular project is setuptools or flit. However, I can't figure out how to generate an sdist with pip.

I can generate a wheel with pip, regardless of the build backend

$ pip wheel . -w dist --no-deps

But there doesn't appear to be a similar pip command to generate an sdist, even though all build backends must support creating sdists, as defined in PEP517.

Shouldn't all build front-ends support building sdist's? Should I be using another tool? I'd like to use the same command to build all of my projects regardless of what their build backend is.


Solution

  • The Python Packaging Guide recommends building packages using the new build library maintained by the same Python Packaging Authority that maintains pip.

    https://github.com/pypa/build

    python -m build . --sdist