-
Notifications
You must be signed in to change notification settings - Fork 1
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
Single-source pip and conda dependencies #26
Conversation
pyproject.toml
Outdated
@@ -18,13 +18,13 @@ dependencies = [ | |||
"scikit-image", # secretly required by intake-xarray as default reader | |||
"torch", | |||
"xarray", | |||
"resnet50-cefas@git+https://github.com/jmarshrossney/resnet50-cefas", | |||
#"resnet50-cefas@git+https://github.com/jmarshrossney/resnet50-cefas", |
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.
conda-lock
fails here. According to the documentation it can deal with this situation where the poetry
dependency specification is adopted, but doesn't mention how to resolve this for PEP 621 style pyproject.toml
files.
This might be to do with conda-lock
using poetry
under the hood..
pyproject.toml
Outdated
dev = ["pytest", "black", "flake8", "isort"] | ||
all = ["cyto_ml[jupyter,dev]"] | ||
dev = ["pytest", "black", "flake8", "isort", "pip-tools", "conda-lock"] | ||
#all = ["cyto_ml[jupyter,dev]"] |
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 pattern for collecting dependencies together also doesn't work with conda-lock
as it tries to look up cyto_ml
and doesn't find it.
The next thing I tried was to explicitly split into I don't actually want to have to do this at all, because I don't want to remove anything from Anyway, I tried to test this approach by demanding that only # in pyproject.toml
[tool.conda-lock]
channels = [
"pytorch", "conda-forge"
]
platforms = [
"linux-64",
"win-64"
]
default-non-conda-source = "pip"
[tool.conda-lock.dependencies]
python = ">=3.12" ... but it failed with
I don't understand what's going on at all, and am inclined to draw the tentative conclusion that single-sourcing dependencies in a |
So I failed at single-source and I don't think there's much point in investing more in this for the time being. I have added some documentation to the I created the lockfiles as follows: pip-compile --extra jupyter --extra dev --output-file requirements.txt pyproject.toml # requirements.txt
conda-lock lock --mamba -f environment.yml # conda-lock.yml In both cases you need to run Does this seem overkill? Yes, I think it does. This is where something like |
On a final note, both lockfiles have all of the dependencies, including the optional It is not difficult to maintain multiple lockfiles for different dependency groups with either |
conda-lock.yml
Outdated
@@ -31,7 +31,7 @@ package: | |||
manager: conda | |||
platform: win-64 | |||
dependencies: {} | |||
url: https://conda.anaconda.org/conda-forge/win-64/_libavif_api-1.1.1-h57928b3_0.conda |
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 don't know why this has happened. I ran conda-lock --update matplotlib
to test updating a lockfile..
requirements.txt
Outdated
@@ -2,7 +2,7 @@ | |||
# This file is autogenerated by pip-compile with Python 3.12 | |||
# by the following command: | |||
# | |||
# pip-compile --extra=dev --extra=jupyter --output-file=requirements.txt pyproject.toml | |||
# pip-compile |
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.
Here I ran pip-compile --upgrade
and it dropped all of the optional dependencies :/
Sorry - I didn't realise that chaining PRs from a fork would be quite so messy, though I should have. The relevant commits start with In future I will use branches.. |
I don't think these are worthwhile additions, though it was an interesting exercise! Closing :) |
As mentioned in #14, it 'should' be possible to specify all of our dependencies in
pyproject.toml
, from which various lockfiles and environment files for eithervenv
orconda
environments can be derived.If you only care about managing/locking python dependencies there are several good options
pip-tools
,poetry
,hatch
,pdm
, or even justpip freeze
. That bit is well-trodden!On the more experimental side,
conda-lock
claims to be able to produce lockfiles forconda
environments with mixed conda/pip dependencies from apyproject.toml
.This PR tracks some experimentation with doing this for our project.
It's not really crucial for us - we don't have many deps so managing both
pyproject.toml
andenvironment.yml
isn't going to be a huge burden. But I'm still curious.[needs rebasing on #24]
[please squash before merging, if merging at all!]