简体   繁体   English

未知的分发格式:'' 通过 Twine 上传到 PyPI 时

[英]Unknown distribution format: '' when uploading to PyPI via Twine

I am trying to update the version of infixpy using twine .我正在尝试使用twine更新infixpy的版本。 Here is my ~/.pypirc :这是我的~/.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

Here is the command line:这是命令行:

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

The upload errors out with InvalidDistribution: Unknown distribution format: '' InvalidDistribution: Unknown distribution format: ''

Here is the full output:这是完整的 output:

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: ''

What corrections are needed to my publishing process?我的发布过程需要哪些更正? I am on Python 3.7 on macOS.我在 macOS 上使用 Python 3.7。

Per the docs for twine upload (emphasis mine):根据twine 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.

You've passed a directory , not files - as the docs suggest, you probably want dist/* .您传递了一个directory ,而不是files - 正如文档所建议的那样,您可能想要dist/* If you pass a directory there are no matches for known distributions, as these are based on file extension, so you end up at this error case :如果您传递一个目录,则没有已知发行版的匹配项,因为这些是基于文件扩展名的,因此您最终会遇到以下错误情况

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

Thebasename for a directory is '' , hence the not-so-helpful output.目录的基本名称是'' ,因此basename不太有用。

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

But Why?但为什么?

Because dist/ is a directory and it expects a file to be uploaded, not any directory.因为 dist/ 是一个目录,它希望上传一个文件,而不是任何目录。 So, the files will be all(*) files inside dist folder因此,文件将是 dist 文件夹中的所有(*)文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM