11

Is it possible to halve your cake and eat it too: can one install (via some mechanism) a project with the following structure:

pyproject.toml
setup.cfg
src/...
scripts/...

In editable mode, like one could with a standard setup.py project:

python3 -m pip install -e . 

(It is OK if the answer is: "one does not install pyproj.toml packages in editable mode")

sinoroc
  • 18,409
  • 2
  • 39
  • 70
Chris
  • 28,822
  • 27
  • 83
  • 158
  • 2
    There's _probably_ a way using Dephell, https://dephell.org/ ... – AKX Mar 30 '21 at 20:13
  • @AKX nice project link. Thanks man. – Chris Mar 30 '21 at 20:14
  • This should just work. Can you show your `setup.cfg` and `pyproject.toml` files? – sinoroc Aug 08 '21 at 10:15
  • 2
    With [PEP 612](https://www.python.org/dev/peps/pep-0621/) and [PEP 660](https://www.python.org/dev/peps/pep-0660/), you will be able to use `pyproject.toml` for everything. As of Pip version 21.1, [you don't need a dummy `setup.py` anymore](https://github.com/pypa/setuptools/issues/1688#issuecomment-902794116). For older Pip versions, you need a [dummy `setup.py`](https://github.com/pypa/setuptools/issues/1688#issuecomment-902784345). – shadowtalker Aug 26 '21 at 13:48

1 Answers1

6

UPDATE: As of August 2022, Setuptools and Pip now fully support PEP 660, and therefore it is now possible to perform an editable installation with only pyproject.toml.

NOTE: To be able to do an editable installation to your user site (pip install -e --user), you need a system installed setuptools v62.0.0 or newer.


After Pip version 21.1, you can use setup.cfg for editable installs.

In the near future, you won't even need that, because there is finally a standard for editable installs that doesn't assume you're using Setuptools: PEP 660. When PEP-517-compatible build backends start also supporting PEP 660, then Pip editable installation will work on projects that only have a pyproject.toml, i.e. PEP-517-only projects that don't support the legacy Setuptools interface (setup.py/setup.cfg).

Before Pip version 21.1 you needed a dummy setup.py:

#!/usr/bin/env python
import setuptools

if __name__ == "__main__":
    setuptools.setup()
kynan
  • 13,235
  • 6
  • 79
  • 81
shadowtalker
  • 12,529
  • 3
  • 53
  • 96