1. 注册pypi
  2. pipi分发配置

    编辑根目录的.pypirc文件

vim ~/.pypirc

内容如下:

[distutils]
index-servers=pypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = <Pypi用户名>
password = <Pypi密码>
  1. 源码参考格式
.
├── LICENSE
├── MANIFEST.in
├── README.md
├── logz
│ └── __init__.py
├── setup.py
└── tests
├── __init__.py
└── test_logz.py

ptest插件项目结构参考

├── LICENSE
├── MANIFEST.in
├── README.md
├── pytest_owner
│ ├── __init__.py
│ └── plugin.py
├── setup.py
└── tests
└── test_pytest_owner.py
  1. setup.py 参考格式

setup.py参考

import os
from setuptools import setup, find_packages

this_directory = os.path.abspath(os.path.dirname(__file__))
setup_requirements = []


def read_file(filename):
with open(os.path.join(this_directory, filename), encoding='utf-8') as f:
long_description = f.read()
return long_description


setup(
author="Han Zhichao",
author_email='superhin@126.com',
description='easy log use for extra infos',
long_description=read_file('README.md'),
long_description_content_type="text/markdown", # 新参数
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.7',
],
license="MIT license",
include_package_data=True,
keywords=[
'logz', 'extra', 'log',
],
name='logz',
packages=find_packages(include=['logz']),
setup_requires=setup_requirements,
url='https://github.com/hanzhichao/logz',
version='0.16',
zip_safe=True,
install_requires=[]
)

pytest插件setup.py参考

import os
from setuptools import setup, find_packages

this_directory = os.path.abspath(os.path.dirname(__file__))
setup_requirements = ['pytest-runner', ]


def read_file(filename):
with open(os.path.join(this_directory, filename), encoding='utf-8') as f:
long_description = f.read()
return long_description

setup(
author="Han Zhichao",
author_email='superhin@126.com',
description='Add owner mark for tests',
long_description=read_file('README.md'),
long_description_content_type="text/markdown",
classifiers=[
'Framework :: Pytest',
'Programming Language :: Python',
'Topic :: Software Development :: Testing',
'Programming Language :: Python :: 3.6',
],
license="MIT license",
include_package_data=True,
keywords=[
'pytest', 'py.test', 'pytest-owner', 'test owner', 'pytest tester'
],
name='pytest-owner',
packages=find_packages(include=['pytest_owner']),
setup_requires=setup_requirements,
url='https://github.com/hanzhichao/pytest-owner',
version='0.1',
zip_safe=True,
install_requires=[
'pytest',
'pytest-runner'
],
entry_points={
'pytest11': [
'pytest-owner = pytest_owner.plugin',
]
}
)
  1. 安装twine包
pip install twine
  1. 在项目中运行以下命令发布项目
python setup.py sdist
twine upload dist/*