运行 python 模块使用诗歌

run python module using poetry

我的 Makefile 中有一个命令,看起来像这样

run/webserver:
    PYTHONPATH=src venv/bin/python -m api

和看起来像这样的项目结构

project/
    src/
       api/
            __init__.py
            __main__.py
    tests/
    Makefile

我使用基本 piprequirements.txt 文件,但决定迁移到诗歌。

我将Makefile更新为这个

run/webserver:
    poetry shell
    poetry run python -m api

pyproject.toml包含此配置诗歌

[tool.poetry]
name = "project"
description = "project"
version =  "1.20.0"
homepage = "https://"
repository = "https://"
documentation = "https://"
authors = [""]
packages = [
    { include="src", from="." },
]

但是当我尝试 运行 命令时

make run/webserver

它失败了

No module named api

可能是什么问题?

packages 参数通常包含名称:

packages = [
    { include = "api", from = "src" },
]

https://python-poetry.org/docs/pyproject/#packages