Package: cenv-tool
Due to the redundant dependency information inside themeta.yaml(required
to create the conda-package) and theenvironment.yml(as definition file
for the conda-environment during development and for production),cenv(short form forconda-env-manager) was created to make themeta.yamlthe only relevant file and to create and update conda-environment from the
definition inside thismeta.yaml.
The name of the conda-environment to create / update is defined in the sectionextra:cenvand the variableenv_nameinside themeta.yaml.
The python version must be defined inextra:cenvinside the keypython.The steps run by cenv:creation of a backup if the environment already exists followed by the
removal of the previous environment.creation of the environment as defined in themeta.yaml.
If any failures occurred during creation and the backup was created, the
command to reset the backup-version can be used.if enabled in the config file the environment.yml is exported after creation
/ update of the environment.The usage of cenv reduces the conda commands to use to the following:conda activate ...to activate the environmentconda deactivateto deactivate an environmentconda infoto show information about the currently activated environmentconda search ...to search for availability of a package in the conda
channels.conda remove-n...--allto remove an environmentcenvto create / update an environmentDocumentationFor complete documentation seereadthedocs.InstallationInstallcenvusing pip:pipinstallcenv_toolNow runinit_cenvto create the relevant config-files and add the
autoactivate- and autoupdate-shell-function to your.bashrc/.zshrc.autoactivate and autoupdatePer default these features are deactivated, even if added to your shell by
runninginit_cenv.autoactivate-featureThe autoactivate-feature activates the conda-environment as namedextra-section in the meta.yaml located atconda-build/meta.yaml, if the
environment exists.
To activate the autoactivate-features run:autoactivate_toggleautoupdate-featureThe autoupdate checks if the content of the meta.yaml changed.
The current state is stored as a md5sum inconda-build/meta.md5.
If it changed the cenv-process is called.For the autoupdate-feature run:autoupdate_toggleUsageAll steps required to create or update the projects conda environment are
run automatically running:cenvATTENTION:If you use cenv, each environment should only be created, updated and
modified usingcenv!
This means the commandsconda install,conda removeare not used
anymore.
Changes of the dependencies of the environment are defined inside themeta.yamland are applied by usingcenv.This means:new dependency required => add it inmeta.yamland runcenv.dependency not needed anymore => remove it frommeta.yamland runcenv.need of another version of dependency => change the version of dependency
inmeta.yamland runcenv.The required information about the projects conda environment are extracted
from the meta.yaml.
This meta.yaml should be located inside the project folder at./conda-build/meta.yaml.
The project-configuration is defined in theextra:cenvsection of themeta.yaml.
There you can define the name of the projects conda-environment atenv_name.
The python version has to be defined here atpython, too.
Also you can define requirements only needed during development but not to be
included into the resulting conda package.
These requirements have to be defined in thedev_requirements-section.All other parts of themeta.yamlhave to be defined as default.A meta.yaml valid for cenv should look like the following:{%set data = load_setup_py_data() %}package:name:"example_package"version:{{data.get("version")}}source:path:..build:build:{{environ.get('GIT_DESCRIBE_NUMBER',0)}}preserve_egg_dir:Truescript:python -m pip install --no-deps --ignore-installed .requirements:build:-python 3.6.8-pip-setuptoolsrun:-python 3.6.8-attrs >=18.2-jinja2 >=2.10-ruamel.yaml >=0.15.23-six >=1.12.0-yaml >=0.1.7-marshmallow >=3.0.0rc1*test:imports:-example_packageextra:cenv:env_name:examplepython:3.6dev_requirements:-ipython >=7.2.0ATTENTION:In therequirements-run-sectionthe minimal version of each package
has to be defined!
The same is required for thedev_requirements-section.
Not defining a version will not create or update a conda-environment,
because this is not the purpose of the conda-usage.
The validity of themeta.yamlis checked incenvusing themarshmallowpackage.
You can additionally add upper limits for the version like the following:- package>=0.1,<0.3If cenv is run the environment is created / updated from the definition inside
thismeta.yaml.
The creation of the backup of the previous environment ensures to undo changes
if any error occurs during recreation of the environment.ATTENTION:cenvcan only update the environment if it is not activated.
So ensure the environment to be deactivated before runningcenv.Per default exporting the conda environment definition into an environment.yml
is turned off.
If you want to turn this functionality on you need to modify your~/.config/cenv.ymlas described in the configuration-part.Example for the output of thecenvcommand:On create:Creatingcenv_dev├──Createenvironment│└──Created├──writemd5sumofmeta.yaml│└──updated└──DoneOn update:Updatingcenv_dev├──Createbackup│└──Created├──Removeexistingenv│└──Removed├──Createenvironment│├──Clearbackup││└──Cleared│└──Created├──writemd5sumofmeta.yaml│└──updated└──DoneDevelopment of cenvDevelop cenvTo create / update the dev environment to develop cenv run the pre-commit hooks
manually:pyenvlocal3.7.3dephellvenvshell--env=devdephelldepsinstallpre-commitrun--all-filesRunning testsTo create / update the test environment run:dephellvenvshell--env=pytestdephelldepsinstallTo run all tests run the following command:dephellprojecttest--env=pytestUpdating the docsTo create / update the docs environment run:dephellvenvshell--env=docsdephelldepsinstall--env=docsTo create / update the docs first run the tests as described above.
Then run:dephellvenvshell--env=docssphinx-apidoc-f-odocscenv_tool&&sphinx-build-Wdocsdocs/build