python项目 如何发布项目到pypi 让用户使用pip安装

传统的项目文件每次上传都需要进行一次git拉取下来再进行安装,在朋友的指导下决定将相应的python项目发布到pypi上让用户使用pip直接安装

一.项目结构参考

python项目 如何发布项目到pypi 让用户使用pip安装_第1张图片

二.具体步骤参考
1.注册用户
https://pypi.org/account/register/
2.安装twine依赖
pip install twine
3.创建setup.py文件
# -*- coding: utf-8 -*-
# @Time    : 2020/10/12 9:10
# @Author  : 
from setuptools import setup, find_packages
import pathlib
here = pathlib.Path(__file__).parent.resolve()
long_description = (here / 'README.md').read_text(encoding='utf-8')
setup(
    name="hbase-thrift-py-sdk",
    version="2.0.0",
    license='MIT',
    # 简介
    description='Use elaticsearch to search hbase',
    url='http://gitlab.weyesns.com/jcsp/library/hbase-thrift-py-sdk',
    long_description=long_description,
    long_description_content_type='text/markdown',
    packages=find_packages(),
    # 安装包中包含的非py文件
    package_data={
        'hbase_thrift': ['Hbase.thrift']},
    # 另外的一些文件
    data_files=[('.', ['README.md', 'requirements.txt'])
                ],
    include_package_data=True,
    platforms='any',
)

4.创建setup.cfg文件
[metadata]
# This includes the license file(s) in the wheel.
# https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-file
license_files = LICENSE.txt
5.创建MANIFEST.in文件
include test.py

# Include the license file
include LICENSE.txt
6.创建许可证LICENSE.txt文件
MIT License

Copyright (c) [2020] [Cocktail_py]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7.打包项目
pip install wheel
python setup.py bdist_wheel --universal
8.发布项目
twine upload dist/*

python项目 如何发布项目到pypi 让用户使用pip安装_第2张图片
python项目 如何发布项目到pypi 让用户使用pip安装_第3张图片

参考官网

利用es实现的hbase二级索引作品

你可能感兴趣的:(个人学习记录,python,pip)