-
Notifications
You must be signed in to change notification settings - Fork 106
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
Support solving for dependencies that are only installable via pip #122
Comments
I would really love this feature to be released. I have actually made a poc Conda manager (https://github.com/wietsedv/coman), mainly for adding pip support. But I will abandon that project when conda-lock supports this. I have three concerns that you might have addressed already (I did not look deeply into your PR).
I'm sorry if these concerns have been addressed already. Good work in any case. |
Thanks! The concerns you point out are only partially addressed in the PR. In the spirit of the rest of
The only issues standing in the way of a release from my perspective are:
@mariusvniekerk do you see any other blockers? |
The problem
I sometimes find myself in a situation where I would like to install the bulk of my dependencies via
conda
, since some of them are expensive-to-build extensions, but also have some dependencies that are only available on PyPI, or as source releases e.g. on GitHub. For example, this project depends onsncosmo
(lots of Cython, takes ~15 minutes to compile from source in CI), but also on a random personal project whose name collides with an unrelated package on PyPI, and so would be impractical to upstream into conda-forge.While I can always lock the
conda
deps and thenpip install
the remainder by hand, it would be attractive to be able to lock both in one go, such that dependencies installed in CI never change behind my back.See also: #115
Sketch of a solution
environment.yml
the pip dependencies would be in thepip
section, whereas for a poetry pyproject.toml, they would be those marked with{source = "pypi"}
.pip
dependencies based on the locked conda environment.environment.yml
output these could be===
version specifiers in thepip
section, while for explicit output they could be in the form of arequirements.txt
embedded in a commented-out section.Prototype implementation
I've been playing with a prototype for personal use that you can find here. The biggest hurdle here is that there is no good candidate for a pip-style dependency resolver.
pip
's own solver is stashed inpip._internal
, making it fairly clear that it is not intended to have any kind of stable interface.poetry
has its own solver that also makes no claims about interface stability, but also doesn't go to any trouble to discourage 3rd-party use, so I decided to use it for now. The implementation largely follows the sketch above. The pip dependencies are emitted into explicit lock files prefixed with# pip
, e.g.conda-lock install
consumes these lines, synthesises a temporaryrequirements.txt
out of them, andpip install
s them in the target env. Alternatively, you can justcat conda-linux-64.lock | awk '/^# pip/ {print substr($0,7)}' > requirements.txt && pip install --no-deps -r requirements.txt
. Since these are URL dependencies,pip
does not have to solve anything. The only way it can fail is if the target URL is unavailable, or the hash does not match. These are fairly easy to diagnose.The introduced poetry dependency is optional; if poetry is not installed, pip dependencies are ignored, and the same warning is printed as before.
In addition,
conda-lock lock
gains an--update
option that lets you update the solution in a previously generated lock file, updating only the specified packages and their dependencies. This is potentially useful for testing incremental dependency updates, e.g. those generated by Dependabot or Renovate.Open questions
I'm mildly satisfied with the solution I've come up with, but would like to gather some feedback before filing a PR, namely:
The text was updated successfully, but these errors were encountered: