How to install a package using pip in editable mode with pyproject.toml?
Oct 25
When a project is specified only via pyproject.toml (i.e. no setup.{py,cfg} files), how can it be installed in editable mode via pip (i.e. python -m pip install -e .)?
I tried both setuptools and poetry for the build system, but neither worked:
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
I get the same error for both build systems:
ERROR: Project file:///tmp/demo has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that supports PEP 660.
I'm using this inside a conda environment, the following is my version of setuptools and pip:
$ conda list | grep setuptools
setuptools 58.3.0 pypi_0 pypi
$ python -m pip --version
pip 21.3.1
1 answer
Accepted answer · original discussion
Oct 25
PEP 660 – Editable installs for pyproject.toml based builds defines how to build projects that only use pyproject.toml. Build tools must implement PEP 660 for editable installs to work. You need a front-end (such as pip ≥ 21.3) and a backend. The statuses of some popular backends are:
- Setuptools implements PEP 660 as of version 64.
- Flit implements PEP 660 as of version 3.4.
- Poetry implements PEP 660 as of version 1.0.8.
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.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.