【问题标题】:Unknown distribution format: '' when uploading to PyPI via Twine未知的分发格式:'' 通过 Twine 上传到 PyPI 时
【发布时间】:2021-03-29 20:23:49
【问题描述】:

我正在尝试使用twine 更新infixpy 的版本。这是我的~/.pypirc

index-servers =
  pypi
  pypitest

[pypi]
repository: https://upload.pypi.org/legacy/ 
username: myuser
password: mypassword

[pypitest]
repository: https://upload.testpypi.org/legacy
username: myuser
password: mypassword

这里是命令行:

python setup.py build
twine upload -r  pypi dist/

InvalidDistribution: Unknown distribution format: '' 出现上传错误

这是完整的输出:

Processing dependencies for infixpy==0.0.6
Finished processing dependencies for infixpy==0.0.6
Processing /Users/steve/git/infixpy
Building wheels for collected packages: infixpy
  Building wheel for infixpy (setup.py) ... done
  Created wheel for infixpy: filename=infixpy-0.0.6-py3-none-any.whl size=43459 sha256=01fed46f42fa86475079636a55685c93521989aa0ba6558726a9d35c01004b7a
  Stored in directory: /private/var/folders/d6/m67jyndd7h754m3810cl3bpm0000gp/T/pip-ephem-wheel-cache-1bizg6_y/wheels/47/66/74/d79a56979feba04c8ef05e12fe861cacf813cecd397e57071f
Successfully built infixpy
Installing collected packages: infixpy
  Attempting uninstall: infixpy
    Found existing installation: infixpy 0.0.6
    Uninstalling infixpy-0.0.6:
      Successfully uninstalled infixpy-0.0.6
Successfully installed infixpy-0.0.6
Uploading distributions to https://upload.pypi.org/legacy/
InvalidDistribution: Unknown distribution format: ''

我的发布过程需要进行哪些更正?我在 macOS 上使用 Python 3.7。

【问题讨论】:

  • 它需要一个文件dist/ 是一个目录,所以你最终会到达github.com/pypa/twine/blob/…
  • 嗯。我过去曾使用过这种方法:事实上,我是从成功使用的自定义安装脚本中运行它的。也许麻绳出版改变了?哦 - 我错过了“/dist”之后的“*”
  • 我将其更改为引用.egg,它确实有效。你可以让它成为一个答案

标签: python pypi twine


【解决方案1】:

每个the docstwine upload(强调我的):


positional arguments:
  dist                  The distribution files to upload to the repository
                        (package index). Usually dist/* . May additionally
                        contain a .asc file to include an existing signature
                        with the file upload.

您传递的是 目录,而不是 文件 - 正如文档建议的那样,您可能想要 dist/*。如果您传递一个目录,则没有已知发行版的匹配项,因为这些是基于文件扩展名的,所以您最终会得到this error case

        else:
            raise exceptions.InvalidDistribution(
                "Unknown distribution format: '%s'" % os.path.basename(filename)
            )

目录的basename'',因此输出不太有用。

【讨论】:

    【解决方案2】:

    在 dist/ 之后添加 * 像这样:twine upload -r pypi dist/*

    但是为什么?

    因为 dist/ 是一个目录,它希望上传一个文件,而不是任何目录。 因此,文件将是 dist 文件夹中的 all(*) 文件

    【讨论】:

      猜你喜欢
      • 2018-03-18
      • 2020-09-22
      • 1970-01-01
      • 2020-10-15
      • 1970-01-01
      • 2018-05-15
      • 2017-12-11
      • 1970-01-01
      • 2017-03-18
      相关资源
      最近更新 更多