使用poetry访问包中的函数

2024-03-28 13:21:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用诗歌来包装我的python代码。我已经设法制作了一个.whl,我可以用pip安装它,但是当我用python导入它时,我不能访问任何函数

这是我当前的pyproject.toml文件:

[tool.poetry]
name = "package"
version = "0.1.0"
description = "package description"
authors = ["Andrew"]
packages = [{include = "package"}]
include = ["package/helper.py", 
           "package/scheduler.py"]

[tool.poetry.dependencies]
python = "^3.6"

[tool.poetry.dev-dependencies]
pytest = "^3.0"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

在poetry创建的包目录中有3个文件:helper.pyscheduler.py__init__.py。在helper.py内部有一个名为adder(x,y)的函数

我想在python中调用这个函数,我必须如何修改我的.toml文件才能做到这一点?我尝试过各种不同的包,包括参数,但到目前为止没有任何效果。谢谢


Tags: 文件函数代码pybuildhelperpackagepoetry