How does one install a setup.cfg + pyproject.toml python project in editable mode with pip?
Asked Answered
N

1

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")

Ng answered 29/3, 2021 at 15:46 Comment(4)
There's probably a way using Dephell, dephell.org ...Hartle
@Hartle nice project link. Thanks man.Ng
This should just work. Can you show your setup.cfg and pyproject.toml files?Insoluble
With PEP 612 and PEP 660, 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. For older Pip versions, you need a dummy setup.py.Behead
B
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()
Behead answered 26/8, 2021 at 13:52 Comment(3)
How should I get the setup.cfg file?Krenek
You don't "get" the file, it's a config file that you create. It is analogous to setup.py.Behead
Yeah, I know that. But I have all my config in pyproject.toml, so something needs to generate this useless setup.cfg for me.Krenek

© 2022 - 2024 — McMap. All rights reserved.