Dans Dev Diary 2.0 Help

Configure Nexus As a Proxy for PyPi

Setup in Nexus

Firstly, you will need to setup a proxy for Pypi repository in Nexus. This will act as a cache for the packages that are downloaded from Pypi.

To do this, follow the steps below:

Configure Pypi Proxy

  1. From the Nexus Dashboard, click on the `Settings` cog in the top right corner.

  2. From the left hand menu, click on `Repositories`

  3. Click on the `Create repository` button

  4. Select `PyPi (proxy)`

  5. Nexus proxy pypi

    Enter the following details:

    • Repository ID: `pypi-proxy`

    • Repository Name: `PyPi Proxy`

    • Remote Storage: `https://pypi.org/`

Next, associate the proxy with a group, this will allow you to use the proxy as a source for packages both from Pypi and from any private repositories you create.

Setup Nexus Group

  1. From the Nexus Dashboard, click on the `Settings` cog in the top right corner.

  2. From the left hand menu, click on `Repositories`

  3. Click on the `Create repository` button

  4. Select `PyPi (group)`

  5. Enter the following details:

    • Repository ID: `pypi-group`

    • Repository Name: `PyPi Group`

  6. Click on the `Add` button in the `Member repositories` section

  7. Select the `pypi-proxy` repository and click on `Add selected`

Setting up pip.conf

  1. Create a file called `pip.conf` either globally or within the venv.

  2. Open the file and add the following:

    [global] index = https://$DOMAIN/repository/pypi-group/pypi index-url = https://$DOMAIN/repository/pypi-group/simple [pypi] repositroy: https://$DOMAIN/repository/pypi-group/
  3. Replace `$DOMAIN` with the domain of your Nexus server. Now to test, run the following command:

    pip -v install requests

    verify that the package is downloaded via your Nexus server. by checking the domain.

Last modified: 20 November 2023