Search code examples
pythonnexuspypi

How to upload the python packages to Nexus sonartype private repo


I have configured the Nexus-OSS-3.14 private Python artifact server on aws cloud. I want to be maintain all my project related Python packages on my private repository server.

I downloaded the all the Python packages on my local Linux box and I want to be upload all the Python packages to private Python artifact server.

I have tried curl put request and I didn't upload and your help is needed to complete this.

I have tried curl put request:

curl -v -u admin:admin --upload-file boto3-1.9.76-py2.py3-none-any.whl https://artifact.example.com/repository/ASAP-Python-2.7-Hosted/

When I used that command and I get 404 response.


Solution

  • I think the recommended approach is to use twine, something like this should work:

    pip install twine
    twine upload --repository https://artifact.example.com/repository/ASAP-Python-2.7-Hosted/ boto3-1.9.76-py2.py3-none-any.whl
    

    It should ask for your username and password. To make life a bit easier you can create $HOME/.pypirc file with the URL, username and password

    [nexus]
    repository: https://artifact.example.com/repository/ASAP-Python-2.7-Hosted/
    username: admin
    password: admin
    

    Then when you call twine, do so like this:

    twine upload --repository nexus boto3-1.9.76-py2.py3-none-any.whl
    

    It's not a hard requirement, but if you're on multi user system and you've put a password in the file you should probably do

    chmod 600 $HOME/.pypirc