-
Notifications
You must be signed in to change notification settings - Fork 104
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
Add pyproject.toml option to prevent requests on pypi.org #304
Conversation
✅ Deploy Preview for conda-lock ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Thanks a lot for this! Before we go ahead with this, I'm wondering if adding a new option is really necessary. (Such stuff adds complexity and long-term maintenance costs.) In particular, I am wondering why pypi.org is being queried in the first place if all the packages are discoverable through the private mirror. Perhaps it's possible to simply prevent this access in the first place. Could you share the stack trace so that we can see the execution path leading up to the PyPI request? |
Thank you very much for your answer! I agree that the ideal behavior would be to prevent unecessary requests to pypi.org without having to use an additional option. At first glance, the fact that pypi is the last item in the repositories list could be enough... but this is not what I see in my use case. Here is an excerpt from my logs, including the commandline used and the stacktrace. Please note that I used conda-lock v1.2.1. Thank you for your time, please let me know if I can help in any way! |
Thanks a lot @yjeand for the stack trace and your willingness to help! We are currently using a vendored copy of Poetry which is v1.1.15. In your PR here you have identified the block where we initialize the pool = Pool(repositories=[*repos, pypi]) Based on your stack trace, it seems that the Would you be able to look into this? |
Thank you for this analysis. For my project we currently use Poetry for our linux builds (I'm working on conda-lock support for Windows, and maybe to replace Poetry for Linux down the road). I can confirm that on our Linux builds Poetry (used directly, outside conda-lock) does not attempt to access pypi since we have added a source with I will take a look into it and report back here. |
Hello, Here is a quick summary of my experimentations. No ideal solution has come up. I think that the most natural behaviour for Poetry-based projects would be for conda-lock to respect the sources declared in Conda-lock instead relies on globally defined sources in the user configuration file for Poetry, like explained here. And as far as I know, there is no way to flag a repo as Coming at it from another angle, I wonder if it would not be simpler to just test a pypi.org connection from conda-lock to decide if we add it to the repositiories list that is passed to the vendored Poetry solver. Something along the lines of: try:
PyPiRepository(disable_cache=True).get_package_info("pip")
repos.append(PyPiRepository())
except RequestException as e:
print(f"Could not access pypi.org, error was:\n{e}", file=sys.stderr)
pool = Pool(repositories=[*repos]) in What do you think about all this? |
This is an excellent insight. Perhaps it would make more sense to store conda-lock configuration related to project.toml in a [tool.conda-lock.pyproject]
use-pypi = true How do you feel about this idea? |
Good idea, it would certainly work for my project. |
For a subsequent PR, it might be interesting to deprecate |
55f6761
to
26fb08c
Compare
Here is my attempt at implementing the |
This looks excellent @yjeand, thanks so much!!! On second thought, I agree with you that One final request: could you please add a short note to the README as documentation? After that, this looks ready from my perspective. @mariusvniekerk, could you please have a look? |
I have added a couple notes in the README. |
My corporate proxy does not allow access to
pypi.org
. We have a private mirror accessible, but unfortunatelyconda-lock
attempts to make requests topypi.org
even when the private mirror is set up, resulting in a conda-lock exception.With this CLI flag, we can ensure that no request goes to
pypi.org
.