Metadata-Version: 2.4
Name: conda-repo-cli
Version: 1.0.222
Summary: A command line interface for Anaconda Platform repository
License: BSD-3-Clause
License-File: LICENSE.md
Requires-Python: >=3.10
Requires-Dist: anaconda-auth>=0.11.0
Requires-Dist: anaconda-cli-base>=0.6.0
Requires-Dist: conda
Requires-Dist: platformdirs>=3.10.0
Requires-Dist: pyyaml>=6.0.1
Requires-Dist: requests>=2.31.0
Requires-Dist: six
Requires-Dist: tabulate
Requires-Dist: typer
Requires-Dist: urllib3>=2.2.2
Description-Content-Type: text/markdown

[ci-tests-badge]: https://github.com/anaconda/conda-repo-cli/actions/workflows/test-and-build-dev.yml/badge.svg
[ci-release-badge]: https://github.com/anaconda/conda-repo-cli/actions/workflows/release.yml/badge.svg

# Conda Repo CLI
[![CI Tests (GitHub Actions)][ci-tests-badge]](https://github.com/anaconda/conda-repo-cli/actions/workflows/test-and-build-dev.yml)
[![CI Release (GitHub Actions)][ci-release-badge]](https://github.com/anaconda/conda-repo-cli/actions/workflows/release.yml)


[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)

CLI tool for working with Anaconda

> **1.0.x release line.** This branch is the 1.0.x maintenance line: a pure
> conda plugin (`conda repo ...`), with no anaconda-cli integration. See
> [docs/release-1.0.x.md](docs/release-1.0.x.md).

[Package Security Manager CLI Documentation](https://www.anaconda.com/docs/psm/on-prem/latest/user/cli)

## Features

conda-repo-cli is a tool for console, the key features are as follows:

- `admin` - Package Security Manager admin settings
- `auth` - Manage Authorization Tokens
- `channel` - Manage your Anaconda repository channels
- `config` - Anaconda Repo Client Configuration
- `copy` - Copy packages from one channel to another
- `cves` - Access Anaconda Repository cvess
- `login` - Authenticate a user
- `logout` - Log out from your Anaconda repository
- `mirror` - Manage your Anaconda repository mirrors
- `move` - Move packages from one channel to another.
- `sbom` - Get SBOM files
- `remove` - Remove an object from your Package Security Manager repository. Must refer to the formal package name as it appears
  in the URL of the package. Also use anaconda show <USERNAME> to see list of package names. Example: anaconda remove
  continuumio/empty-example-notebook
- `search` - Search in your Anaconda repository
- `upload` - Upload packages to your Package Security Manager repository
- `whoami` - Return information about logged user
- `wizard` - Configure Conda to use Package Security Manager

## Installation

Python installing:

```console
$ python setup.py install
```

Conda:

```console
$ conda install conda-repo-cli
```

## Usage

conda-repo-cli can do all what you need without access to UI. You can following options/arguments:

```
$ conda repo -h
usage: conda-repo [-h] [--disable-ssl-warnings] [-k] [--show-traceback] [-v] [-q] [-V] [-t TOKEN] [-s SITE]
                  {admin,auth,channel,config,copy,cves,login,logout,mirror,move,remove,search,upload,whoami} ...

positional arguments:
  {admin,auth,channel,config,copy,cves,login,logout,mirror,move,remove,search,upload,whoami}
                        sub-command help
    admin               Package Security Manager admin settings
    auth                Manage Authorization Tokens
    channel             Manage your Anaconda repository channels
    config              Anaconda Repo Client Configuration
    copy                Copy packages from one channel to another
    cves                Access Anaconda Repository cvess
    login               Authenticate a user
    logout              Log out from your Anaconda repository
    mirror              Manage your Anaconda repository mirrors
    move                Move packages from one channel to another.
    remove              Remove an object from your Package Security Manager repository. Must refer to the formal package name as it appears in the URL of the package. Also use anaconda show <USERNAME> to
                        see list of package names. Example: anaconda remove continuumio/empty-example-notebook
    sbom                Get SBOM files
    search              Search in your Anaconda repository
    upload              Upload packages to your Package Security Manager repository
    whoami              Return information about logged user

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit

output:
  --disable-ssl-warnings
                        Disable SSL warnings (default: False)
  -k, --insecure        Allow to perform "insecure" SSL connections and transfers.
  --show-traceback      Show the full traceback for chalmers user errors (default: False)
  -v, --verbose         print debug information on the console
  -q, --quiet           Only show warnings or errors on the console

repo-client options:
  -t TOKEN, --token TOKEN
                        Authentication token to use. May be a token or a path to a file containing a token
  -s SITE, --site SITE  select the anaconda-client site to use
```

## Authentication

conda-repo-cli integrates with `anaconda-auth` for unified authentication across Anaconda tools.

### Using anaconda login (Recommended)

Authenticate once using the Anaconda CLI:

```console
$ anaconda login
```

After authentication, `conda-repo-cli` will automatically use your credentials for all operations.

### Configuring for Self-Hosted Instances

For self-hosted Anaconda instances, create a configuration file at `~/.anaconda/config.toml`:

```toml
default_site = "self-hosted"

[sites."self-hosted"]
domain = "staging.ai-platform.anacondaconnect.com"
```

### Legacy Token Authentication

You can still use token-based authentication:

```console
$ conda-repo login --username your_username --password your_password
```

Or pass a token directly:

```console
$ conda-repo -t YOUR_TOKEN channel list
```

## Developing

To install the package in development mode:

- create a local environment `make setup`
- To activate the environment, Run `eval $(make shell)`
  This way you can use the `conda-repo` command to execute `repo_cli/main.py` and run the local dev version. To test if
  commands are working fine:
    - Run `type conda-repo` --> This should display path to conda-repo in env/bin folder
    - Run `conda-repo -h` --> This should display usage of conda-repo command, positional arguments possible and various
      other options (like a help guide)
    - You can also refer https://team-docs.anaconda.com/en/latest/user/cli.html --> instead of `conda repo` command,
      use `conda-repo` command for testing in development mode.

- All support commands can be found at `repo_cli/commands/`

For creating new command, you need to create new file, e.g. `testcommand.py`. You can start by using the skeleton
provided in [new-command.sample.py](new-command.sample.py).

### Code linting and formatting

This project uses [black](https://github.com/psf/black) and [isort](https://github.com/PyCQA/isort) to handle code
formatting needs.

By default, [pre-commit](https://pre-commit.com/) is installed. This provides a fail-fast way to ensure all files are
properly formatted before they land on our pipeline. The GitHub pipeline also ensures that no code-smells land in
our `main` branch.

## Testing

For run tests you need to write `pytest`

You will see results

```
$ pytest
=========================================================================================== test session starts ===========================================================================================
platform darwin -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/stasfilin/Documents/Work/Anaconda/conda-repo-cli
plugins: requests-mock-1.8.0, asyncio-0.15.1, httpx-0.12.0, cov-2.11.1
collected 41 items

repo_cli/tests/integration/test_auth.py .....s                                                                                                                                                      [ 14%]
repo_cli/tests/integration/test_channels.py ..........                                                                                                                                              [ 39%]
repo_cli/tests/integration/test_packages.py ..........ssssssssssssss                                                                                                                                [ 97%]
repo_cli/tests/unit/test_utils/test_format.py .                                                                                                                                                     [100%]

============================================================================================ warnings summary =============================================================================================
repo_cli/utils/appdirs.py:82
  /Users/stasfilin/Documents/Work/Anaconda/conda-repo-cli/repo_cli/utils/appdirs.py:82: DeprecationWarning: invalid escape sequence \D
    """Return full path to the user-shared data dir for this application.

../../../../miniconda/lib/python3.8/site-packages/clyent/__init__.py:5
  /Users/stasfilin/miniconda/lib/python3.8/site-packages/clyent/__init__.py:5: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp

repo_cli/utils/config.py:108
  /Users/stasfilin/Documents/Work/Anaconda/conda-repo-cli/repo_cli/utils/config.py:108: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    if isinstance(updated_value, collections.Mapping):

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=============================================================================== 26 passed, 15 skipped, 3 warnings in 10.44s ===============================================================================


```

## Building and uploading

Building conda-repo-cli requires the following tools:

* **Python 3.6**
* **miniconda** - Download from https://docs.conda.io/en/latest/miniconda.html
* **anaconda-client** - Install via `conda install anaconda-client`
* **conda-build** - Install via `conda install conda-build`

### Updating

Steps:

1. Make changes in your feature branch
2. Create PR to master
3. Approve and merge the PR

### Building and uploading to ae-dev channel

This is done automatically by GitHub Actions upon merging to `main`
> Requires upload permissions for https://anaconda.org/ae-dev channel

Steps:

1. Run `make build`
2. Run `make upload`
3. Check uploaded package in [ae-dev/conda-repo-cli](https://anaconda.org/ae-dev/conda-repo-cli)

### Uploading to main channel

If QA testing was successful, proceed to the next steps.

Steps:

1. Run `git tag [new version]` (for your commit)
2. Run `git push --tag`
3. Create PR to master with new version
   in [conda-repo-cli-feedstock](https://github.com/AnacondaRecipes/aggregate/tree/master/conda-repo-cli-feedstock)
4. Wait for Distro team to approve and merge the PR
4. Check that a new version is available: `conda search conda-repo-cli`
