7

I have users that create both conda and pip packages- I have no control over this

I use artifactory to host private conda and pip repos, for example this is how a private pip repo works: https://www.jfrog.com/confluence/display/JFROG/PyPI+Repositories

Sometimes there is a private pip package a conda environment or package needs. How can I configure conda to get my private pip packages from my private repo?

I haven't found documentation on this. I would like for this to be transparent for users as much as possible- so they set up their config once and in their conda environment they can easily specify a private pip package and it just works

red888
  • 27,709
  • 55
  • 204
  • 392

1 Answers1

12

Conda won't search PyPI or alternative pip-compatible indexes automatically, but one can still use the --index-url or --extra-index-url flags when using pip install. E.g.,

Ad Hoc Installation

# activate environment
conda activate foo

# ensure it has `pip` installed
conda list pip

# install with `pip`
pip install --extra-index-url http://localhost:8888 bar

YAML-based environments

foo.yaml

name: foo
channels:
  - defaults
dependencies:
  - python
  - pip
  - pip:
    - --extra-index-url http://localhost:8888
    - bar

Environment creation

conda env create -f foo.yaml
merv
  • 67,214
  • 13
  • 180
  • 245
  • But it will read my .pypirc to get username and password right? Otherwise how does it authenticate to the private repo? Do I have to manually pip install or will conda of fetch my creds from pypirc during a conda install/create/update/etc? – red888 Dec 20 '20 at 18:53
  • 1
    @red888 [as per docs](https://pip.pypa.io/en/stable/user_guide/#basic-authentication-credentials), it looks like you can use a `.netrc` file, keyring, or simply put the credentials in the URL. – merv Dec 20 '20 at 19:03
  • Interesting that does not appear in the jfrog docs for configuring a private pypi repo. So for conda I would need to use netrc because it ignores pypirc? – red888 Dec 20 '20 at 19:21
  • @red888 not sure. TBH, I've never used a `.pypirc`; [docs seem to indicate](https://packaging.python.org/specifications/pypirc/) that it is only for *uploading to repositories*, in which case it's not Conda ignoring it, but it's `pip` that doesn't use it. – merv Dec 20 '20 at 19:27
  • how do I specify `--extra-index-url` in a meta.yaml? – red888 Dec 21 '20 at 15:53
  • @red888 maybe I misunderstood. Conda builds of packages cannot depend on Pip-installed packages. – merv Dec 22 '20 at 00:49