Here is the steps to upload a package to conda server. First, a package that will be uploaded to a conda server must be available on Python package index (PyPI). Then you can create a conda recipe from package-PyPI. Then you will build a conda package from conda recipe. After you build a conda package, you can upload it to a channel to make it available for others to use. A channel is a specific location for storing packages, and may point to a cloud-based repository or a private location on a remote or local repository that you or your organization created.
Table of Content
conda update condaconda install conda-buildconda install anaconda-clientGo to https://anaconda.org/ and register new account.
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txtif errorlevel 1 exit 1del %SCRIPTS%\conda-initcopy bdist_conda.py %PREFIX%\Lib\distutils\command\if errorlevel 1 exit 1python setup.py install --single-version-externally-managed --record=record.txt To create conda recipe from PyPI, type like this:
conda skeleton pypi NAME_OF_PACKAGEfor example, create conda recipe of OctaDist package:
conda skeleton pypi octadistThis will take 1-2 minutes.
When it is done, you should see the message like this:
# output...Hunk #1 succeeded at 167 with fuzz 2 (offset 1 line).Writing recipe for octadist...To build conda package, type like this:
conda-build --python PYVER PACKAGEwhere
For example:
conda-build --python 3.7 octadistThis will build and test your package. When it is done, a conda package will be created either at $HOME/conda-bld or at the environment directory:
# output$HOME/conda-bld/# or$HOME/anaconda3/envs/ENV_NAME/conda-bldconda convert --platform PLATFORM FILE -o $HOME/conda-bld/where
$HOME/conda-bld/linux-64/ directory.For example,
conda convert --platform win-64 $HOME/conda-bld/linux-64/*.tar.bz2 -o $HOME/conda-bld/This will convert the conda package from linux-64 to win-64 platform, the file will be created at $HOME/conda-bld/win-64:
$HOME/conda-bld/win-64/*.tar.bz2You have to login to Anaconda server before uploading packages. Use following command:
anaconda loginThen you will be asked username and password:
Using Anaconda API: https://api.anaconda.orgUsername: Password: Now you are ready to upload all conda packages to the server using anaconda command:
anaconda upload PACKAGE.tar.bz2For example, upload package for linux-64 platform:
anaconda upload $HOME/conda-bld/linux-64/*.tar.bz2When it is done without error messages, you can now try installing a package via conda command.
conda install PACKAGETo create, build, and upload package for all platform automatically, you can use the following bash script to do so:
#!/bin/bashpkg='octadist'array=( 3.5 3.6 3.7 )platforms=( osx-64 linux-32 linux-64 win-32 win-64 )### 1. create metal.ymlconda skeleton pypi $pkg### 2. building conda packagesfor i in "${array[@]}"do conda-build --python $i $pkgdone### 3. convert package to other platformCON_BLD=$HOME/conda-bld# CON_BLD="/home/nutt/anaconda3/envs/py37/conda-bld"find $CON_BLD/linux-64/ -name *.tar.bz2 | while read filedo #conda convert --platform all $file -o $HOME/conda-bld/ for platform in "${platforms[@]}" do conda convert --platform $platform $file -o $CON_BLD/ donedone### 4. upload packages to condafind $CON_BLD/ -name *.tar.bz2 | while read filedo anaconda upload $filedoneString in meta.yml file should be supported by conda-build, if you get error about "Unicode string", you can avoid this error by putting the string to " ... ", for example, the following string has colon (:) which is not supported by conda-build:
Old:
about: summary: My Pacakge: New packageNew:
about: summary: "My Pacakge: New package"Rangsiman Ketkaew