Building conda packages

This tutorial describes how to build a conda package

  1. Install Miniconda or Anaconda, conda-build and Git

    • After installing miniconda or anaconda, use conda to install conda-build and Git.
    • To install conda-build in your terminal window or an anaconda prompt, run:

        conda install conda-build
    • Git can be installed by following the steps mentioned here.
    • Follow Building conda packages with conda skeleton. The lab’s GitHub template already has the basic skeleton.
  2. Edit the meta.yaml file. It should look something like this:

     {% set version = "1.1.0" %}
     name: imagesize
     version: {{ version }}
     git_rev: 1.1.4
     git_depth: 1 # (Defaults to -1/not shallow)
     noarch: python
     number: 0
     script: python -m pip install .
         - python
         - pip
         - python
         - imagesize
     license: MIT
     summary: 'Getting image size from png/jpeg/jpeg2000/gif file'
     description: |
         This module analyzes jpeg/jpeg2000/png/gif image header and
         return image size.
    • Here is another example from the pyCapsid repository
     #{% set data = load_setup_py_data() %}
     name: pycapsid
     version: 0.1.9
     path: ..
     #url:{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
     # If getting the source from GitHub, remove the line above,
     # uncomment the line below, and modify as needed. Use releases if available:
     # and otherwise fall back to archive:
     # url:{{ version }}.tar.gz
     #sha256: 2b3a0c466fb4a1014ea131c2b8ea7c519f9278eba73d6fcb361b7bdb4fd494e9
     # sha256 is the preferred checksum -- you can get it for a file with:
     #  `openssl sha256 <file name>`.
     # You may need the openssl package, available on conda-forge:
     #  `conda install openssl -c conda-forge``
     script: python -m pip install . -vv
     number: 1
     # Uncomment the following line if the package is pure Python and the recipe is exactly the same for all platforms.
     # It is okay if the dependencies are not built for all platforms/versions, although selectors are still not allowed.
     # See for more details.
     noarch: python
     # If the installation is complex, or different between Unix and Windows, use separate bld.bat and files instead of this key.
     # By default, the package will be built for the Python versions supported by conda-forge and for all major OSs.
     # Add the line "skip: True  # [py<35]" (for example) to limit to Python 3.5 and newer, or "skip: True  # [not win]" to limit to Windows.
     # More info about selectors can be found in the conda-build docs:
         - python <3.11
         - pip
         - setuptools
         - setuptools-scm
         - python<3.11
         - biotite
         - scikit-learn
         - numpy<1.24
         - scipy
         - matplotlib-base
         - numba
         - statsmodels
     # Some packages might need a `test/commands` key to check CLI.
     # List all the packages/modules that `` imports.
         - pyCapsid
     # For python packages, it is useful to run pip check. However, sometimes the
     # metadata used by pip is out of date. Thus this section is optional if it is
     # failing.
         - pip
     summary: A set of computational tools written in python for the analysis of viral capsids
     # Remember to specify the license variants for BSD, Apache, GPL, and LGPL.
     # Use the SPDX identifier, e.g: GPL-2.0-only instead of GNU General Public License version 2.0
     # See
     license: MIT
     # The license_family, i.e. "BSD" if license is "BSD-3-Clause".
     # Optional
     license_family: MIT
     # It is required to include a license file in the package,
     # (even if the license doesn't require it) using the license_file entry.
     # Please also note that some projects have multiple license files which all need to be added using a valid yaml list.
     # See
     license_file: LICENSE.txt
     # The doc_url and dev_url are optional.
         - colintravisbrown
     #    # GitHub IDs for maintainers of the recipe.
     #    # Always check with the people listed below if they are OK becoming maintainers of the recipe. (There will be spam!)
     #    - LisaSimpson
     #    - LandoCalrissian
  3. Write build script files and bls.bat if noarch: python is not included.
    •—Shell script for macOS and Linux.
    • bld.bat—Batch file for Windows.
    • The 2 files and bld.bat must be in the same directory as your meta.yaml file.


    • Type exactly as shown below in bld.bat
        "%PYTHON%" install
        if errorlevel 1 exit 1  

    • Type exactly as shown below in
        $PYTHON install     # Python command to install the script.
  4. Building and Installing
    • Run conda-build:
        conda-build click
    • If the package has dependencies, link the channel containing them when doing conda build.
        conda build -c conda-forge --output-folder .
    • When conda-build is finished, it displays the package filename and location.
    • Install your newly built program on your local computer by using the use-local flag:
        conda install --use-local click
  5. Uploading new packages to
    • Open an account on
    • Run the command conda install anaconda-client, enter your username and password.
    • Log into your account with the command:
        anaconda login
    • Upload your package to
        anaconda upload ~/miniconda/conda-bld/linux-64/click-7.0-py37_0.tar.bz2
  6. Installing the package after uploading it
    • First, create a new virtual environment using conda and then activate it.

        conda create -n envName python=3.10 -y
        conda activate envName
        conda install -c account_name -c conda-forge package-name

Site Last Updated: August 11, 2023