【发布时间】:2022-08-19 02:32:49
【问题描述】:
我有以下pip install -e . 的情况不是构建develop 版本,除非我删除不包含包装信息的pyproject.toml,而是black 配置。
有人知道该怎么做才能获得develop 构建。
我的pyproject.toml 看起来像这样:
# Source https://github.com/psf/black#configuration-format
[tool.black]
line-length = 100
target-version = [\'py38\']
exclude = \'\'\'
\'\'\'
setup.py
from setuptools import find_namespace_packages
from setuptools import setup
setup(
name=\"webservice\",
packages=find_packages(),
version=\"0.1.0\",
description=\"description\",
author=\"Author\",
license=\"License\",
)
使用这两个文件运行pip install -e ....
(webservice_tool)pk@LAP1:~/webservice_tool$ pip install -e .
Obtaining file:///home/pk/webservice_tool
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: webservice
Building editable for webservice (pyproject.toml) ... done
Created wheel for webservice: filename=webservice-0.1.0-0.editable-py3-none-any.whl size=4070 sha256=dcb7c034ba437503d1059fe9370ccafbda144cd19f3e5d92340a63a7da396422
Stored in directory: /tmp/pip-ephem-wheel-cache-6iqiqbob/wheels/e6/b5/ba/40d8c3d66df94ee2ae46e181034e0c3c47132784db53284d0b
Successfully built webservice
Installing collected packages: webservice
Successfully installed webservice-0.1.0
我删除了pyproject.toml,然后才出现Running setup.py develop。
(webservice_tool) pk@LAP1:~/webservice_tool$ pip install -e .
Obtaining file:///home/pk/webservice_tool
Preparing metadata (setup.py) ... done
Installing collected packages: webservice
Attempting uninstall: webservice
Found existing installation: webservice 0.1.0
Uninstalling webservice-0.1.0:
Successfully uninstalled webservice-0.1.0
Running setup.py develop for webservice
Successfully installed webservice-0.1.0
我的 conda env 中一些选定软件包的版本,在 wsl2 中运行
packaging 21.3 pyhd3eb1b0_0
pip 22.1.2 py38h06a4308_0
python 3.8.13 h12debd9_0
setuptools 61.2.0 py38h06a4308_0
文件夹结构
|-- data_utils
| |-- clean_cache.py
| `-- advanced_utils.py
|-- deployment
| |-- base_deployment
| | |-- auth-proxy.yaml
| | |-- kustomization.yaml
| | |-- webapi.yaml
| | `-- webui.yaml
| `-- mysql_from_helm
| |-- mysql-from-helm.yaml
| `-- mysql-kustomization.yaml
|-- docker-compose.yml
|-- Dockerfile
|-- environment.yml
|-- live_api
| |-- definitions.json
| |-- __init__.py
| `-- live_api.py
|-- params.py
|-- pyproject.toml
|-- setup.py
|-- shared_helpers
| |-- data_cleaning.py
| |-- handle_time.py
| |-- __init__.py
| |-- plot_timesequence.py
| |-- read_samples.py
| `-- save_samples.py
|-- setup.py
|-- util.py
|-- webtool
| |-- clean_data
| | |-- clean_data.py
| | `-- __init__.py
| |-- evaluation
| | |-- draw_figures.py
| | |-- __init__.py
| | `-- webtool_metrics.py
| |-- __init__.py
| |-- preprocess
| | |-- __init__.py
| | `-- preprocess.py
| |-- ui
| | |-- __init__.py
| | `-- create_ui.py
| `-- util
| |-- data_input.py
| |-- data_redefinitions.py
| `-- __init__.py
|-- webtool.egg-info
| |-- dependency_links.txt
| |-- entry_points.txt
| |-- PKG-INFO
| |-- SOURCES.txt
| `-- top_level.txt
`-- webtool_tests
|-- clean_data
| `-- test_clean_data.py
|-- evaluation
| `-- test_draw_figures.py
|-- preprocess
| `-- test_preprocess.py
`-- util
|-- test_data_input.py
`-- test_data_redefinitions.py
-
它做同样的事情,只是输出消息不同。
-
是什么让您认为这不是开发安装?
-
这两条消息的含义相同:
Building editable for webservice (pyproject.toml) ... done在一个中,Running setup.py develop for webservice在另一个中。 -
可编辑是关键词。
-
@wim 这两个安装在处理导入方面的行为不同。如果我在主项目文件夹
home/pk/webservice_tool中有一个文件util.py,我可以在python 脚本中编写import util,对于Running setup.py develop版本,这是可行的,而另一个则抛出错误ModuleNotFoundError: No module named \'util\'。
标签: python pip setuptools setup.py pyproject.toml