我如何制作一个python套餐,并在conda-forge(甚至在我的个人康达频道)上使用诗歌开发?

发布于 2025-01-19 10:45:19 字数 1324 浏览 4 评论 0原文

我使用 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 包。

请帮助我了解我所缺少的内容,以及是否有一种更简单的方法可以使我的诗歌项目作为 conda 包在 conda-forge 上甚至在我的个人 anaconda 频道上提供。

I have developed my first Python package using Poetry as a dependency management and packaging tool.

Publishing my work to PyPI has been as easy as running:

poetry publish --build

Now, I'd like to make my package available in the conda ecosystem too. As a preliminary step, I've tried to build it locally with conda build.

This is what my (anonymized) meta.yaml file looks like:

{% 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>"

Upon running conda build, the following exception is raised:

ModuleNotFoundError: No module named 'poetry'

immediately after these lines:

[...]
Processing $SRC_DIR
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'

This is my very first time creating a conda package.

Please, help me understand what I'm missing and if there is an easier way to make my Poetry project available as a conda package on conda-forge or even on my personal anaconda channel.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄凉少年不暖心 2025-01-26 10:45:19

您似乎缺少“构建要求”部分。

requirements:
  build:
    - python
    - pip
    - poetry

You seem to be missing the build requirements section.

requirements:
  build:
    - python
    - pip
    - poetry
风筝在阴天搁浅。 2025-01-26 10:45:19

以下内容对我有用:

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要求

The following worked for me:

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

Make sure you:

  • use {{PYTHON}} instead of python
  • include poetry in both build and host requirements
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文