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

[Feature Request] Support for PyPI Mirrors #9056

Closed
liblaf opened this issue Nov 12, 2024 · 2 comments
Closed

[Feature Request] Support for PyPI Mirrors #9056

liblaf opened this issue Nov 12, 2024 · 2 comments
Labels
configuration Settings and such needs-design Needs discussion, investigation, or design

Comments

@liblaf
Copy link

liblaf commented Nov 12, 2024

Description

In order to improve download speeds and reliability, it would be beneficial to support configurable PyPI mirrors within the uv.toml configuration file. This feature would allow users to specify alternative mirrors for PyPI packages and files, while still retaining the default PyPI link in the uv.lock file.

Proposed Solution

Inspired by the configuration options in pixi, I propose adding a [mirrors] section to the uv.toml file. This section would allow users to redirect requests for specific PyPI endpoints to alternative mirrors.

Example configuration:

[mirrors]
# Redirect all requests for PyPI to the mirror
"https://pypi.org/simple" = [
    "https://mirrors.cernet.edu.cn/pypi/web/simple"
]

# Redirect all requests for files to one of the listed mirrors
"https://files.pythonhosted.org/packages" = [
    "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages",
    "https://mirrors.cernet.edu.cn/pypi/web/packages",
]

Benefits

  • Improved Download Speeds: Users can leverage faster mirrors located closer to their geographical region.
  • Reliability: Redundancy in mirror options can help mitigate issues with a single mirror being down.
  • Consistency: The default PyPI link remains in the uv.lock file, ensuring compatibility and clarity.

Additional Considerations

  • Fallback Mechanism: If a specified mirror is unavailable, uv could automatically fall back to the next listed mirror or the default PyPI endpoint.

Related Issue

Conclusion

Supporting configurable PyPI mirrors in uv.toml would enhance the user experience by providing faster and more reliable package downloads. I kindly request the implementation of this feature or further discussion on alternative solutions.

@charliermarsh
Copy link
Member

I think this could be thought of as similar to #6349.

@charliermarsh charliermarsh added resolver Related to the package resolver needs-design Needs discussion, investigation, or design configuration Settings and such and removed resolver Related to the package resolver labels Nov 12, 2024
@liblaf
Copy link
Author

liblaf commented Nov 13, 2024

@charliermarsh Thanks! I didn't notice that issue before.

I think URL redirecting is more flexible than setting proxy URL for index, as URL redirecting can handle cases when sdist and wheels URL differ from registry URL (e.g. https://pypi.org and https://files.pythonhosted.org).

Closing in favor of #6349.

@liblaf liblaf closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Settings and such needs-design Needs discussion, investigation, or design
Projects
None yet
Development

No branches or pull requests

2 participants