-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat: Allow using repository mirrors #3624
feat: Allow using repository mirrors #3624
Conversation
I'm glad to see someone attacking this topic. @ZeroAurora I hope you manage to get it done. |
OK most things of this PR are done. Now I need some help with the test... |
I'm trying to learn testing little by little. Maybe I will push some tests later. |
I'm making huge changes to the code I've written and will rebase and force-push again later, since I just want to keep the log clean. |
Now everything is ready. This PR is ready for merging. |
🎉 Completed! This time is true. Apologize again for so many force pushes. |
This comment has been minimized.
This comment has been minimized.
Thanks a lot for your contribution @ZeroAurora. 👍 Because I'm not familiar with this part of poetry I've pinged the other maintainer to have a look at your PR. |
Thanks! At the same time I'm going to rebase and modify the commits again to keep the log clean. |
Hey I've rebased this to the latest master branch. How's the reviewing process going? |
Fixed something. Seems the linting problem is still not my fault. |
Yes, looks like the linter runner itself is failing somehow.
Patience. Maintainers will get to this eventually, but it might take some time, months maybe, because they do not have much time/resources to invest on unpaid volunteer work. My advice to improve your chances of getting this PR reviewed earlier, is to make the maintainers' work easier. For example you could get as many eyes as possible on this. In your case there are many people affected by the underlying issue, as shown by the many linked issues. So if you feel confident enough with your PR, then go post on those issues and ask others to test your PR and see if it does indeed fix their use cases. Good luck! |
Thanks @sinoroc ! I'm going to follow your advice. |
I know where's the problem! fixing. |
... to enable further improvements on mirrored repository. One example is that the cache dir of the mirrored PyPI repository should also be named "pypi". However, the repository name "pypi" is reserved for the original PyPI. Doing this change to LegacyRepository will not only allow this, but also enable other developers to make changes if mirrored LegacyRepository is broken. The corresponding tests are also added. Note that there are some changes on the paths to some files.
... and reduced some debug messages to ensure good reading experience.
if TYPE_CHECKING: | ||
from .repositories.legacy_repository import LegacyRepository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've deleted these two lines since LegacyRepository is already imported above.
Dear @ZeroAurora, thanks a stack for your attempt to tackle this improvement to Poetry. We have been talking about topics related to this at earthobservations/wetterdienst#332 just recently. At earthobservations/wetterdienst#332 (comment), I just summarized different discussions which already took place within the Poetry issue tracker. Specifically, it would be really nice if your patch could also address the use case not only to use a repository mirror, but also to turn off reaching out to the internet at all by going to a repository on the local filesystem (or the Good luck and keep up the spirit! With kind regards, |
Hey @amotl ! |
Hey @ZeroAurora, thanks for your kind response. I recognize that this request is out of scope of this patch, thanks to your elaboration. Eventually, I might come back to this in order to improve the situation for our use case, thus bringing similar features to Poetry like what Through your patch, it is already very valuable to us to know which places to look at. With kind regards, |
@amotl |
Dear @sinoroc,
Thank you very much for your suggestion. Let's continue our discussion at earthobservations/wetterdienst#332 when applicable? Then, we won't hijack the discussion around @ZeroAurora's contribution any longer. Sorry again for doing that on the first hand! With kind regards, |
I have just tried this branch (e0bc6d4) with CodeArtifact (essentially a private PyPI mirror that requires authentication). I have the following configuration:
and I have provided credentials for it using However, loading any packages fails with "Unable to find installation candidates". |
Some fixes you're welcome to merge: After these, I can install from CodeArtifact:
However, when updating or adding new packages, Poetry starts inserting these sections into the lockfile:
|
thx for the patches, I'm considering to merge them when I'm free (now very busy as a student) |
I feel sorry, but as I couldn't handle this PR any longer, I have to close it. Debugging and keeping up-to-date with upstream are not easy for me (I'm a student, both in real world and in programming world, after all), and I don't have time to manage them either. |
I will not delete the branch, just in case that someone would like to base on it. |
I'm deleting the branch since it has already had many diffs with the upstream. Re-implementing is more realistic. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
Current status: ready for review and merge
Resolves: #1632, Resolves: #1841, Resolves: #2151, Resolves: #3355, Resolves: #3474, Resolves: #3479, Resolves: #3553
(btw I don't know how to write good tests so I need some help...)Details
This PR introduces a config
repositories.<repo>.mirror.url
, which is used to specify a mirror url of a existing repository.This can be extremely helpful in regions where it's hard to connect to PyPI and other sources. (And also makes poetry my first choice for my python projects.)
Blocking Problems
Avoid publishing to mirror repositories.Currently I achieved the goals by modifingfactory.py
, which is used to initialize thePoetry
object used by others. I'm not sure if it will break uploading.I checked
poetry/publisher.py
and ensured this won't happen.Non-blocking Problems
Currently (in the PR), poetry won't fallback to original source if a source fails. I couldn't think of a way to resolve it. But both
pip
andpipenv
seem not to fallback, so we can be a bit evil and not fallback too lololI've tested it and PyPI mirror won't show up in requirements.txt.
This is my first PR to such a large project 🎉 so I would be ❤️ if you help with this PR!