pypi上发布包

在项目目录执行下面的操作:

配置文件:

import io
import os
from setuptools import setup, find_packages

with io.open(os.path.join("docs", 'index.rst'), encoding='utf-8') as f:
    readme = f.read()

with io.open('requirements.txt') as f:
    requirements = f.readlines()

setup(
    name="xxx",
    version="0.0.1",
    url='https://github.com/',
    author='James',
    author_email='xxx@xxx.com',
    maintainer='James',
    maintainer_email='xxx@xxx.com',
    description='xxx',
    long_description=readme,
    license="MIT",
    packages=find_packages(),
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: Implementation :: CPython',
        'Programming Language :: Python :: Implementation :: PyPy',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: MIT License',
        'Topic :: Database',
    ],
    install_requires=requirements,
)

requirements.txt 填写依赖关系.

docs/index.rst 填写文档

 

检查:

 python setup.py check

输出一般是running check

如果有错误或者警告,就会在此之后显示

没有任何显示表示Distutils认可你这个setup.py文件。

 

打包为源码包:

python setup.py sdist build

 

上传生成的包:

可以使用setuptools,或者twine上传,推荐使用twine上次,因为使用setuptools上传时,你的用户名和密码是明文或者未加密传输,安全起见还是使用twine吧

python setup.py sdist upload

使用twine上传,先安装twine

pip install twine

twine upload dist/*

 

文件包含的设置:

新建文件MANIFEST.in,常用的如下:

recursive-include docs *
include LICENSE

第一行 recursive-include 表示递归包含 docs 目录下的所有

第二行 include 表示包含 LICENSE 这一个文件

 

错误提示:

出现

HTTPError: 400 Client Error: File already exists. See https://upload.pypi.org/help/#file-name-reuse for url: https://upload.pypi.org/legacy/

请清理掉 build 和 dist 目录

转载于:https://my.oschina.net/zhupengdaniu/blog/1633312

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值