-
Notifications
You must be signed in to change notification settings - Fork 105
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
Configure private pip repositories in the environment file #481
Configure private pip repositories in the environment file #481
Conversation
✅ Deploy Preview for conda-lock ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -1,126 +1,14 @@ | |||
""" |
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.
Most of this has been extracted to conda_lock/models/package_source.py
, which contains the shared logic common to both channels and pip repositories.
conda_lock/pypi_solver.py
Outdated
def _normalize_url(url: str, pip_repositories: Optional[List[PipRepository]] = None) -> str: | ||
if not pip_repositories: | ||
return url | ||
for pip_repository in pip_repositories: | ||
specified_url = urlparse(pip_repository.url) | ||
repository_host = specified_url.scheme + "://" + specified_url.netloc | ||
repository_host_expanded = expandvars(repository_host) | ||
if url.startswith(repository_host_expanded): | ||
url = url.replace(repository_host_expanded, repository_host, 1) | ||
return url |
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.
This differs from the way environment variables are re-substituted in conda channels. This is because generally speaking, most pip repositories link to files outside of the Python simple/
API path.
E.G. pypi/api/simple
would be the configured path for resolution, but the resolved file URL might be pypi/<package-name>/<package-name>-1.0.0.tar.gz
.
Because of this, we need to make some assumptions based on the netloc instead of full matches.
Hey, I took a look, and I like the direction this is heading, thanks so much for this! I'm impressed by your PyPI mock. :) I see that the first commit is primarily a combination of moving code from Finally, feel free to be bold about refactoring and simplifying existing code if it helps. You're touching a lot of code that's probably long overdue for an overhaul. For example, I'd prefer to use libraries when it makes things easier. |
I note an issue with the current approach, which is unfortunately not detected by the test. The More annoyingly, the solver uses the URL from the response not the one used to make the request. This means that if the solver makes a request to I can only think of one good solution here, which is to inspect each resolved package URL and attempt to match them to the configured I'll investigate this route.
|
One of my top priorities is to upgrade the vendored version of Poetry. I'm not sure whether or not this would help, but anyways I want to depend on Poetry as little as possible. But if it's tied into their solver I suppose we have no choice but to play along for now, since we can't modularize the solver overnight. |
We should also support parsing credentials dynamically out of netrc files (this works quite well for a lot of conda package registries) |
if not solver_url.startswith(self.stripped_base_url): | ||
# The resolved package URL is at a different host to the repository | ||
return solver_url |
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.
This is an interesting edge case.
Basically this is where the repository is at http://private-pypi.org
, but that index directs the solver to some other host, e.g. http://packages.private-pypi.org
or http://somewhere.completely.different
.
Currently in this case the lockfile will just use the URL from the solver as-is, without any auth.
An alternative would be to just add the auth to the URL anyway? WDYT?
I (finally) found enough time to get this in a working state, ready-for-review. Let me know what you think. |
@jacksmith15 I'm doing a lot of traveling at the moment; this is in my review queue, but I'm still looking for a chunk of time when I can go through this carefully. Feel free to pester me, but I can't promise any timescale yet. Perhaps @mariusvniekerk could help if available. |
Description
This PR adds support for specifying private pip repositories in the
environment.yml
file, similar to how channels are specified.Similarly to channels, environment variables may be specified, and these will remain as references in the lockfile.
This aims to solve #460, and is an alternative approach to the one proposed by #471