gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
34.36k stars 2.61k forks source link

gradio cc publish to twine broken on python 3.9 #7721

Closed duerrsimon closed 7 months ago

duerrsimon commented 8 months ago

Describe the bug

gradio cc publish fails on Python 3.9 with the following error:

 Uploading distributions to https://upload.pypi.org/legacy/
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/duerr/miniconda3/envs/gradio_customcomponents/lib/python3.9/site-packages/gradio/cli/comma │
│ nds/components/publish.py:196 in _publish                                                        │
│                                                                                                  │
│   193 │   │   │   │   if (not max_version or max_version in p.name)                              │
│   194 │   │   │   ]                                                                              │
│   195 │   │   │   print(f"Uploading files: {','.join(twine_files)}")                             │
│ ❱ 196 │   │   │   twine_upload(twine_settings, twine_files)                                      │
│   197 │   │   except Exception:                                                                  │
│   198 │   │   │   console.print_exception()                                                      │
│   199 │   if upload_demo and not demo_dir:                                                       │
│                                                                                                  │
│ /home/duerr/miniconda3/envs/gradio_customcomponents/lib/python3.9/site-packages/twine/commands/u │
│ pload.py:123 in upload                                                                           │
│                                                                                                  │
│   120 │   repository_url = cast(str, upload_settings.repository_config["repository"])            │
│   121 │   print(f"Uploading distributions to {repository_url}")                                  │
│   122 │                                                                                          │
│ ❱ 123 │   packages_to_upload = [                                                                 │
│   124 │   │   _make_package(filename, signatures, upload_settings) for filename in uploads       │
│   125 │   ]                                                                                      │
│   126                                                                                            │
│                                                                                                  │
│ /home/duerr/miniconda3/envs/gradio_customcomponents/lib/python3.9/site-packages/twine/commands/u │
│ pload.py:124 in <listcomp>                                                                       │
│                                                                                                  │
│   121 │   print(f"Uploading distributions to {repository_url}")                                  │
│   122 │                                                                                          │
│   123 │   packages_to_upload = [                                                                 │
│ ❱ 124 │   │   _make_package(filename, signatures, upload_settings) for filename in uploads       │
│   125 │   ]                                                                                      │
│   126 │                                                                                          │
│   127 │   repository = upload_settings.create_repository()                                       │
│                                                                                                  │
│ /home/duerr/miniconda3/envs/gradio_customcomponents/lib/python3.9/site-packages/twine/commands/u │
│ pload.py:77 in _make_package                                                                     │
│                                                                                                  │
│    74 │   filename: str, signatures: Dict[str, str], upload_settings: settings.Settings          │
│    75 ) -> package_file.PackageFile:                                                             │
│    76 │   """Create and sign a package, based off of filename, signatures and settings."""       │
│ ❱  77 │   package = package_file.PackageFile.from_filename(filename, upload_settings.comment)    │
│    78 │                                                                                          │
│    79 │   signed_name = package.signed_basefilename                                              │
│    80 │   if signed_name in signatures:                                                          │
│                                                                                                  │
│ /home/duerr/miniconda3/envs/gradio_customcomponents/lib/python3.9/site-packages/twine/package.py │
│ :117 in from_filename                                                                            │
│                                                                                                  │
│   114 │   │   ]                                                                                  │
│   115 │   │   if missing_fields:                                                                 │
│   116 │   │   │   supported_metadata = list(pkginfo.distribution.HEADER_ATTRS)                   │
│ ❱ 117 │   │   │   raise exceptions.InvalidDistribution(                                          │
│   118 │   │   │   │   "Metadata is missing required fields: "                                    │
│   119 │   │   │   │   f"{', '.join(missing_fields)}.\n"                                          │
│   120 │   │   │   │   "Make sure the distribution includes the files where those fields "        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
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.

Have you searched existing issues? 🔎

Reproduction

See above, the exact same package can be published after upgrading to python 3.10

Screenshot

No response

Logs

No response

System Info

python 3.9, gradio 4.21.0

Severity

I can work around it

freddyaboulton commented 8 months ago

Thanks will take a look! What version of twine are you using @duerrsimon ?

duerrsimon commented 8 months ago

It works with

twine version 5.0.0 (importlib-metadata: 7.0.2, keyring: 24.3.1, pkginfo:
1.10.0, requests: 2.31.0, requests-toolbelt: 1.0.0, urllib3: 2.2.1)

I believe the twine version before was 4.0.2. This is the only twine I could find in dist-info in my lib/python3.9/site-packages

freddyaboulton commented 8 months ago

This is a bug with twine: https://github.com/pypa/twine/issues/1070. same thing happened last night during the gradio release.

twine does not set a required version of pkginfo, so when hatch updated, twine didn't know how to read the metadata.

I don't think there's much we can do beyond raising an error in gradio. Will look into that.