上传自己的包到pypi


1、首先要有自己的pypi账号,去官网注册

2、我的目录结构,其中build、cbot.egg-info以及dist是打包的时候生成的,并且最外层的叫什么都无所谓。但要确保setup.py和内层的这个是同级的,别把setup.py放到包文件夹里面去了。

 

3、导出requirements.txt文件(存放使用的依赖)

pip freeze > requirements.txt

4、书写README.md文件,该文件是可以显示到官网中的说明的。

我的部分说明:md的书写语法自行百度

5、新建MANIFEST.in文件,文件名必须是这个。

6、接下来书写setup.py文件,这个是最重要的

# coding=utf-8

from setuptools import setup, find_packages

with open("README.md", "r") as fh:
    long_description = fh.read()

setup(
    name='cbot',

    version="0.1.0",
    description=(
        'A chinese chat bot'

    ),
    long_description=open('README.md', 'r').read(),
    long_description_content_type="text/markdown",
    author='felix',
    author_email='felix2@foxmail.com',
    maintainer='felix',
    maintainer_email='felix2@foxmail.com',
    license='MIT License',
    packages=find_packages(),
    platforms=["ubuntu", 'windows'],
    url='https://github.com/wangyitao/cbot',
    classifiers=[
        'Development Status :: 4 - Beta',
        'Operating System :: OS Independent',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: Implementation',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
        'Topic :: Software Development :: Libraries'
    ],
    install_requires=[
        'sqlalchemy',
        'python-dateutil',
        'python-levenshtein',
        'requests',
    ]
)
setup.py

6、打包上传

打包前可以先检查一下。

python setup.py check

打包

python3 setup.py sdist build

上传,使用twine,pip install twine 安装

twine upload dist/*

上传成功否就能在自己的pypi账号中看到了。

但是并不是马上就能使用pip安装了。需要等待一段时间。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM