how to build and install a self-made conda package


I’m new to conda. Is there a way I can build the package somewhere, move it to another environment and install it without connect to the internet?

For example we want to have a package specifically for xgboost users. We want have these in the meta.yaml:

  name: xgboost-test
  version: 1.0 

    - "*"

# needs channels: conda-forge
    - python
    - pip
    - conda
    - python 
    - pip
    - nodejs
    - git
    - conda
    - nb_conda
    - papermill
    - pandas
    - pandas-profiling
    - plotly
    - requests
    - scikit-learn
    - scipy
    - google-api-core
    - urllib3
    - scikit-learn
    - xgboost==1.1.1

After building a new package which contains all above, we have a new package named xgboost-test-1.0.20221206-py37_0.tar.bz2.

Is there any way I can only move this new package to another computer and install it over there, without setting the channel, or not connect to the internew? I don’t think it’s convenient to setup a channel every time. I thought there is a way which I can simply install the new package file, that’s more quick and straight forward.

The best way I know is copy the whole channel folder to the new environment and install over there. The other way I know is to download the package file, use conda index to initialize the channel, and install it by conda install -c file:///path/to/local/channel. But I’m wondering if there is a way just move the package itself, not the whole channel folder. I thought there is a way which I can simply install the new package file, that’s more quick and straight forward.

I think conda-pack will work for what you need to do - Conda-Pack — conda-pack 0.7.0 documentation

This workflow works in simple cases:

conda install|create can take a package URL or a file path, but in that case it works in “explicit” mode, which means that the solver will not resolve the dependencies and only the contents of the package will be linked.

You can then conda install <your_pkg_name> --only-deps that environment so the solver fills the gaps. This might only work with the classic solver at this moment.

1 Like

You’re going to need the internet to install the deps anyway – so it depends a biton how complex the dependencies are – it may be quite straightforward. You can also create a separate “conda_requiriements” file, and install the dependencies that way.