为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 pyproject.toml 中正确包含路径依赖?

如何在 pyproject.toml 中正确包含路径依赖?

米脂 2023-04-11 15:14:59
我有 2 个项目结构如下:/abc-lib  / abc    / __init__.py    / main.py  / pyproject.toml/abc-web-api  / src    / __init__.py    / main.py  / pyproject.toml我试图将abc-lib其作为依赖项包含在 中abc-web-api,因此具有abc-web-api/pyproject.toml如下所示:[tool.poetry]name = "abc-web-api"version = "0.0.1"description = "Some description."authors = ["Someone <someone@example.com>"]repository = "https://github.com/someone/abc-web-api"readme = "README.md"[tool.poetry.scripts]serve = "src.main:app"[tool.poetry.dependencies]python = "~3.6.8"abc-lib = { path="../abc-lib" }[tool.poetry.dev-dependencies]pytest = "^3.10.1"yapf = "^0.30.0"flake8 = "^3.8.3"[build-system]requires = ["poetry>=0.12"]build-backend = "poetry.masonry.api"当我执行时poetry install,我收到以下消息:Package operations: 1 installs, 0 updates, 0 removals  - Installing abc-lib (1.0.0 ../abc-lib)[ModuleOrPackageNotFound]No file/folder found for package abc-lib“Installing”声明中显示的版本号是正确的,所以我对[ModuleOrPackageNotFound].有谁知道我该如何解决?谢谢
查看完整描述

1 回答

?
白板的微信

TA贡献1883条经验 获得超3个赞

您的文件夹结构看起来有点奇怪。看起来您更喜欢“src”变体。所以我建议如下:


./

├── abc-lib

│   ├── pyproject.toml

│   └── src

│       └── abc_lib

│           ├── __init__.py

│           └── main.py

└── abc-web-api

    ├── pyproject.toml

    └── src

        └── abc_web_api

            ├── __init__.py

            └── main.py

pyproject.toml有了这个abc-lib:


[tool.poetry]

name = "abc-lib"

version = "0.1.0"

description = ""

authors = ["Someone <someone@example.com>"]



[tool.poetry.dependencies]

python = "^3.6"


[tool.poetry.dev-dependencies]


[build-system]

requires = ["poetry>=1.0"]

build-backend = "poetry.masonry.api"

这在abc-web-api:


[tool.poetry]

name = "abc-web-api"

version = "0.1.0"

description = ""

authors = ["Someone <someone@example.com>"]



[tool.poetry.dependencies]

python = "^3.6"

abc-lib = {path = "../abc-lib"}


[tool.poetry.dev-dependencies]


[build-system]

requires = ["poetry>=1.0"]

build-backend = "poetry.masonry.api"


查看完整回答
反对 回复 2023-04-11
  • 1 回答
  • 0 关注
  • 143 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信