About Anaconda Help Download Anaconda

anaconda-cloud / packages / anaconda-activate-check
Standard Python conda
0.2.0

Check the environment status before during activation

  • 697 total downloads
  • Last upload: 1 month and 15 days ago

Installers

  • noarch v0.2.0

pip install

To install this package run one of the following:
pip install -i https://pypi.anaconda.org/anaconda-cloud/simple anaconda-activate-check
pip install -i https://pypi.anaconda.org/anaconda-cloud/label/dev/simple anaconda-activate-check

conda install

To install this package run one of the following:
conda install anaconda-cloud::anaconda-activate-check
conda install anaconda-cloud/label/dev::anaconda-activate-check

Description

anaconda-activate-check

Check the environment status during activation and warn or block activation if instructed.

There is a significant amount of backend work needed to make this project useful. As such, this should not be seen as the "final" production ready version of this project but more of a full-featured proof-of-concept.

In particular this project monkey patches conda's activation logic at interpreter startup. This is brittle and add unneeded overhead to all invocations of python. Alternatives should be explored before a production release.

Basic usage

Create (and log) a conda environment.

conda create --name sample zlib --yes

When the environment is activated, its status is checked. If the status is 'warn', a default message is sent to stderr:

 conda activate example
Environment Activation Warning: "Environment with possible packages out of compliance; try updating package version."

f the status is 'block', the activation is blocked. The default message to the user will be:

 conda activate example

EnvironmentActivationBlocked: "Environment Blocked! Not in compliance with the organization's policies."

Setup for development

Ensure you have conda installed. Then run:

make setup

This installs the package in editable mode and symlinks the .pth file into site-packges in a development environment in the root of the project directory.

Activate it using:

conda activate ./env

After activation conda will still refer to the install in the base environment. The conda from the environment where package is installed needs to be used for activation. To switch conda to refer to the developmennt install use:

eval $(./env/condabin/conda shell.zsh hook)

Replace shell.zsh with shell.bash when using bash.

With this switch conda can be used directory to test the activation check.

For example:

conda create --name sample zlib --yes
ANACONDA_

Environment variables

Various environment variables control the behavior of the activation check:

  • ANACONDA_ACTIVATE_CHECK_DISABLED: Disable the automatic monkey patch, useful for testing.
  • ANACONDA_CLOUD_API_DOMAIN : Domain of the Anaconda Cloud API.

Run the unit tests

make test

Run the unit tests across isolated environments with tox

make tox

© 2024 Anaconda, Inc. All Rights Reserved. (v4.0.6) Legal | Privacy Policy