2

场景:

  • 我们维护了一些公司内部使用的 conda 包
  • 对于其中一些包,我们几乎不知道这些包的使用位置和方式(用户下载并安装这些包到他们的本地 python 安装)
  • 为了更好地支持使用这些包的用户和项目,我们想更多地了解这些包的用法。

当用户安装软件包时,我想在标准输出上显示一条消息:

Please let us know that you're using the xxx package: send an e-mail to ...@example.com, notify us on the teams channel, or update the wiki page ... directly. Thanks!

问题:

  • conda install在成功安装软件包后显示自定义消息的最简单方法是什么?最好是适用于 Linux 和 Windows 的东西。
4

1 回答 1

2

这可以通过post-link配方中的脚本来完成。 如文档中所述,您必须将消息写入${PREFIX}/.messages.txt,而不是stdoutstderr

示例配方:

foobar-recipe/
├── meta.yaml
├── post-link.bat
└── post-link.sh
# meta.yaml
package:
  name: foobar
  version: 0.1
#!/bin/bash

# post-link.sh

cat << EOF >> ${PREFIX}/.messages.txt


*****************************
Thanks for installing foobar!
*****************************
EOF

(对于 Windows,实现post-link.bat。)

构建它:

$ conda build foobar-recipe

测试安装:

$ conda create -y -n test-foobar --use-local foobar
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /opt/miniconda/envs/test-foobar

  added / updated specs:
    - foobar


The following NEW packages will be INSTALLED:

  foobar             opt/miniconda/conda-bld/osx-64::foobar-0.1-0


Preparing transaction: done
Verifying transaction: done
Executing transaction: /

*****************************
Thanks for installing foobar!
*****************************

done
#
# To activate this environment, use
#
#     $ conda activate test-foobar
#
# To deactivate an active environment, use
#
#     $ conda deactivate

于 2020-12-17T02:56:36.207 回答