This tool builds a conda environment with pip dependencies together
in a way that allows for cross-distro/cross-version compatibility.
They are two ways to use cpip:
cpip packwill package the environment into a portable tarball.cpip createwill simply create a ready-to-use environment.
The advantage of having a create command gives the user the option
to create the environment in the exact same way as the one that will
be deployed via the pack command.
- Assembles an environment with basic
condacommands from givencondaenvironment files - Installs cross-compilers and downloads/compiles
pippackages - Packages
condaenvironment viaconda-packtool - Unpacks environment to desired location (only for
createcommand)
- Linux
- macOS
- conda-pack (installed via
conda) - jq (installed via
conda) - python (installed via
conda)
The command below will add cpip to your PATH environment variable;
make sure to substitute <cpip_repository> for the absolute path
of the cpip repository.
export PATH=<cpip_repository>/bin>:$PATH
To keep this configuration every time you open a new shell, make sure to add this command to your shell configuration file.
- for login
bashshells this will be~/.bash_profile - for non-login
bashshells this will be~/.bashrc
conda update -n base -c defaults conda
conda init + restart terminal
conda env create from base of cpip directory
conda activate cpip
For more information: cpip pack --help or cpip create --help
Initial Setup (if using 'cpip pack'):
1. untar archive --> tar -xf <archive>
2. activate environment --> source <env-root>/bin/activate
3. fix path prefixes --> conda-unpack
Normal Use:
* activate --> source <env-root>/bin/activate
* deactivate --> source deactivate
NOTE: It's possible to change the path of <env-root> after
untarring, as long that is done prior to running conda-unpack.
Use cpip clean command to clean the conda and/or pip caches
pip dependencies can be installed via conda or poetry.
It is recommended to use a poetry project to define all the pip
packages in your project; this allows for lockfiles to pin package
versions properly. If you decide to use poetry, it makes sense to
move ALL pip dependencies from the conda environment file(s) to
a poetry project file.
Cross-compilers will be installed if any pip dependencies are
detected, or the --command option is used. They will always be
uninstalled automatically before the environment is finalized.
The cross-compilers used are Anaconda compiler tools (see here). They are not true cross-compilers since they are not configured to work cross-platform. However, they are configured to give a high degree of compatibility from one distro/version to another.
NOTE: If any Anaconda compiler tools or associated runtime libraries are present in the environment file(s), they will be removed completely. Only the compiler runtime libraries will be reinstalled, and potentially of different versions than before.
Immediately after the environment is created, it may be desired to run
certain commands in the active environment. To do this, we can use the
--command option as many times as desired to pass in commands that we
want to run while the environment is active. cpip will ensure that
cross-compilers are installed in the environment, so that the build
environment for running commands is consistent with the build environment
for compiling pip packages.
This tool can take more than one conda environment file.
These files will be loaded in the order they are given on
the command line. Different command line orders may produce
slightly different environments.
Changing certain configuration values may yield unexpected results.
cpip pack internally sets settings.virtualenvs.create to false,
but restores the setting to its original value upon failure or completion.
Running more than one cpip command simultaneously is not supported.
For systems that don't respect the XDG_CACHE_HOME environment variable,
Poetry may have concurrency issues, however, if using a poetry.lock file,
this will relieve any potential cache conflicts.
The cache issues can be solved completely if poetry allows for the
something more flexible like a --poetry-cache-dir command line option.