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

本文介绍如何将Python项目发布到PyPI供用户通过pip安装。包括注册PyPI账号、安装twine、创建setup.py等步骤,并详细展示了配置文件的内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

一.项目结构参考

在这里插入图片描述

二.具体步骤参考
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/*

在这里插入图片描述
在这里插入图片描述

参考官网

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cocktail_py

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值