当一个项目仅通过pyproject.toml (即没有setup.{py,cfg}文件)指定时,如何通过pip (即python -m pip install -e .)以可编辑模式安装它?
我尝试了构建系统的setuptools和poetry,但都没有用:
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"对于这两个构建系统,我得到了相同的错误:
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.我在conda环境中使用它,下面是我的setuptools和pip版本
$ conda list | grep setuptools
setuptools 58.3.0 pypi_0 pypi
$ python -m pip --version
pip 21.3.1发布于 2021-10-25 16:35:19
用于基于pyproject.toml的构建的可编辑安装定义了如何构建只使用pyproject.toml的项目。构建工具必须实现PEP 660,以便可编辑安装才能工作。您需要一个前端(如pip≥21.3)和一个后端。一些流行后端的状态如下:
注意:为了能够对用户站点(pip install -e --user)进行可编辑的安装,您需要安装一个setuptools v62.0.0或更高版本系统。
发布于 2022-09-19 21:36:28
当我搜索错误字符串"(A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)“时,我在这里绊倒了。
在我的例子中,我所需要做的就是更新pip:
python3 -m pip install --upgrade pip然后安装工作正常。
发布于 2022-08-15 15:27:36
在诗歌1.2.0b3中,“当前项目”在运行poetry install时默认以可编辑模式自动安装。
$ pip uninstall virtualenv # or via apt if you installed that way
$ sudo apt install python3-dev python3-pip python3-setuptools
$ wget install.python-poetry.org -o get-poetry.py
$ python3 get-poetry.py --preview
$ cd /you/project/folder
$ poetry install
$ pip list
Package Version Editable project location
------------------ -------- -------------------------------------------
...
your-project 0.1.0 /you/project/folder
pip 22.2.2
...https://stackoverflow.com/questions/69711606
复制相似问题