pythonbuildpackagepypitwine

Twine/PyPI - Invalid distribution file


I am trying to upload my package (SyntenyQC) to test pypi as described here via Anaconda prompt.

I have installed twine and build as described in the link, and got a dist folder with a wheel and gz file. However, twine errors with Invalid distribution file.

I am copying my token via right-click not ctrl v (avoiding this error). I noticed that the printout of twine is slightly different from that of the tutorial, which may be relevant:

tutorial in link:

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
...

my traceback

Uploading distributions to https://test.pypi.org/legacy/
Enter your API token:                                    ###this line###
Uploading syntenyqc-0.0.1-py3-none-any.whl
...

My full traceback is below. I suspect the issue may be that I am installing from within a venv (pip_env) so will try repeating everything from my base env. In the meantime, can anyone else suggest any obvious fixes?

Thanks!

Traceback (path is a replacement for long paths):

(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.

EDIT

running in my base environment with fresh installs of build, twine and hatchling gives me a new twine error :( :

(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.

EDIT 2

Updating pkginfo fixed the error in edit 1, leading me back to the same initial error </3

EDIT 3

Twine can't find any issues with the files, so not sure what the issue is:

(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

Solution

  • In order to fix this, I removed some non-python files that were included in my package.