7

I'm writing a Python package that I want to publish on both pypi and conda. To avoid mistakes, I would like to store the requirements in a single file; at least for the foreseeable future, they are the same.

It is easy to go from meta.yaml to setup.py (e.g. through pyyaml), however what about the other way around? How can I inject the requirements into meta.yaml?

Is there anything like:

{% set data = load_setup_py_data() %}
...
requirements:
  run:
    {{ data.get('install_requires') }}

What is the best practice for this scenario?

Dimebag
  • 833
  • 2
  • 9
  • 29

1 Answers1

6

Hard to figure out for a jinja noob but this works:

requirements:
  run:
    {% for req in data.get('install_requires', []) %}
      - {{ req }}
    {% endfor %}

Surprisingly hard to figure out why but load_setup_py_data() seems to be called multiple times during conda-build and sometimes it returns an empty dict with no install_requires, so .get would return a None.

Dimebag
  • 833
  • 2
  • 9
  • 29