conda / conda-lock

Lightweight lockfile for conda environments
https://conda.github.io/conda-lock/
Other
456 stars 101 forks source link

incorrect install command suggested in conda-lock.yml comments with 'dev' extra dependencies #641

Open qmarcou opened 1 month ago

qmarcou commented 1 month ago

Checklist

What happened?

After building a lock file from a pyproject.toml with optional dependencies named 'dev': conda-lock --extras dev -f pyproject.toml --mamba with pyproject.toml being:

[project]
name = "MNWE"
dynamic = ["version"]
dependencies = [
    "python",
]

[project.optional-dependencies]
dev = [
    "pytest",
]

[tool.conda-lock]
channels = [
    'conda-forge', 'defaults'
]
platforms = [
    'win-64'
]

the conda-lock.yml header displays incorrect install information:

# This lock contains optional development dependencies. Include them in the installed environment with:
#     conda-lock install --dev-dependencies -n YOURENV conda-lock.yml

which fails

conda-lock install --dev-dependencies -n YOURENV conda-lock.yml
Usage: conda-lock install [OPTIONS] [LOCK_FILE]
Try 'conda-lock install --help' for help.

Error: No such option: --dev-dependencies

Both : conda-lock install --dev -n YOURENV conda-lock.yml and conda-lock install -e dev -n YOURENV conda-lock.yml work, any of these two commands should be suggested instead.

I guess these lines should be deleted (if the -e option is prefered) or updated: https://github.com/conda/conda-lock/blob/fcb8d53ee135fd8c473d751343614de1c241a7ab/conda_lock/lockfile/__init__.py#L193-L199

When using any other name than dev (e.g foo) for extras the correct command is suggested : conda-lock install -e foo -n YOURENV conda-lock.yml

Conda Info

active environment : lock-env
    active env location : C:\Users\zzzzz\AppData\Local\miniconda3\envs\lock-env
            shell level : 2
       user config file : C:\Users\zzzzz\.condarc
 populated config files :
          conda version : 24.4.0
    conda-build version : not installed
         python version : 3.10.14.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=skylake_avx512
                          __conda=24.4.0=0
                          __win=0=0
       base environment : C:\Users\zzzzz\AppData\Local\miniconda3  (writable)
      conda av data dir : C:\Users\zzzzz\AppData\Local\miniconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\zzzzz\AppData\Local\miniconda3\pkgs
                          C:\Users\zzzzz\.conda\pkgs
                          C:\Users\zzzzz\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\zzzzz\AppData\Local\miniconda3\envs
                          C:\Users\zzzzz\.conda\envs
                          C:\Users\zzzzz\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/24.4.0 requests/2.28.1 CPython/3.10.14 Windows/10 Windows/10.0.19045 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8
          administrator : False
             netrc file : None
           offline mode : False

Conda Config

# nothing

Conda list

No response

Additional Context

This is in between documentation and bug issue and I wasn't sure how to assign it. This is also somewhat related to #255 .

maresb commented 1 month ago

@mariusvniekerk, is there any reason not to deprecate all the dev related flags on conda-lock install and conda-lock render? It seems to me like --extras dev is equivalent, and much less confusing.

And I think we should readd --dev-dependencies with a deprecation error.