How can I host my own private conda repository?

前端 未结 3 529
抹茶落季
抹茶落季 2020-12-04 18:01

I have a few python projects that are dependent on each other. I have different release versions for each project and different projects might be dependent on different rele

3条回答
  •  没有蜡笔的小新
    2020-12-04 18:43

    There are two parts to this: how to create the channel and how to use it. Part two is the hardest to do nicely.

    The first part is described in detail in the conda documentation. You can serve the channel directly from files, or via a static webserver.

    To use the channel, one approach is the -c file://tmp/my-conda-channel/, but recent conda versions allow a much better solution via custom channels which where (recently?) added to conda.

    The documentation is available via conda config --describe which includes this part:

    # custom_channels (map: str)
    #   A map of key-value pairs where the key is a channel name and the value
    #   is a channel location. Channels defined here override the default
    #   'channel_alias' value. The channel name (key) is not included in the
    #   channel location (value).  For example, to override the location of
    #   the 'conda-forge' channel where the url to repodata is
    #   https://anaconda-repo.dev/packages/conda-forge/linux-64/repodata.json,
    #   add an entry 'conda-forge: https://anaconda-repo.dev/packages'.
    #
    # custom_channels: {}
    

    The syntax for adding a channel is not documented, but reading the source the correct invocation is seen to be:

    conda config --set custom_channels.my-conda-channel file://tmp/
    

    (Note: my-conda-channel/ is not part of path). With this added to your config, you can now use your own channel in the same way you would conda-forge or other 'built-in' channels:

    conda install -c my-conda-channel my-cool-package
    

    For anyone in an MS Windows setting, the correct set of slashes and backslashes for using this with a windows share is file://\\SOMECORP\Corp\conda\channels\. Works a charm.

提交回复
热议问题