在工作中,别组同事要求我们把代码上传至pip源,经过仔细的研究成功上传并记录如下:
- 注册pypi的账号
- 安装setuptools:https://pypi.python.org/pypi/setuptools
- 下载ez_setup.py:https://bootstrap.pypa.io/ez_setup.py
- 执行:python ez_setup.py
- 配置~/.pypirc文件:(windows下需要在cmd中使用rename命令才行)
- [distutils]
index-servers =
pypi
[pypi]
username:******
password:******
- 编写setup.py:
-
from setuptools import setup, find_packages setup( name='$PROJECT_NAME', version='$VERSION', keywords = ('$KEYWORD1', '$KEYWORD2'), description='blah blah blah ...', license='Free', author='***', author_email='***@***.com', url='http://***************', platforms = 'any', packages = find_packages('absolute path or relative path of src'), package_dir = {'':'absolute path or relative path of src'}
)
-
- 注册项目:
- python setup.py register
- 打包并上传
- python setup.py sdist upload