[Python] Package Management - Nexus

  • 213
  • 0
  • 2021-03-25

How to upload pkg to nexus

Windows

在使用者目錄底下新增下列檔案

c:\Users\{YOUR_NAME}\.pypirc

內容如下

[distutils]
index-servers=nexustest
 
[nexustest]
repository = http://{NEXUS_URL}:8081/repository/pypi-internal/
username = {USER}
password = {PASSWORD}
 
 

在python專案目錄中

新增 檔案

README.md 

setup.py

import setuptools

with open("README.md", "r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="demo", # Replace with your own username
    version="0.0.1",
    author="AUTHOR",
    author_email="EMAIL",
    description="A small example package",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="THE REPO URL",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires='>=3.6',
)

打包

 python setup.py sdist bdist_wheel

upload

 twine upload -r nexustest dist/* --verbose

download 

pip install demo -i http://{NEXUS_URL}:8081/repository/pypi-internal/simple --trusted-host {NEXUS_URL}