最重要的是正确准备您的setup.py。那么:
-
setup.py sdist bdist_wheel 生成分发档案到dist/ 文件夹
-
twine upload dist/* 将档案上传到 PyPi(使用您的 PyPi 用户名/密码)
这里是setup.py的例子:
from setuptools import setup, find_packages
with open('README.md') as readme_file:
README = readme_file.read()
with open('HISTORY.md') as history_file:
HISTORY = history_file.read()
setup_args = dict(
name='elastictools',
version='0.1.2',
description='Useful tools to work with Elastic stack in Python',
long_description_content_type="text/markdown",
long_description=README + '\n\n' + HISTORY,
license='MIT',
packages=find_packages(),
author='Thuc Nguyen',
author_email='gthuc.nguyen@gmail.com',
keywords=['Elastic', 'ElasticSearch', 'Elastic Stack', 'Python 3', 'Elastic 6'],
url='https://github.com/ncthuc/elastictools',
download_url='https://pypi.org/project/elastictools/'
)
install_requires = [
'elasticsearch>=6.0.0,<7.0.0',
'jinja2'
]
if __name__ == '__main__':
setup(**setup_args, install_requires=install_requires)
你可以在这里找到更详细的教程:https://medium.com/@thucnc/how-to-publish-your-own-python-package-to-pypi-4318868210f9