Check the environment status before during activation
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 anaconda-cloud::anaconda-activate-check
conda install anaconda-cloud/label/dev::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.
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."
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_
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.make test
make tox