如何将使用Poetry开发的Python包放入conda-forge或个人conda渠道中?

6

我使用Poetry作为依赖管理和打包工具,开发了我的第一个Python包。

将我的作品发布到PyPI上非常容易,只需运行以下命令:

poetry publish --build

现在,我想让我的软件包在conda生态系统中可用。作为预备步骤,我尝试使用conda build在本地构建它。

这是我的(匿名的)meta.yaml文件的内容:

{% set version = "0.1.4" %}

package:
  name: "<my-package-name>"
  version: {{ version }}

source:
  url: <URL-of-the-source-distribution-of-my-package-on-PyPI>.tar.gz
  sha256: <SHA256-of-the-source-distribution-of-my-package-on-PyPI>

build:
  noarch: python
  script: python -m pip install .

requirements:
  host:
    - python
    - pip
  run:
    - python

about:
  license: MIT
  license_familY: MIT
  license_file: LICENSE
  summary: "<Brief-project-description>"

在运行conda build时,引发以下异常:
ModuleNotFoundError: No module named 'poetry'

在这些行之后立即进行操作:
[...]
Processing $SRC_DIR
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'

这是我第一次创建conda包。

请帮助我理解我缺少什么,如果有更简单的方法将我的Poetry项目作为conda包在conda-forge上或甚至在我的个人anaconda通道上可用。


1
显然,使用Poetry无法实现这一点:https://github.com/python-poetry/poetry/issues/3376 - Luigi
你的软件包有哪些依赖?它真的只需要Python吗?如果conda-build报错了,提示需要 poetry,那么加入它作为(主机)依赖会发生什么呢?如果你的软件包在PyPI上,并且你有兴趣使用Conda Forge进行部署,也许可以尝试一下grayskull - merv
2个回答

1

您好,看起来您缺少构建要求部分。

requirements:
  build:
    - python
    - pip
    - poetry

0
以下内容对我有效:
package:
    name: custom-package
    version: "0.1"

source:
    path: ./

build:
  noarch: python
  script: {{PYTHON}} -m pip install .


requirements:
  build:
    - python
    - pip
    - poetry

  host:
    - python
    - poetry

  run:
    - python
    - poetry

请确保:

  • 使用{{PYTHON}}而不是python
  • buildhost要求中都包含poetry

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接