Open lesteve opened 2 years ago
So part of that is possible and part of it is not entirely,
Since the pip solver being used is the poetry solver the configuration for allow-prereleases
is not a global setting but a local one per dependency as defined over here
https://github.com/python-poetry/poetry-core/blob/ffc22b22a2e9d075ba93fea1348729bf9af2c3fd/src/poetry/core/packages/dependency.py#L39
I assume in this case you probably want just a prerelease of just numpy, and not everything else.
The pypi repositories being used are defined in https://github.com/conda-incubator/conda-lock/blob/9a1132d703dd34a5524becba15b976769781d52d/conda_lock/pypi_solver.py#L200-L201 , there is already a feature request to support those a bit better in #135 so adding in that should potentially be feasible.
The harder part is which pip install arguments to support generically as there are quite a few of them and the mapping of them to poetry flags isn't necessarily trivial
I assume in this case you probably want just a prerelease of just numpy, and not everything else.
Yep indeed in practice we would want prerelease versions only for a few packages e.g. numpy, scipy, pandas so it would be fine to do it on a per-package basis.
there is already a feature request to support those a bit better in https://github.com/conda-incubator/conda-lock/issues/135 so adding in that should potentially be feasible.
OK nice.
There was actually a third hidden feature request in my original post: having dependencies like https://github.com/joblib/joblib/archive/master.zip
(and I assume git+https://
as well). Right now I am getting a parsing error:
pkg_resources.extern.packaging.requirements.InvalidRequirement: Parse error at "'://githu'": Expected stringEnd
Maybe this should be a separate issue, but I think it's related. I was wondering how to get conda-lock to install pip dependencies a la pip install --no-cache-dir ...
instead of manually deleting the cache before running conda-lock install
. Instead I think my question should be restated to is there a way to get conda-lock to get poetry to clear the cache before building those dependencies?
@rcthomas, is this motivated by reducing disk space for Docker or other space-constrained environments?
Unfortunately I don't think there's a good way to this automatically with the way things are currently structured. Manually deleting the cache seems to me like the way to go.
@maresb no, not disk space, I just sometimes want to make sure that I'm not using the pip cache directory when building packages from PyPI.
The reason I followed up on this thread instead of opening a new one is that I'm actually not looking for a way to do this automatically, I was wondering if I could tell conda-lock to pass arguments like OP asked about, but to prevent using the pip cache (as if one were passing --no-cache-dir
to pip install
). Initially I thought "if there's just a way to pass arguments to pip" that would work but I do see why it's maybe not as easy as that.
A simpler but related usecase, would be nice if requirements.txt
was supported in environment.yml
dependencies:
- python=3.11
- pip
- pip:
- -r requirements.txt
- conda-lock
Ya, I see this thread as good motivation to eliminate conda-lock's use of Poetry, replacing it with a generic solver.
Since the pip solver being used is the poetry solver the configuration for
allow-prereleases
is not a global setting but a local one per dependency as defined over here https://github.com/python-poetry/poetry-core/blob/ffc22b22a2e9d075ba93fea1348729bf9af2c3fd/src/poetry/core/packages/dependency.py#L39 I assume in this case you probably want just a prerelease of just numpy, and not everything else.
How does one get the poetry dependency solver in conda-lock to set allow_prereleases
to True
when finding the appropriate package version? Is this something that can be done with some special syntax in the environment.yaml
file?
I don't think we currently have any way to activate allow_prereleases=True
. I think you'd have to patch the source. If you add an option to pyproject.toml
and a test I wouldn't see any problem with merging it in a PR.
Ah ok. That's a shame because pip's default behaviour is to find pre-releases when it can't find a stable release (which is the issue in my case... installing the conda environment works fine but exporting it using conda-lock fails). I'll look into it but not familiar with poetry at all!
This may be stretching conda-lock a bit, but would there be a chance to support full pip requirements.txt syntax in environment.yml like the following one? This is supported by conda and mamba, see https://github.com/conda/conda/pull/3969 for conda support:
The use case we have in scikit-learn:
Right now I get an error when trying to lock the environment because
--pre
does not look like a "standard" requirement e.g. something likepackage>version
.The full output with the error: