Introduction

Conda is a popular package and environment management system primarily used with Python. It’s widely used in data science, scientific computing, AI, and bioinformatics, because it facilitates portability and reproducibility of (data) science workflows.

However, if your team needs to host private Conda packages, the typical recommendation is to build and manage your own Conda channel. While self-hosting a Conda channel is possible, it requires ongoing maintenance and infrastructure costs. Surprisingly, major package managers like Artifactory and PackageCloud don’t natively support Conda.

This guide will show you how to create a private Conda channel step by step, including:

  • How to build a simple Conda package (no prior experience needed).
  • How to set up a private Conda repository using RepoForge.
  • How to upload and install Conda packages from your private channel.

Step 1: Build a Simple Conda Package

Before setting up a private Conda channel, we need a sample package. We’ll create a simple “hello-world” Conda package that:

  • Contains a Python script (hello.py) that prints “Hello, Conda!”.
  • Includes a meta.yaml file defining package metadata.
  • Is built using Conda Build.

1.1 Install Conda Build Tools

Make sure you have Conda installed. If not, install Miniconda or Anaconda.

Then, install the Conda build tools:

conda install -y conda-build anaconda-client

1.2 Create the Package Structure

Run the following to create a directory for our package:

mkdir -p ~/conda-packages/hello-world
cd ~/conda-packages/hello-world

Now, create the Python script:

# hello-world/hello.py
def main():
    print("Hello, Conda!")

if __name__ == "__main__":
    main()

Next, define the package metadata. It should be called meta.yaml and stored in the same folder as the above Python script.

package:
  name: hello-world
  version: "1.0.0"

source:
  path: .

build:
  script: python -m hello

requirements:
  run:
    - python

about:
  summary: "A simple hello-world package for Conda"
  license: MIT

1.3 Build the Conda Package

Now, build the package using conda build:

conda build . --output-folder dist --output

The package should now be built in the dist folder. The above command should output the specific path to the build conda package to be uploaded — it should look something like this:

dist/osx-arm64/hello-world-1.0.0-0.conda

This package can now be uploaded to RepoForge.

Step 2: Create a Private Conda Repository on RepoForge

Now that we have a package, we need a private Conda repository to host it.

2.1 Sign Up for RepoForge

If you haven’t already, sign up for a free trial at RepoForge.io.

2.2 Create a New Conda Channel

Go to the RepoForge dashboard.

Click “Create new Conda channel” and give it a name (I used hello-world)

Step 3: Upload the Conda Package to RepoForge

Once you’ve created your private Conda channel, you can click on the Show push commands button to see how to publish packages to your Conda channel, which will show you a code snippet that looks something like this:

import requests

with open("dist/osx-arm64/hello-world-1.0.0-0.conda", "rb") as f:
    files = {'file': f}
    auth = ("your-email@example.com", "$REPOFORGE_PASSWORD")
    response = requests.post(
        'https://api.repoforge.io/conda/unique-hash-id/my-channel',
        files=files,
        auth=auth
    )
    assert response.status_code == 200

Essentially, all you need to do is POST your Conda package to the unique RepoForge.io URL shown in the above code snippet. It should just be a case of executing the above code, ensuring that you replace the following parts:

  • unique-hash-id with your organisation’s unique ID.
  • my-channel with the name of your desired Conda channel, e.g. hello-world
  • your-email@example.com and $REPOFORGE_PASSWORD with your RepoForge.io credentials.
  • Finally, ensure the file path is correct — it should match the output of your conda build command earlier

Once you’ve run the upload script, refresh the view in the RepoForge.io dashboard — you should see your package has been uploaded!

Step 4: Configure Conda to Use Your Private Channel

Now, let’s install the package from your private Conda repository.

In the RepoForge dashboard, click on the info icon next to your package to see the installation commands:

4.1 Install the conda-auth plugin

This step is only required if you created a private conda channel — if you’re using the free version of RepoForge, you won’t need to do this (although anybody with the link will be able to access your package)

The command for installing it is the first one in the above dialog:

conda install --name base --channel conda-forge conda-auth

4.2 Add Your Private RepoForge Channel

To configure Conda to use your private RepoForge repository, run the next snippet from the above dialog:

conda config --set custom_channels.hello-world <your-repoforge-repo-url>

4.3 Login with Conda auth

Again, this is only required for non-public Conda channels.

conda auth login -b hello-world --username <repoforge username> --password $REPOFORGE_PASSWORD

4.4 Install the Package

Now, install hello-world from your private Conda channel:

conda install -c hello-world hello-world=1.0.0

4.5 Verify Installation

You can now use the below command to verify that it worked

conda list -n conda-test | grep hello
hello-world               1.0.0                         0    hello-world

Done! Your private Conda package is now hosted, installed, and working correctly.

Next Steps: Automate Package Publishing

If you’re regularly updating and distributing Conda packages, you can:

  • Automate uploads with a simple script.
  • Set up CI/CD integration to publish new package versions automatically.
  • Control access with fine-grained permissions in RepoForge.

To explore more advanced workflows, check out the RepoForge Conda documentation.