如何使用 pyproject.toml 和诗歌从单个 python 模块构建多个包?
我想实现与 Dask 库类似的行为,可以使用 pip
安装 dask
、dask[dataframe]
、<代码>dask[array] 等。他们通过使用带有软件包密钥的 setup.py
来实现此目的 像这样。如果我仅安装 dask
,则不会安装 dask[dataframe]
,并且在执行模块时它们会警告您这一点。
我在诗歌文档中找到了这个,但是当我执行poetry build< /code> 我只得到一个包含所有包的
.whl
文件。
如何打包我的模块,以便能够使用 poetry
安装库的特定部分?
I want to achieve a similar behavior as the library Dask does, it is possible to use pip
to install dask
, dask[dataframe]
, dask[array]
and others. They do it by using the setup.py
with a packages key like this. If I install only dask
the dask[dataframe]
is not installed and they warn you about this when executing the module.
I found this in the poetry documentation but when I execute poetry build
I only get one .whl
file with all of the packages within.
How can I package my module to be able to install specific parts of a library using poetry
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,Dask 示例并不单独安装子包,它只是单独安装自定义依赖项,如
为了使用
poetry
完成相同的行为,您需要使用这个 (正如用户 @sinoroc 在 此评论 )来自
poetry
extras 页面的示例pyproject.toml
是这样的:通过使用
poetry build --formatwheel
将创建一个单独的轮文件。为了使用 pip 和wheel 文件安装一组特定的额外依赖项,您应该使用:
Actually the Dask example does not install subpackages separately, it just installs the custom dependencies separately as explained in this link.
In order to accomplish the same behavior using
poetry
you need to use this (as mentioned by user @sinoroc in this comment)The example
pyproject.toml
from thepoetry
extras page is this:By using
poetry build --format wheel
a single wheel file would be created.In order to install a specific set of extra dependencies using pip and the wheel file you should use: