PIP mirror

How to configure a mirror for PIP

PIP is the package manager for Python and Nexus does support acting as a mirror.

Create blob store

Just like for APT and NPM we'll create a blobstore just for PIP. This will be called pip to follow the same guidelines.

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select blob store, then Create blob store
  3. Under Type select File
  4. Under Name enter pip
  5. Select Create blob store to create it.

Create pip/pypi mirror

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select Repositories then the Create Repository
  3. Select pypi (proxy) as the repository type.
  4. Now fill in the required fields.

    1. For name enter pypi-proxy
    2. For Remote storage enter the repository url https://pypi.org
    3. For Blob store select the one you created earlier, pip if you are following my naming conventions.
  5. Once it's all filled in select Save and the Repositories list should now show it.

Create pip/pypi group

This is optional. If you are going to just mirror the core pypi repository then you can skip this and just use pypi-proxy directly.

However, Nexus supports grouping multiple repositories together with a group, where if it cannot find an artefact in the first one it would check the next one. This is seamless to the client as all it knows about is there's a single repository.

One use-case for this is if you have a hosted repository where you store your own private artefacts. In this instance you'd create the proxy as above, then a pypi-hosted repository. The group would then include both of them as if it's just one.

I'd advise you should create the group with just pypi-proxy present as then your pip clients will use the group, and you can then seamlessly change the underlying proxies separately. For example, using an alternate upstream pypi repository instead of the default one. You can do the switch in nexus without changing any client.

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select Repositories then the Create Repository
  3. Select pypi (group) as the repository type.
  4. Now fill in the required fields:

    1. For name enter pypi-group
    2. Under member repositories you will see two lists.

      On the left hand side select the npm repositories you want to be a member of this group and select >. It should then appear on the right hand side.

      You can change the priority of the entries by selecting the repository name and clicking the up or down arrows. The higher a repository is in the list then they are checked first.

  5. Once it's all filled in select Save and the Repositories list should now show it.

Using the mirror

Once you have configured your repositories, you can then now point pip to use it. This is described in the Using Repository mirrors section.


Last modified February 11, 2022: Add PyPi repository config (081fa77)