私仓地址:http://nexus.xxxprivate.com/#browse/search/pypi
1、绑定我们的私仓地址
pip install flask -i http://nexus.xxxprivate.com/repository/pypi/simple 地址如下图,末尾加“/simple”
2、编写nexus的python配置
在用户目录下编辑.pypirc vim ~/.pypirc
[distutils]
index-servers =
pypi
nexus
[pypi]
repository:http://nexus.xxxprivate.com/repository/local-pypi/
username:admin
password:Nexus123
[nexus]
repository=http://nexus.xxxprivate.com/repository/local-pypi/
username=admin
password=Nexus123
repository地址是hosted的地址
3、安装打包工具twine
pip install twine
4、编写打包文件
编写打包文件setup.py,切记要和主项目在统一目录下,比如:和nicekit同级目录 find_packages包可以直接冲install_requires中拉取相关的依赖
from setuptools import setup, find_packages
setup(
name='nicekit',
version='1.0.1',
description='This is nicekit of the setup',
author='xxx',
author_email='xxx@qq.com',
url='https://www.xxxx.com',
install_requires=['pymysql', 'redis', 'pyhs2', 'toolkit'],
packages=find_packages(),
)
5、打包,提交
python setup.py sdist bdist_wheel twine upload -r nexus dist/*
6、拉取使用
修改requirements.txt文件
--index-url http://nexus.xxxprivate.com/repository/pypi/simple/
--trusted-host nexus.xxxprivate.com
nicekit==1.0.1
导入pip install -r requirements.txt
|