PyPi is Python's online repository, and is where libraries are downloaded from when you run pip install.
To configure Nexus to proxy for this, first create a new blob store for its artifactsThis step is optional, if you want to store the cached artifacts in their own sub-directory..
Then create a new repository, of type pypi (proxy).
To configure the repo:
- Give the repo a name (e.g. pypi-proxy).
- Use the suggested URL for the remote repository (https://pypi.org).
- If you want to make downloaded artifacts immutable, set the Maximum component age to -1.
- Configure the blob store you want to keep downloaded artifacts in.
On the client computer, we need to tell pip that it should download libraries from our instance of Nexus, instead of the usual pypi.org. This is done via a pip.conf file, and can be done either globally for the entire computer, per-user, or per-project.
Run pip config -v list to find out where the file locations are.
Then, create a pip.conf file that looks like this:
[global] index = http://nexus3:8081/repository/pypi-proxy/pypi index-url = http://nexus3:8081/repository/pypi-proxy/simple trusted-host = nexus3
If we now pip install something, we can see it downloading from our Nexus instance, instead of the usual Python servers.
If we go back to the Nexus admin console, we can see the downloaded artifacts, where they will be available the next time they are requested.
And if we check the Nexus data directory on the server, we can see that some new files have been created to store the cached artifacts.
|↵1||This step is optional, if you want to store the cached artifacts in their own sub-directory.|