我试图测试将库升级为pypi,我只是做了一个非常简单的例子

问题描述

文件夹和文件的结构:

Immage

README.txt中的所有文本

This is a verry simple calculator.

CHANGELOG.txt中的所有文本

Change Log
==========

0.0.1 (19/10/2020)
-------------------
- First Release

LICENCE.txt中的所有文本(用------- ------删除了我的名字)

Copyright 2020 ------- -----

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.

MANIFEST.in中的所有文本

global-include *.txt *.py

__init__.py中的所有文本

def add_num(num1,num2):
    return num1 + num2

def subtract_num(num1,num2):
    return num1 - num2

def multiply_num(num1,num2):
    return num1 * num2

def divide_num(num1,num2):
    return num1 / num2

def exponent_num(num1,num2):
    return num1 ** num2

setup.py中的所有测试(已删除我的电子邮件和姓名)

from setuptools import setup,find_packages

classifiers = [
    'Development Status :: 5 - Production/Stable','Intended Audience :: Education','Operating System :: Microsoft :: Windows :: Windows 10','License :: OSI Approved :: MIT License','Programming Language :: Python :: 3'
]

setup(
    name='martinsimplecalculator',version='0.0.1',description='a basic calculator',long_description_content_type='txt',long_description=open('README.txt').read() + '\n\n' + open('CHANGELOG.txt').read(),url='',author='----',author_email='----',license='MIT',classifiers=classifiers,keywords='calculator',packages=find_packages(),install_requires=['']

)

其余文件是使用以下命令制作的:

python3 setup.py sdist

在我输入后:

twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

并输入我的用户名和密码,我收到此错误:

HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information.

请帮助我从未做过,并且我一直在关注this youtube视频

解决方法

内容类型txt不是有效的内容类型,对于纯文本,您应该使用text/plain

long_description_content_type='text/plain',

此外,您似乎在使用setuptools之前的旧版本long_description_content_type,应该升级到最新版本:

$ python3 -m pip install -U setuptools

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...