3

我想使用诗歌工具创建一个空的(元)包,主要是为了简化将依赖项列表组合在一起的过程。如果我按如下方式创建我的 project.toml:

[build-system]
requires = ["poetry"]

[tool.poetry]
name = "metapackage"
version = "1.0.0"
description = "My empty metapackage"
authors = ["Me"]
license = "MIT"

[tool.poetry.dependencies]
numpy = "*"

然后执行poetry build,我得到一个错误:

$ mkdir -p metapackage
$ python -m poetry build --no-interaction --format wheel -vvvUsing virtualenv: /Users/duncan/opt/miniconda3/envs/py37
Building metapackage (1.0.0)

[ValueError]
metapackage is not a package.

Traceback (most recent call last):
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/poetry/console/commands/build.py", line 30, in handle
    builder.build(fmt)
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/poetry/masonry/builder.py", line 19, in build
    builder = self._FORMATS[fmt](self._poetry, self._env, self._io)
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/poetry/masonry/builders/wheel.py", line 44, in __init__
    super(WheelBuilder, self).__init__(poetry, env, io)
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/poetry/masonry/builders/builder.py", line 68, in __init__
    includes=self._package.include,
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/poetry/masonry/utils/module.py", line 72, in __init__
    source=package.get('from'),
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/poetry/masonry/utils/package_include.py", line 15, in __init__
    self.check_elements()
  File "/Users/duncan/opt/miniconda3/envs/py37/lib/python3.7/site-packages/poetry/masonry/utils/package_include.py", line 61, in check_elements
    raise ValueError('{} is not a package.'.format(root.name))

我是否遗漏了一些东西来告诉诗歌这个包裹没有内容?

附录:我很乐意使用诗歌作为创建一个.dist-info包含元数据的目录的方法,以便pip看到已安装的元数据包,如果有更好的工具,我很乐意切换。

4

2 回答 2

3

使用setuptools它可能如下所示:

pyproject.toml

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools"]

setup.cfg

[metadata]
name = metapackage
version = 1.0.0
description = My empty metapackage
authors = Me
license = MIT

[options]
install_requires =
    numpy

请注意选项packagespy_modulesscriptsext_modules未填充。

于 2020-01-23T15:56:58.313 回答
2

使用诗歌构建的包的绝对最低要求是它包含可导入的 python 模块或包。

因此,您至少需要一个允许该语句import metapackage的文件,仅一个没有任何文件的文件夹是不够的:

选项 1,带模块

.
├── pyproject.toml
└── metapackage.py  # can be empty

选项 2,带包裹

.
├── pyproject.toml
└── metapackage
    └── __init__.py  # can be empty
于 2020-01-14T08:22:37.333 回答