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

poetry publish fails for package with . in its name. #5782

Closed
2 tasks done
nekitdev opened this issue Jun 6, 2022 · 18 comments
Closed
2 tasks done

poetry publish fails for package with . in its name. #5782

nekitdev opened this issue Jun 6, 2022 · 18 comments
Labels
area/publishing Related to PyPI/PEP 503 publishing kind/bug Something isn't working as expected version/1.2.1

Comments

@nekitdev
Copy link

nekitdev commented Jun 6, 2022

Issue

For packages with . in the name:

[tool.poetry]
name = "example.py"

Poetry correctly builds wheels and sdists with example.py in the file name.
However, when uploading to PyPI with the canonical name (i.e. example-py), poetry publish fails with the following error:

HTTP Error 400: Start filename for 'example-py' with 'example-py'.
@nekitdev nekitdev added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 6, 2022
@mkniewallner
Copy link
Member

According to https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode, it seems that the right thing to do for wheels would be to replace . with _ for the distribution name.

Though even if doing so, a bug in warehouse (the backend behind PyPI) may prevent the upload from working: pypi/warehouse#10030.

@nekitdev
Copy link
Author

nekitdev commented Jun 7, 2022

It seems as though Poetry attempts to publish example-py with files containing example.py, causing PyPI to return the error above. I have hooked canonicalize_name function to see if PyPI allows uploading with example.py as the name, which it apparently does. So I'm assuming the mismatch is what causes the error.

@nekitdev
Copy link
Author

nekitdev commented Jun 7, 2022

Once again, I'm not exactly sure how to solve this issue, though.

@neersighted
Copy link
Member

Once again, I'm not exactly sure how to solve this issue, though.

We've already got a PR under review that uses the same logic pip does to canonicalize wheel names.

@nekitdev
Copy link
Author

nekitdev commented Jun 7, 2022

Oh, I see, thanks! I'm looking forward to it. :)

@NiklasRosenstein
Copy link

Hello, what's the progress on the PR @neersighted? I'm running into the same issue.

I'm a bit surprised because on 20th of June (so only two weeks back), I was able to publish a package with . in the name: https://pypi.org/project/databind.core/2.0.7/#files

But today I get

400 Client Error: Start filename for 'databind-core' with 'databind-core'. for url: https://upload.pypi.org/legacy/

I don't see any release to poetry-core since February though.

@NiklasRosenstein
Copy link

I just realized that this is an issue with poetry-core==1.1.0b2, but not with the latest final release poetry-core==1.0.8.
The way I had set up my build process was that I ended up using the a poetry-core beta release.

I also confirmed the issue with 1.1.0b3.

@aaronhnsy
Copy link

aaronhnsy commented Sep 3, 2022

I am still getting this issue with poetry==1.2.0 and poetry-core==1.1.0.
Building works fine but I am unable to publish the sdist file and publishing the wheel file results in the package having a dash in the name on pypi which is undesirable.

@dimbleby
Copy link
Contributor

dimbleby commented Sep 3, 2022

Situation:

  • poetry always normalizes the package name at upload
  • poetry-core normalizes package names when building .whl but not when building .tar.gz
  • pypi insists that uploaded files start with a prefix that matches the package name

So per this issue, folk who try for un-normalized package names find that poetry normalizes their package name at upload, and they can't upload their source distribution because it has the wrong prefix.

Probably the sensible next step is to normalize .tar.gz names in poetry-core (and also make the corresponding change in poetry itself - the uploader class currently expects unnormalized source distributions, because it 'knows' what poetry-core did).

That gets to a place where poetry insists on normalization, but at least it is possible to upload sdists.

Not planning on doing this myself, no doubt MRs are welcome.

@mkniewallner
Copy link
Member

Probably the sensible next step is to normalize .tar.gz names in poetry-core (and also make the corresponding change in poetry itself - the uploader class currently expects unnormalized source distributions, because it 'knows' what poetry-core did).

Last time I checked, there was no accepted PEP formally stating that sdists should be canonicalised, though the closest thing there is to that is this packaging specification which states:

The file name of a sdist is not currently standardised, although the de facto form is {name}-{version}.tar.gz, where {name} is the canonicalized form of the project name (see PEP 503 for the canonicalization rules) with - characters replaced with _, and {version} is the canonicalized form of the project version (see Version specifiers).

There is PEP 625 about canonicalising the name the same way as for wheels, but it is still in draft.

Although PEP or not, it would seem more sensible to canonicalise sdists the same way as Poetry already does for wheels, for better consistency, especially since this (probably) shouldn't be a problem for any tool consuming the sdists.

@dimbleby
Copy link
Contributor

dimbleby commented Sep 3, 2022

Sure, the proposal to canonicalize sdists in the same way as bdists wasn't intended to rule out the possibility of supporting un-canonicalized project names at some later point (nor to rule it in, come to that!).

I suggest sdist canonicalization as a relatively low risk next step that can be taken without getting into that discussion at all. It's clearly a bug at the moment that some packages can't upload their sdists, start by solving that.

Then later debate the merits or otherwise of supporting un-canonicalized names.

@neersighted
Copy link
Member

If anything this bug is PyPI being too strict in validation when different names are allowed by the spec -- technically Poetry is doing nothing wrong. However, from a practical standpoint I believe they use filenames to identify releases, so the requirement to match makes sense (even if it's undocumented/not required by spec).

@SvenBecker
Copy link

Is there some way to opt out of the package name normalization or would it be possible to provide such an option? We are using some internal PyPI so I'm not sure if those PyPI validations even affect us.

@dimbleby
Copy link
Contributor

No. You will either need to put together an MR changing the code, or hope that someone else does.

@neersighted neersighted added area/publishing Related to PyPI/PEP 503 publishing version/1.2.1 and removed status/triage This issue needs to be triaged labels Sep 23, 2022
@NiklasRosenstein
Copy link

NiklasRosenstein commented Sep 27, 2022

What worked for me is to pin poetry-core==1.0.8:

[build-system]
requires = ["poetry-core==1.0.8"]
build-backend = "poetry.core.masonry.api"

But I build with Poetry build and publish with Twine; not sure if this still works with poetry publish.

@neersighted
Copy link
Member

This will not work with poetry publish as Poetry does not use the requires = field.

@neersighted
Copy link
Member

Closing as python-poetry/poetry-core#484 is merged.

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/publishing Related to PyPI/PEP 503 publishing kind/bug Something isn't working as expected version/1.2.1
Projects
None yet
Development

No branches or pull requests

7 participants