5

我正在为另一个依赖项编写一个包,conda-forge并且需要指定一个conda-forge依赖项。本质上,我需要安装conda-forge gdal包的固定版本,因为它实际上编译了libtiff支持 BIGTIFF 文件的版本....

现在,如果我要安装gdalconda环境中,我会写类似的东西。

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

任何有关如何执行此操作的建议将不胜感激。

4

1 回答 1

4

我认为不可能在meta.yaml. conda-build 问题跟踪器中仍未解决以下问题: https ://github.com/conda/conda-build/issues/532

作为一种解决方法,如果您知道所需的确切版本,gdal则可以在配方中指定确切的版本和“构建字符串”。

唯一烦人的事情是,你必须gdal为你的配方需要支持的每个平台和 python 版本的组合列出一次。

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-forge 频道的 gdal 包列表中复制了这些。)

顺便说一句,既然你提到对你来说真正重要的区别是libtiff,那么你应该钉住libtiff而不是gdal吗?或者两者兼而有之?


编辑:

host避免在andrun部分中重复整个构建字符串列表会很好。

正如您在评论中建议的那样,一种选择是在以下位置定义构建字符串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 }}

另一种选择是在 jinja 变量中定义查找表,直接在meta.yaml. 这可能有点难看,但至少所有逻辑都包含在一个文件中。我不确定更喜欢哪个。

{% 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] }}
于 2020-07-31T04:06:25.473 回答