我正在为conda-forge编写一个包,需要指定另一个conda-forge依赖项的依赖项。本质上,我需要安装conda-forge gdal包的固定版本,因为它实际上编译了支持BIGTIFF文件的libtiff版本.
现在,如果我要将gdal安装到conda环境中,我会编写类似的内容。
conda install -c conda-forge gdal=2.4.4 在安装软件包时,我会从安装的gdal=2.4.4中获得这个版本的conda-forge。现在,在meta.yaml文件中,我可以指定类似于这样的包依赖项,但是我没有看到如何为tar文件指定一个URL,或者任何可能工作的东西。
{% set version = "0.0.1" %}
package:
name: mypackage
version: {{ version }}
source:
url: https://github.com/myrepo/{{ version }}.tar.gz
sha256: ****6a63
build:
number: 1
skip: true # [win and py27]
entry_points:
- mycli = mypackage.main:main
requirements:
build:
- python
-
host:
- python
- pip
- numpy
- gdal # <----- want to specify from conda-forge
run:
- python
- gdal # <----- want to specify from conda-forge如能就如何做到这一点提出建议,将不胜感激。
发布于 2020-07-31 04:06:25
我认为在meta.yaml中指定通道是不可能的。以下问题在conda构建问题跟踪器中仍未解决:https://github.com/conda/conda-build/issues/532
作为一种解决办法,如果您知道您需要的gdal的确切版本,您可以在配方中指定确切的版本和“构建字符串”。
唯一令人讨厌的是,您必须为您的食谱需要支持的平台和python版本的每一个组合列出一次gdal。
requirements:
build:
- python
-
host:
- python
- pip
- numpy
- gdal 2.4.4 py36h02fde04_1 # [osx and py==36]
- gdal 2.4.4 py37h622575a_1 # [osx and py==37]
- gdal 2.4.4 py38h57202bd_1 # [osx and py==38]
- gdal 2.4.4 py36hbb8311d_1 # [linux and py==36]
- gdal 2.4.4 py37hf8c3989_1 # [linux and py==37]
- gdal 2.4.4 py38hfe926b7_1 # [linux and py==38]
run:
- python
- gdal 2.4.4 py36h02fde04_1 # [osx and py==36]
- gdal 2.4.4 py37h622575a_1 # [osx and py==37]
- gdal 2.4.4 py38h57202bd_1 # [osx and py==38]
- gdal 2.4.4 py36hbb8311d_1 # [linux and py==36]
- gdal 2.4.4 py37hf8c3989_1 # [linux and py==37]
- gdal 2.4.4 py38hfe926b7_1 # [linux and py==38](我抄袭了在conda锻造通道上的gdal包列表上的那些。)
顺便说一句,既然您提到对您来说真正重要的区别是libtiff,那么您应该将libtiff而不是gdal钉在一起吗?或者两者都有?
编辑:
最好避免在host和run部分中重复构建字符串的整个列表。
正如您在注释中所建议的,一个选项是在conda_build_config.yaml中定义构建字符串。
# conda_build_config.yaml
gdal_build:
- py36h02fde04_1 # [osx and py==36]
- py37h622575a_1 # [osx and py==37]
- py38h57202bd_1 # [osx and py==38]
- py36hbb8311d_1 # [linux and py==36]
- py37hf8c3989_1 # [linux and py==37]
- py38hfe926b7_1 # [linux and py==38]# meta.yaml
requirements:
build:
- python
-
host:
- python
- pip
- numpy
- gdal 2.4.4 {{ gdal_build }}
run:
- python
- gdal 2.4.4 {{ gdal_build }}另一个选项是直接在meta.yaml中在jinja变量中定义查找表。这可能会稍微丑陋一些,但至少所有的逻辑都包含在一个文件中。我不知道该选哪一种。
{% set platform = 'linux' if linux else 'osx' if osx else 'win' %}
{%
set gdal_builds = {
'osx': {
36: 'py36h02fde04_1',
37: 'py37h622575a_1',
38: 'py38h57202bd_1',
},
'linux': {
36: 'py36hbb8311d_1',
37: 'py37hf8c3989_1',
38: 'py38hfe926b7_1',
}
}
%}
requirements:
build:
- python
-
host:
- python
- pip
- numpy
- gdal 2.4.4 {{ gdal_builds[platform][py] }}
run:
- python
- gdal 2.4.4 {{ gdal_builds[platform][py] }}https://stackoverflow.com/questions/63182614
复制相似问题