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

Shorter URLs #8

Open
dstufft opened this issue Jun 6, 2022 · 1 comment
Open

Shorter URLs #8

dstufft opened this issue Jun 6, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@dstufft
Copy link
Member

dstufft commented Jun 6, 2022

Currently URLs look something like this:

https://inspector.pypi.io/project/pip/22.1/packages/f3/77/23152f90de45957b59591c34dcb39b78194eb67d088d4f8799e9aa9726c4/pip-22.1-py3-none-any.whl/pip/_internal/models/format_control.py

That's pretty long! Obviously this is done because that gives enough information to fetch the URL from files.pythonhosted.org, but it might be nice to use shorter URLs, and query PyPI to get the long URL for the file distribution?

We could go as simple as:

https://inspector.pypi.io/file/pip/pip-22.1-py3-none-any.whl/pip/_internal/models/format_control.py

That's enough information to know the project name (since sdists don't have a well formed name) and the filename (which we can then look up on PyPI's /simple/<project>/ page), and get the long URL.

We could even go a bit simpler, and do:

https://inspector.pypi.io/file/pip-22.1-py3-none-any.whl/pip/_internal/models/format_control.py

Note all this embeds is the filename, we would need a way to look up the URL given nothing but the filename, but filenames are unique on PyPI, so we could just have a route on PyPI that does a redirect of filename to pythonhosted.org and does that look up for us.

The main thing we'd lose is that these links would then "die" if the file is removed from PyPI but still exists in files.pythonhosted.org. Maybe with #5 we could store the filename => file url mapping as we load them, which would mean they would continue to work in the future.

Alternatively, maybe still support the long URLs, and have a button to turn the short url into a permalink (think how github does).

Alternatively, maybe this is a silly idea and we should just stick with the long URLs :)

@di
Copy link
Member

di commented Jun 6, 2022

Note all this embeds is the filename, we would need a way to look up the URL given nothing but the filename, but filenames are unique on PyPI, so we could just have a route on PyPI that does a redirect of filename to pythonhosted.org and does that look up for us.

Yeah, this is why I did this, so that these links continue to work after the project is taken down, without having to make changes to PyPI.

@di di added the enhancement New feature or request label Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants