准备
首先,你需要一个 setup.py
文件
这是我一个程序中的例子:portstat
from setuptools import setup, find_packages
from os import path
from codecs import open
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='portstat',
version='0.0.3',
keywords=('port', 'monitor', 'traffic'),
url='https://github.com/imlonghao/portstat',
license='Apache License 2.0',
author='imlonghao',
author_email='fbi@fastmail.com',
description='A simple port traffic monitor',
long_description=long_description,
packages=find_packages(),
platforms='any',
entry_points={
'console_scripts': [
'portstat=portstat.portstat:main'
]
}
)
发布
python setup.py bdist_egg
python setup.py sdist
python setup.py register
python setup.py sdist upload
测试服务器
python setup.py register -r "https://testpypi.python.org/pypi"
python setup.py sdist upload -r "https://testpypi.python.org/pypi"
安装的话就是通过-i 参数指定服务器
pip install -i "https://testpypi.python.org/pypi" portstat