Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus repository manager as pip local server not working properly

A local nexus server has been setup as our pip local server. I'm trying to install a sample/test class (inherits) using the said local server. Uploading to the local server is successful, but installing using this command:

pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits

Resulted to this:

  Could not find a version that satisfies the requirement inherits 
  (from versions: )
  No matching distribution found for inherits

I also tried these commands, but the results are the same:

pip install inherits
pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits-0.1
pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits==0.1

Here're the contents of my ~/.pypirc:

[distutils]
index-servers =
    nexus
    pypi

[nexus]
username: my-username
password: mypassword
repository: http://<nexus-ip>:8081/nexus/repository/pypi-internal/

[pypi]
...

Here're the contents my ~/.config/pip/pip.conf

[global]
index = http://<nexus-ip>:8081/repository/pypi-all/pypi
index-url = http://<nexus-ip>:8081/repository/pypi-all/simple

As mentioned, uploading using below command is successful:

python setup.py sdist upload -r nexus

Response from the nexus server is here (i.e. signifies upload was successfull):

creating inherits-0.1
creating inherits-0.1/inherits
creating inherits-0.1/inherits.egg-info
copying files to inherits-0.1...
copying setup.cfg -> inherits-0.1
copying setup.py -> inherits-0.1
copying inherits/__init__.py -> inherits-0.1/inherits
copying inherits/addmult.py -> inherits-0.1/inherits
copying inherits/inherits.py -> inherits-0.1/inherits
copying inherits/subdiv.py -> inherits-0.1/inherits
copying inherits.egg-info/PKG-INFO -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/SOURCES.txt -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/dependency_links.txt -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/top_level.txt -> inherits-0.1/inherits.egg-info
Writing inherits-0.1/setup.cfg
Creating tar archive
removing 'inherits-0.1' (and everything under it)
running upload
Submitting dist/inherits-0.1.tar.gz to http://<nexus-ip>:8081/nexus/repository/pypi-internal/
Server response (200): OK

Contents of the setup.py are the basic details:

#!/usr/bin/env python

import os
import sys

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

requires = []

setup( 
    name = "inherits",
    packages = ["inherits"],
    version = '0.1',
    description = 'Example inherits package',
    #url = "",
    #download_url = "",
    author = "Jayson Pryde",
    classifiers = [],
)

Any ideas on how to resolve this and make the pip install work? Thanks in advance!

like image 462
jaysonpryde Avatar asked Jan 23 '17 07:01

jaysonpryde


4 Answers

In case someone has encountered the same issue and is interested for a solution, here are two things I did.

1. Execute pip using this:

pip install inherits -i http://<nexus-ip>:8081/nexus/repository/pypi-all/simple -v --trusted-host <nexus-ip>

The -v and --trusted-host parameters are optional

2. Move your ~/.config/pip/pip.conf to ~/.pip/pip.conf and execute:

pip install inherits -v —trusted-host <nexus-ip>

Only challenge encountered with #2 is pip will always connect to the nexus server. So in case I want to connect to pypi.org, I have to rename the pip.conf first.

Hope this helps someone!

like image 141
jaysonpryde Avatar answered Sep 19 '22 12:09

jaysonpryde


I ran into the same problem. I used the following steps to solve it. It works flawlessly now.

In the following steps replace pypi-mw with your private nexus pypi registry name.

Add Nexus user with all necessary privileges

Create a new role. Filter all privileges by your pypi-registry name and add them all. Apply the new role to your user (you can fine-grain priveleges later):

enter image description here

Edit .pypirc for upload credentials

Put this into ~/.pypirc

[distutils]
index-servers =
    pypi
    pypi-mw

[pypi]
repository: https://pypi.python.org/pypi
username: peter

[pypi-mw]
repository: https://my-private-registry.com/repository/pypi-mw/
username: peter

Edit pip.conf for download credentials

Put this into ~/.pip/pip.conf:

[global]
index = https://pypi.python.org/pypi/
index-url=https://pypi.python.org/simple/
extra-index-url=https://MY-NEXUS-USER:[email protected]/repository/pypi-mw/simple/
trusted-host = my-private-registry.com

Try it out

If everything works like it should, you now have the option to upload your packages to pypi like this:

python setup.py bdist_wheel upload

Or to your private registry:

python setup.py bdist_wheel upload -r "pypi-mw"

To install a package you can run the usual command:

pip install mypackage --user 

It should now search both registries (pypi and pypi-mw) for your package.

like image 30
Rotareti Avatar answered Sep 19 '22 12:09

Rotareti


I have encountered the same issue, and I resolved it by adding pypip-read and pypip-browse role to my anonymous user on Nexus.

like image 23
Kyrremann Avatar answered Sep 20 '22 12:09

Kyrremann


Configuring pip with nexus repository in Windows

Create pip.ini in the folder %APPDATA%/pip/pip.ini, in your case go to your own %APPDATA% folder then create a text file pip.ini under pip folder

In my local m/c %APPDATA% is C:\Users\username\AppData\Roaming>

Add below lines in pip.ini

[global]
trusted-host=nexus.example.com:8443
index = https://nexus.example.com/repository/pypi-group/pypi
index-url = https://nexus.example.com/repository/pypi-group/simple
no-cache-dir = false

Then you can run the pip command from your windows command prompt

like image 31
akarahman Avatar answered Sep 19 '22 12:09

akarahman