conda / conda

A system-level, binary package and environment manager running on all major operating systems and platforms.
https://docs.conda.io/projects/conda/
Other
6.35k stars 1.64k forks source link

Add `--name/-n` option to `conda config` #12137

Open maximlt opened 1 year ago

maximlt commented 1 year ago

Checklist

What is the idea?

conda config can be used to configure an activated environment with conda config --env .... I believe this is a cool feature of conda. However, as I said the environment needs to be activated which poses some problem, I think, when conda is controlled programmatically through its command-line interface as you need to fiddle with the shell (I'd be happy to be proven wrong on this point!).

Adding --name/-n to conda config means that it would no longer be required to activate the environment to configure it. It would also make conda's CLI more consistent, as --name/-n is an option of conda create/install/update/remove(and more?).

Why is this needed?

The HoloViz group has a developer tool called pyctdev that is meant to be a unified interface for managing a Python project (e.g. doit test_unit, doit build_package, doit build_docs, ...). The user can either choose conda or pip as their dependency manager, i.e. pyctdev knows how to parse and convert the dependencies listed in a setup.py file so that they can be installed with conda. We're trying to see how we can improve this tool and being able to configure an environment without activating it would be a cool feature.

What should happen?

No response

Additional Context

I tried to look for related issues but looking for conda config just returns hundred of issues, sorry if this is a duplicate!

travishathaway commented 1 year ago

Hi @maximlt,

This is a very reasonable feature request that actually shouldn't be too hard to implement. To do this, we really just need to figure out which configuration file we need to edit. That's exactly what this code here does:

https://github.com/conda/conda/blob/main/conda/cli/main_config.py#L223-L233

The good thing is that we are already have the functions to determine if a particular environment exists.

On top of of -n/--name, I would also recommend that we add -p/--prefix to stay consistent with the rest of the commands.

travishathaway commented 1 year ago

As a temporary work around, you could implement something like this:

# Do this from the base environment
export MY_ENV_NAME='my-cool-env'
conda config --append channels cool-new-channel --file "$CONDA_PREFIX/envs/$MY_ENV_NAME/.condarc"

This will effectively do the same thing granted you are running this from a base environment.

bleakprestiger commented 1 year ago

Can I Take This Issue ?

maximlt commented 1 year ago

@bleakprestiger sure!

harivamsi9 commented 1 year ago

is anyone working on this issue rn? if not I would like to contribute

travishathaway commented 1 year ago

Hi @harivamsi9 and @bleakprestiger,

Are either of you still interested in working on this (sorry for the very late response 🙃). I'd be happy to assign either of you to it. Just tag me in your response so I don't miss it.

github-actions[bot] commented 3 months ago

Hi there, thank you for your contribution!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this issue to remain open please:

  1. Verify that you can still reproduce the issue at hand
  2. Comment that the issue is still reproducible and include:
    • What OS and version you reproduced the issue on
    • What steps you followed to reproduce the issue

NOTE: If this issue was closed prematurely, please leave a comment.

Thanks!

maximlt commented 3 months ago

Not stale.