Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 author name leads to Author-email field being encoded #531

Closed
foosel opened this issue Nov 9, 2022 · 6 comments
Closed

UTF-8 author name leads to Author-email field being encoded #531

foosel opened this issue Nov 9, 2022 · 6 comments

Comments

@foosel
Copy link

foosel commented Nov 9, 2022

I have a pyproject.toml containing my name and email in the authors field like this:

authors = [
  { name = "Gina Häußge", email = "[email protected]" }
]

Running python -m build generates the following in METADATA:

Author-email: =?utf-8?b?R2luYSBIw6R1w59nZSA8Z2luYUBvY3RvcHJpbnQub3JnPg==?=

That in turn leads to an error when attempting to upload such a package to testpypi (I haven't yet tried production pypi but I would expect it to behave exactly the same):

❯ python -m twine upload --repository testpypi dist/*
[...]
ERROR    HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
         '=?utf-8?b?R2luYSBIw6R1w59nZSA8Z2luYUBvY3RvcHJpbnQub3JnPg==?=' is an invalid value for Author-email. Error: Use a valid email address See https://packaging.python.org/specifications/core-metadata for more      
         information.

Should this maybe rather be =?utf-8?b?R2luYSBIw6R1w59nZQ==?= <[email protected]> in that Author-email field? Or maybe, given that Core metadata specifications says this:

Whenever metadata is serialised to a byte stream (for example, to save to a file), strings must be serialised using the UTF-8 encoding.

just leaving UTF-8 strings as is and including them in the file unencoded would be the best way, but I don't know what side effects that might have.

In my setup.py based packages, METADATA looks like this and that works just fine on upload:

Author: =?utf-8?b?R2luYSBIw6R1w59nZQ==?=
Author-email: [email protected]

So, if push comes to shove, splitting the values up like this might be the easiest solution to this issue, as already mentioned in #501. Being forced to write my name ASCII only certainly feels wrong in 2022 ;)

@foosel
Copy link
Author

foosel commented Nov 9, 2022

Addendum: twine check says "everything is great!" even with that Author-email field. I feel betrayed 😂

❯ twine check dist/*
Checking dist/OctoPrint_Setuptools-1.0.0-py3-none-any.whl: PASSED
Checking dist/OctoPrint-Setuptools-1.0.0.tar.gz: PASSED

@henryiii
Copy link
Contributor

henryiii commented Nov 9, 2022

This is a function of your build backend - what build backend are you using?

Addendum: twine check says "everything is great!"

twine check checks practically nothing. It's quite hard to find a bug it can catch. ;)

@abravalheri
Copy link
Collaborator

abravalheri commented Nov 9, 2022

Might be related to pypa/wheel#488, pypa/setuptools#3663

@FFY00
Copy link
Member

FFY00 commented Nov 9, 2022

build is simply a frontend for the build process, it just invokes the build backend, which I assume is setuptools. setuptools is the one creating the metadata file.

From my understanding, the METADATA file is not UTF-8, so each field needs to be manually encoded. Perhaps something broke there.

As @abravalheri pointed out, that wheel issue seems related.

@foosel
Copy link
Author

foosel commented Nov 9, 2022

Ah, thanks, yes, that wheel ticket looks very much like it.

For reference, my build system definition:

[build-system]
requires = [
    "setuptools>=40.8.0",
    "wheel"
]
build-backend = "setuptools.build_meta"

And apologies, I'm still getting my bearings with the fancy new stuff after coming from a decade of setup.py :)

In that case, happy to close this and sub to the wheel issue instead, thanks and apologies for the noise!

@foosel foosel closed this as completed Nov 9, 2022
@FFY00
Copy link
Member

FFY00 commented Nov 9, 2022

No worries, happy to help 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants