Metadata-Version: 2.4
Name: condascan
Version: 1.0.0
Summary: CLI tool to look for the best conda environment which satisfies certain requirements
Author-email: Steve Immanuel <iam.steve.immanuel@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Steve Immanuel
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/SteveImmanuel/condascan
Keywords: conda,anaconda,miniconda
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rich
Requires-Dist: packaging>=25.0
Requires-Dist: pyyaml
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: bumpver; extra == "dev"
Dynamic: license-file

# condascan
CLI tool to scan through existing `conda` environments. It helps you manage your conda environments by:
- Finding environments that satisfy a `requirements.txt` or `environment.yml` file. You can then clone them, instead of creating a new environment from scratch.
- Checking if a command is available in some environments, as well as getting the result of executing the command.
- Compare different environments to see which packages are unique or shared. Then, you can delete environments that are not needed anymore.

## Installation
You can install `condascan` using `pip`:
```bash
pip install condascan
```

Additionally, `conda` has to be installed on your system, either using `miniconda`, `anaconda`, `miniforge`, `mambaforge`, etc. Make sure that you can execute the following command:
```bash
conda --version
```

## Usage

### Search by Requirements
Using the `have` command, you can scan through your conda environments and find those that satisfy a given requirement. The bash command is as follows:
```bash
condascan have <requirement>
```
`<requirement>` can be one of the following:
- A string enclosed in quotes, specifying space-separated package names in PEP 440 format, e.g., `"numpy pandas"`, `"numpy==1.2.* pandas>=2.1.0"`.
- A path to a `requirements.txt` file, generated by `pip freeze`
- A path to a `environment.yml` file, generated by `conda env export`

### Check Command Availability
To see if a command is available in any of your conda environments, use the `can-execute` command:
```bash
condascan can-execute <command>
```
`<command>` can be one of the following:
- A string enclosed in quotes, specifying the command to run, e.g., `"nvcc --version"`
- A path to `.txt` file containing list of commands, one per line.

**Note**: To determine if a command can be executed in a given environment, `condascan` will actually **run** the command inside each environment. This means any side effects (e.g., creating files, modifying state, or triggering installations) will occur if the command succeeds. Make sure the commands you're testing are safe and have predictable behavior across environments.

### Compare Environments
To compare two or more environments, use the `compare` command:
```bash
condascan compare <envs>
```
<envs> can be one of the following:
- A string enclosed in quotes, specifying space-separated installed environment names, e.g., `"base env1 env2"`
- A path to a `.txt` file containing list of installed environment names, one per line.

### Caching
To speed up execution, `condascan` caches the results of previous runs. The cache is stored in `~/.cache/condascan`. If in-between executing `condascan` you modify your conda environments or you want to run without cache, you can do so by adding `--no-cache` flag. For example:
```bash
condascan have "numpy pandas" --no-cache
```

### Formatting Output

#### Verbose, Limit, and First Flags
**Note:** These flags are only applicable for `have` and `can-execute` commands

To get the detailed output of `condascan`, you can add `--verbose` flag. For example:
```bash
condascan can-execute "nvcc --version" --verbose
```
To limit the number of environments displayed in the output, you can use the `--limit` flag. Note that this is only applicable for `have` and `can-execute` commands. For example:
```bash
condascan have "numpy pandas" --limit 5
```
To find the first environment that satisfies the requirement, you can use the `--first` flag. Note that in this case, `condascan` will only scan the environments until it finds the first one that satisfies the requirement, and then it will stop scanning further. This can significantly speed up the search if you only need one environment that meets the requirement.
For example:
```bash
condascan have "numpy pandas" --first
```

#### Pip Flag
**Note:** These flags are only applicable for `compare` command

By default, the `compare` command will compare every installed package from any channel in the environments. If you want to compare only packages installed from `pip`, you can use the `--pip` flag. For example:
```bash
condascan compare "env1 env2" --pip
```

