[英]Add requirements from requirements.txt to conda meta.yaml
I'm writing a Python package that I want to publish on both pypi and conda.我正在写一个 Python package 我想在 pypi 和 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 (eg through pyyaml), however what about the other way around?从 meta.yaml 到 setup.py(例如通过 pyyaml)很容易 go,但是反过来呢? How can I inject the requirements into meta.yaml?
如何将需求注入 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?这种情况的最佳实践是什么?
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
.令人惊讶的是,很难弄清楚为什么
load_setup_py_data()
在conda-build
期间似乎被多次调用,有时它返回一个没有 install_requires 的空字典,所以.get
会返回一个None
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.