5

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.

merv
  • 67,214
  • 13
  • 180
  • 245
Luigi
  • 81
  • 3
  • 1
    Apparently, there is no way to achieve this with Poetry: https://github.com/python-poetry/poetry/issues/3376 – Luigi Apr 06 '22 at 16:43
  • What are your package's dependencies? Does it really only need Python? If `conda-build` complains about `poetry`, what happens if you add that as a (host) dependency? If your package is on PyPI and you're interested in Conda Forge deployment, maybe give [`grayskull`](https://github.com/conda-incubator/grayskull) a try. – merv Apr 06 '22 at 19:54

2 Answers2

1

You seem to be missing the build requirements section.

requirements:
  build:
    - python
    - pip
    - poetry
wim
  • 338,267
  • 99
  • 616
  • 750
0

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
Narek
  • 548
  • 6
  • 26