-
Notifications
You must be signed in to change notification settings - Fork 103
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
Python dependency gets wrong category name when pip is only used in dev dependencies. #275
Comments
Hi, I'm having trouble reproducing this. What's your conda-lock version? BTW, a few minor suggestions:
|
You can also try adding in python as a dep in the dev-environment, that will probably make things behave correctly |
Last time I tried adding something as a |
Hi, thanks for the quick responses. I created an environment closer to my use-case to reproduce the problem.
name: conda_lock_bug_demo
category: main
platforms:
- linux-64
channels:
- conda-forge
- anaconda
- pytorch
# We want to have a reproducible setup, so we don't want default channels,
# which may be different for different users. All required channels should
# be listed explicitly here.
- nodefaults
dependencies:
- python=3.10
- conda-lock=1.2
name: conda_lock_bug_demo
category: dev
platforms:
- linux-64
channels:
- conda-forge
- anaconda
- pytorch
# We want to have a reproducible setup, so we don't want default channels,
# which may be different for different users. All required channels should
# be listed explicitly here.
- nodefaults
dependencies:
# Dev dependencies
- pytest
- pip:
- seaborn In an environment running python 3.10.4, installing pip install conda-lock[pip_support]==1.2.1 Creating the lock file using: conda-lock lock -f environment.yml -f dev-environment.yml --check-input-hash --mamba --lockfile "conda-lock.yml" This will create a lock file where the python dependency has the incorrect
For this example I first tried installing |
I would recommend not including |
Yes, but it's normal to have |
I tend to just install conda-lock with pipx or condax (or directly into the base conda environment) and have it live entirely in its own environment. It's a cli tool so no need to import it or mix it with other stuff |
Makes sense, but I don't think having the |
I can confirm issue exists. It is not only a |
In my understanding categories are reliable only if whole dependency trees of categories are disjoint (which in the real world hardly happens). First, no dependency, direct or indirect, can have two categories, so it is not possible to select an arbitrary subset of categories when installing the environment. Second, a category can be overwritten in an non-deterministic manner, which makes it impossible to create hierarchy of categories. |
Regarding |
Regarding |
I seem to be experiencing this issue, specifically when locking pip requirements defined in a What I observe is that transitive dependencies managed with pip are installed in the the Example, requirement X and dev requirement Y both depend on Z, but Z gets installed in dev only. I am only observing this issue when moving to the new lockfile format (conda-lock >=2) Is the only solution to assembly 2 separate environments for "dev" and "no dev" where "dev" contains all the dependencies of the latter, plus dev requirements (and therefore not use categories feature)? |
Hi @Ben-Habermeyer, in practice I've usually managed to work around the issue by ensuring that main dependencies are never repeated as dev dependencies and then occasionally adding any missing transitive dependencies as explicit main dependencies as needed. It's pretty ugly and fragile but usually gets the job done. Since you're working with a Poetry-based project, I'd highly recommend looking into pixi. Pixi is basically Poetry for conda. It does pypi dependencies a lot more robustly and is being developed actively by a team that I really admire. There are a few differences: it's project-based rather than global-environment-based. Even though you're working with a pyproject.toml I'd recommend using pixi.toml for better conceptual separation even though they're equivalent. |
Thanks @maresb, yes I have been looking at #278, #434 and mamba-org/mamba#1209 as well - seems to be exactly what I am experiencing. Yea essentially what I have is a bioinformatic python package where dependencies are locked using Previously (conda lock v1) But as myself and others have explained, there seems to be a transitive dependency issue now with categories where the transitive dependencies (seems limited to pip dependencies?) are only listed in the I have tried your suggestion of adding explicit transitive dependencies with some success. For non-pyproject-toml based requirements, I have also used https://github.com/conda-incubator/conda-env-builder to define environment yaml files which inherit form one another (in this example, I will also take a look at pixi as you suggested. For the time being do you suggest following #273 as the root issue when a fix may be addressed in |
Hi,
I have an environment file
environment.yml
:And a dev environment
dev-environment.yml
:When I create the lock file (
conda-lock lock -f environment.yml -f dev-environment.yml --check-input-hash --mamba
) the python dependency will now havecategory: dev
. This breaksconda-lock install --no-dev
since python will not be installed.Probably something in the pip code overwrites the category of python.
The text was updated successfully, but these errors were encountered: