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 conda
conda install conda-build
conda install anaconda-client
Go to https://anaconda.org/ and register new account.
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1
del %SCRIPTS%\conda-init
copy bdist_conda.py %PREFIX%\Lib\distutils\command\
if errorlevel 1 exit 1
python setup.py install --single-version-externally-managed --record=record.txt
To create conda recipe from PyPI, type like this:
conda skeleton pypi NAME_OF_PACKAGE
for example, create conda recipe of OctaDist package:
conda skeleton pypi octadist
This 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 PACKAGE
where
For example:
conda-build --python 3.7 octadist
This 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-bld
conda 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.bz2
You have to login to Anaconda server before uploading packages. Use following command:
anaconda login
Then you will be asked username and password:
Using Anaconda API: https://api.anaconda.org
Username:
Password:
Now you are ready to upload all conda packages to the server using anaconda command:
anaconda upload PACKAGE.tar.bz2
For example, upload package for linux-64 platform:
anaconda upload $HOME/conda-bld/linux-64/*.tar.bz2
When it is done without error messages, you can now try installing a package via conda command.
conda install PACKAGE
To create, build, and upload package for all platform automatically, you can use the following bash script to do so:
#!/bin/bash
pkg='octadist'
array=( 3.5 3.6 3.7 )
platforms=( osx-64 linux-32 linux-64 win-32 win-64 )
### 1. create metal.yml
conda skeleton pypi $pkg
### 2. building conda packages
for i in "${array[@]}"
do
conda-build --python $i $pkg
done
### 3. convert package to other platform
CON_BLD=$HOME/conda-bld
# CON_BLD="/home/nutt/anaconda3/envs/py37/conda-bld"
find $CON_BLD/linux-64/ -name *.tar.bz2 | while read file
do
#conda convert --platform all $file -o $HOME/conda-bld/
for platform in "${platforms[@]}"
do
conda convert --platform $platform $file -o $CON_BLD/
done
done
### 4. upload packages to conda
find $CON_BLD/ -name *.tar.bz2 | while read file
do
anaconda upload $file
done
String 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 package
New:
about:
summary: "My Pacakge: New package"
Rangsiman Ketkaew