本文将介绍如何构建 Conda
包,并将生成的 Conda 包上传至 anaconda cloud
首先下载安装Anaconda
系统:macOS arm64
# 创建 conda 构建环境
$ conda create -n PersusX
# 激活 conda 构建环境
$ conda activate PersusX
# 安装conda-build
$ conda install conda-build
Anaconda Cloud
账号Anaconda 的地址为 https://anaconda.org/
Anaconda
客户端$ conda install anaconda-client
Anaconda
$ anaconda login
将package 打包成conda
可以安装的包需要使用工具conda-build
,将打包完成的package需要anaconda-client
。
使用conda
通常是用试错的方法打包的,在第一构建程序包的时,通常会因为缺少依赖关系或者链接错误导致失败,之后可以通过检查这些错误并修改recipe,以及缺少的依赖项,这通常是meta.yaml文件中内容。在经过几次尝试和循环纠错后,可以最终打包成功。
coanda
打包时的路径conda
打包时的工作环境本文以脉冲星数据处理软件tempo
为案例,tempo
的文件结构为:
tempo
├── Makefile.am
├── README
├── clock
│ ├── Makefile.am
│ ├── bipmnist.01.extrap
│ ├── bipmnist.03.extrap
│ ├── bipmnist.05.extrap
│ ├── bipmnist.06.extrap
│ ├── bipmnist.08.extrap
│ ├── bipmnist.11.extrap
│ ├── bipmnist.12.extrap
│ ├── bipmnist.12.extrap.extralong
│ ├── bipmnist.14
│ ├── bipmnist.15.extrap
│ ├── bipmnist.16.extrap
│ ├── bipmnist.17.extrap
│ ├── bipmnist.18.extrap
│ ├── bipmnist.19.extrap
│ ├── bipmnist.92
│ ├── bipmnist.96
│ ├── leap.sec
│ ├── time.dat
│ ├── time3_gbt.dat
│ ├── time_ao.dat
│ ├── time_bonn.dat
│ ├── time_chime.dat
│ ├── time_gb140.dat
│ ├── time_gb853.dat
│ ├── time_gbt.dat
│ ├── time_jb.dat
│ ├── time_nancay.dat
│ ├── time_nuppi.dat
│ ├── time_pks.dat
│ ├── time_vla.dat
│ ├── time_wsrt.dat
│ ├── ut1.dat
│ └── utccorr.tot
├── config
│ ├── ax_blas.m4
│ └── ax_lapack.m4
├── configure.ac
├── doc
│ ├── Makefile
│ ├── index.html
│ ├── param_idx.txt
│ ├── ref_man_sections
│ │ ├── binary.txt
│ │ ├── clock.txt
│ │ ├── config.txt
│ │ ├── control.txt
│ │ ├── description.txt
│ │ ├── ecliptic.txt
│ │ ├── ephem.txt
│ │ ├── fixedformat.txt
│ │ ├── freeformat.txt
│ │ ├── inputfile.txt
│ │ ├── nist-utc.txt
│ │ ├── notes.txt
│ │ ├── obsys.txt
│ │ ├── options.txt
│ │ ├── output.txt
│ │ ├── parameter.txt
│ │ ├── tdb-tt.txt
│ │ ├── toa.txt
│ │ ├── toacommand.txt
│ │ ├── tz-in.txt
│ │ ├── tz-param.txt
│ │ ├── tz-polyco.txt
│ │ └── tz.txt
│ ├── reference_manual.html
│ ├── tempo11.000_install.html
│ ├── tempo11.html
│ ├── tempo_idx.html
│ ├── tempo_install.html
│ ├── tempo_update.html
│ ├── upload
│ └── upload_gh
├── ephem
│ ├── DE200.1950.2050
│ ├── DE405.1950.2050
│ ├── DE418.1950.2050
│ ├── DE421.1950.2050
│ ├── DE430.1950.2050
│ ├── DE435.1950.2050
│ ├── DE436.1950.2050
│ ├── DE438.1950.2050
│ ├── DE440.1950.2050
│ ├── Makefile.am
│ ├── TDB.1950.2050
│ └── ecliptic.dat
├── info
│ └── recipe
│ ├── build.sh
│ └── meta.yaml
├── obsys.dat
├── prepare
├── src
│ ├── Makefile.am
│ ├── a1ut1f.f
│ ├── a1utcf.f
│ ├── acom.h
│ ├── ang.f
│ ├── array.h
│ ├── arrtim.f
│ ├── atimfake.f
│ ├── bcom.h
│ ├── bigendian.f
│ ├── blkdbat.f
│ ├── bnrybt.f
│ ├── bnrybtx.f
│ ├── bnrydd.f
│ ├── bnryddfwhiecc.f
│ ├── bnryddgr.f
│ ├── bnryddk.f
│ ├── bnryddp.f
│ ├── bnrydds.f
│ ├── bnryddt.f
│ ├── bnryeh.f
│ ├── bnryell1.f
│ ├── bnrymss.f
│ ├── bootmc.f
│ ├── bt2ell1.f
│ ├── cfgin.f
│ ├── chebpc.f
│ ├── citem.f
│ ├── clockcor.f
│ ├── clocks.h
│ ├── config.h.in
│ ├── covar.f
│ ├── cross.f
│ ├── cutil.c
│ ├── damoyr.f
│ ├── dim.h
│ ├── dot.f
│ ├── dp.h
│ ├── dskrd.f
│ ├── earth.f
│ ├── ell12bt.f
│ ├── eph.h
│ ├── ephcom.h
│ ├── ephinit.f
│ ├── ephread.f
│ ├── equ2ecl.f
│ ├── fit.f
│ ├── fk4tofk5.f
│ ├── flagcom.h
│ ├── galco.f
│ ├── gasdev.f
│ ├── get_version_id.sh
│ ├── getcmdline.f
│ ├── getecliptic.f
│ ├── getflags.f
│ ├── getvalue.f
│ ├── glitch.h
│ ├── glsfit.f
│ ├── glsfit_missing.f
│ ├── inpar.f
│ ├── interp.f
│ ├── lmst.f
│ ├── mass2dd.f
│ ├── matinv.f
│ ├── matrix.f
│ ├── mjdadd.f
│ ├── mxprt.f
│ ├── newbin.f
│ ├── newsrc.f
│ ├── newval.f
│ ├── nutation.f
│ ├── obsite.f
│ ├── orbit.h
│ ├── outpar.f
│ ├── pcard.f
│ ├── pcshft.f
│ ├── plnoise.f
│ ├── pospm_conv.f
│ ├── prcnut.f
│ ├── precession.f
│ ├── propmo.f
│ ├── radian.f
│ ├── ran1.f
│ ├── resid.f
│ ├── setup.f
│ ├── sitea2n.f
│ ├── siten2a.f
│ ├── siten2b.f
│ ├── sort.f
│ ├── space_motion.f
│ ├── tdb1ns.f
│ ├── tdbcom.h
│ ├── tdbgen.f
│ ├── tdbinit.f
│ ├── tdbinit2.f
│ ├── tdbread.f
│ ├── tempo.f
│ ├── timcalc.f
│ ├── tmalloc.f
│ ├── toa.h
│ ├── tparin.f
│ ├── tpohdr.f
│ ├── trnsfr.h
│ ├── tz.h
│ ├── tzfit.f
│ ├── tzinit.f
│ ├── ut1.h
│ ├── ut1red.f
│ ├── vcom.h
│ ├── vmemw.f
│ └── ztim.f
├── tempo.cfg.in
├── tempo.hlp
├── test
│ ├── 0437-4715.par.original
│ ├── 0437.par
│ ├── 0437.tim
│ ├── Makefile.am
│ ├── tempo.cfg
│ ├── tempo.lis.original
│ └── time.dat
├── tzpar
│ ├── 1937+21.par
│ └── Makefile.am
└── util
├── README
├── avtime
│ └── avtime.f
├── center_epoch
│ └── center_epoch.py
├── compare_tempo
│ ├── README
│ └── compare_tempo
├── cull
│ ├── README
│ └── cull.pl
├── dmx
│ ├── dmx_cleanup.py
│ ├── dmx_info.py
│ └── dmx_median_adjust.py
├── dmx_broaden
│ └── dmx_broaden
├── dmx_ranges
│ └── DMX_ranges2.py
├── dmxparse
│ ├── dmxparse
│ └── dmxparse.py
├── extract
│ ├── README
│ └── extract.pl
├── lk
│ ├── README
│ └── lk.f
├── non_tempo
│ ├── README
│ ├── aolst
│ ├── dt
│ └── mjd
├── obswgt
│ ├── README
│ └── obswgt.pl
├── print_resid
│ ├── Makefile.am
│ ├── print_resid.c
│ ├── tempo_output.c
│ └── tempo_output.h
├── pubpar
│ ├── README
│ └── pubpar.py
├── res_avg
│ ├── res_avg
│ └── res_compare
├── ut1
│ ├── README
│ ├── check.ut1
│ ├── do.iers.ut1
│ ├── do.iers.ut1.new
│ ├── get_ut1
│ ├── get_ut1_new
│ ├── make_ut1
│ └── predict_ut1.c
└── wgttpo
├── README
├── wgttpo.pl
├── wgttpo_emin.pl
└── wgttpo_equad.pl
其中在./info/recipe
中包含了 meta.yaml
和 build.sh
两个文件,conda-build
将包含 meta.yaml
和 build.sh
文件的文件夹称为**recipe**。
package:
name: tempo
version: 2022.10.09
source:
path: /Users/persusx/test/tempo
build:
number: '0'
string: PersusX
requirements:
build:
- clang
- clang-14
host:
- libblas 3.9.0
run:
- libblas >=3.9.0,<4.0a0
- libgfortran 5.*
- libgfortran5 >=9.3.0
about: {}
extra:
copy_test_source_files: true
final: true
#!/bin/bash
source ./prepare
./configure --prefix=$PREFIX CFLAGS='-g -O2' FFLAGS='-g -O2'
make
make install
make -C util/print_resid
make -C util/print_resid install
tempodir=$PREFIX/share/tempo
mkdir -p $tempodir
cat tempo.cfg.in | sed 's%@abs_top_srcdir@%'$tempodir'%' > $tempodir/tempo.cfg
cp -a tempo.hlp $tempodir
cp -a ephem $tempodir
cp -a obsys.dat $tempodir
cp -a util/dmxparse/dmxparse.py $PREFIX/bin/
cp -a util/res_avg/res_avg $PREFIX/bin/
# This foo will make conda automatically define a TEMPO env variable
# the environment is activated.
etcdir=$PREFIX/etc/conda
mkdir -p $etcdir/activate.d
echo "setenv TEMPO $tempodir" > $etcdir/activate.d/tempo-env.csh
echo "export TEMPO=$tempodir" > $etcdir/activate.d/tempo-env.sh
mkdir -p $etcdir/deactivate.d
echo "unsetenv TEMPO" > $etcdir/deactivate.d/tempo-env.csh
echo "unset TEMPO" > $etcdir/deactivate.d/tempo-env.sh
$ conda-build tempo
注意 :当出现以下报错信息时:
conda_build.exceptions.DependencyNeedsBuildingError: Unsatisfiable dependencies for platform ...
可以添加conda-forge
通道:
$ conda config --add channels conda-forge
## 登录
$ anaconda login
## 上传
$ anaconda upload /Users/psrxx/opt/anaconda3/conda-bld/osx-arm64/tempo-2022.10.09-PersusX.tar.bz2
Conda Channels 文档:https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/channels.html
Conda channel是用来存放安装包的地方。Conda的安装包是从网站上下载的,在不指定安装包网站的情况下,将默认从 https://repo.anaconda.com/pkgs/ 下载,假如想要的安装包不在这个网站上,就需要指定安装的网站,比如:想从conda-forage下载pgplot这个包,则运行:
$ conda install pgplot --channel conda-forge
conda-forge是GitHub上的社区,专于做开源Conda的包, 官网:https://conda-forge.org/