猿问

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

我有 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].


有谁知道我该如何解决?谢谢


米脂
浏览 159回答 1
1回答

白板的微信

您的文件夹结构看起来有点奇怪。看起来您更喜欢“src”变体。所以我建议如下:./├── abc-lib│&nbsp; &nbsp;├── pyproject.toml│&nbsp; &nbsp;└── src│&nbsp; &nbsp; &nbsp; &nbsp;└── abc_lib│&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;├── __init__.py│&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;└── main.py└── abc-web-api&nbsp; &nbsp; ├── pyproject.toml&nbsp; &nbsp; └── src&nbsp; &nbsp; &nbsp; &nbsp; └── abc_web_api&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ├── __init__.py&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; └── main.pypyproject.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"
随时随地看视频慕课网APP

相关分类

Python
我要回答