我正在尝试上传我的包(
SyntenyQC
)以通过 Anaconda 提示符此处所述来测试 pypi。
我已经按照链接中的说明安装了
twine
和build
,并获得了一个带有wheel和gz文件的dist
文件夹。 但是,twine
会出现 Invalid distribution file
错误。
我通过右键单击而不是 ctrl v 复制我的令牌(避免 this 错误)。 我注意到 twine 的打印输出与教程的打印输出略有不同,这可能是相关的:
教程在链接:
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: __token__
Uploading example_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
...
我的回溯
Uploading distributions to https://test.pypi.org/legacy/
Enter your API token: ###this line###
Uploading syntenyqc-0.0.1-py3-none-any.whl
...
我的完整回溯如下。 我怀疑问题可能是我从 venv (
pip_env
) 中安装,因此将尝试重复我的基本环境中的所有内容。 与此同时,其他人可以提出任何明显的修复建议吗?
谢谢!
回溯(路径替代长路径):
(pip_env) C:\Users\username\.spyder-py3\SyntenyQC>pip install --upgrade twine
Requirement already satisfied: twine in path
Requirement already satisfied: urllib3>=1.26.0 in path (from twine) (1.26.16)
Requirement already satisfied: pkginfo>=1.8.1 in path (from twine) (1.10.0)
Requirement already satisfied: keyring>=15.1 in path (from twine) (23.13.1)
Requirement already satisfied: importlib-metadata>=3.6 in path (from twine) (6.0.0)
Requirement already satisfied: requests>=2.20 in path (from twine) (2.31.0)
Requirement already satisfied: readme-renderer>=35.0 in path (from twine) (44.0)
Requirement already satisfied: requests-toolbelt!=0.9.0,>=0.8.0 in path (from twine) (1.0.0)
Requirement already satisfied: rfc3986>=1.4.0 in path (from twine) (2.0.0)
Requirement already satisfied: rich>=12.0.0 in path (from twine) (13.7.1)
Requirement already satisfied: zipp>=0.5 in path (from importlib-metadata>=3.6->twine) (3.11.0)
Requirement already satisfied: jaraco.classes in path (from keyring>=15.1->twine) (3.2.1)
Requirement already satisfied: pywin32-ctypes>=0.2.0 in path (from keyring>=15.1->twine) (0.2.0)
Requirement already satisfied: nh3>=0.2.14 in path (from readme-renderer>=35.0->twine) (0.2.18)
Requirement already satisfied: Pygments>=2.5.1 in path (from readme-renderer>=35.0->twine) (2.15.1)
Requirement already satisfied: docutils>=0.21.2 in path (from readme-renderer>=35.0->twine) (0.21.2)
Requirement already satisfied: charset-normalizer<4,>=2 in path (from requests>=2.20->twine) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in path (from requests>=2.20->twine) (3.4)
Requirement already satisfied: certifi>=2017.4.17 in path (from requests>=2.20->twine) (2024.6.2)
Requirement already satisfied: markdown-it-py>=2.2.0 in path (from rich>=12.0.0->twine) (3.0.0)
Requirement already satisfied: mdurl~=0.1 in path (from markdown-it-py>=2.2.0->rich>=12.0.0->twine) (0.1.2)
Requirement already satisfied: more-itertools in path (from jaraco.classes->keyring>=15.1->twine) (8.12.0)
(pip_env) C:\Users\username\.spyder-py3\SyntenyQC>pip install --upgrade build
Requirement already satisfied: build in path (1.2.1)
Requirement already satisfied: pyproject_hooks in path (from build) (1.0.0)
Requirement already satisfied: colorama in path (from build) (0.4.6)
Requirement already satisfied: packaging>=19.1 in path (from build) (23.0)
Requirement already satisfied: tomli>=1.1.0 in path (from build) (2.0.1)
(pip_env) C:\Users\username\.spyder-py3\SyntenyQC>python -m build
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
- hatchling
* Getting build dependencies for sdist...
* Building sdist...
* Building wheel from sdist
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
- hatchling
* Getting build dependencies for wheel...
* Building wheel...
Successfully built syntenyqc-0.0.1.tar.gz and syntenyqc-0.0.1-py3-none-any.whl
(pip_env) C:\Users\username\.spyder-py3\SyntenyQC>python -m twine upload --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
Enter your API token:
Uploading syntenyqc-0.0.1-py3-none-any.whl
100% ---------------------------------------- 3.2/3.2 MB • 00:03 • 902.8 kB/s
WARNING Error during upload. Retry with the --verbose option for more details.
ERROR HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
Invalid distribution file.
编辑
在我的基础环境中运行全新安装的
build
、twine
和 hatchling
给我一个新的缠绕错误 :( :
(base) C:\Users\username\.spyder-py3\SyntenyQC>python -m twine upload --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
ERROR InvalidDistribution: Metadata is missing required fields: Name, Version.
Make sure the distribution includes the files where those fields are specified, and is using a supported Metadata-Version: 1.0, 1.1, 1.2, 2.0, 2.1, 2.2.
编辑2
更新 pkginfo 修复了编辑 1 中的错误,导致我回到相同的初始错误
编辑3
Twine 找不到文件的任何问题,因此不确定问题是什么:
(base) C:\Users\u03132tk\.spyder-py3\SyntenyQC>twine check dist/*
Checking dist\syntenyqc-1.0-py3-none-any.whl: PASSED
Checking dist\syntenyqc-1.0.tar.gz: PASSED
为了解决这个问题,我删除了包中包含的一些非 python 文件。