Package: cpenv
cpenvManage software plugins, project dependencies and environment
variables using Modules.InstallationThe recommended method of installing cpenv is viapipx.
Pipx is used to install python cli applications in isolation.pipx install cpenvpipx upgrade cpenvpipx uninstall cpenvOverviewCpenv is a cli tool and python library used to create, edit, publish, and activate Modules. A Module is a folder containing a dependency, like Arnold for Maya, and a module file that configures it.Environment VariablesVariableDescriptionDefaultCPENV_HOMECustomize path to cpenv homeCPENV_DISABLE_PROMPTDisable prompt when modules activated0CPENV_ACTIVE_MODULESList of activated modulesCPENV_SHELLPreferred subshell like "powershell"Example ModulessnackCreate a ModuleUsecpenv create <module>to use a guide to create a new Module.
This will create a new folder in your current working directory with a module file in it.Edit a ModuleEach Module contains a module.yml file, referred to as a module file. A module file contains metadata like the name and version of a module, as well as configuration, like environment variables.# Variables
# $MODULE - path to this module
# $PLATFORM - platform name (win, mac, linux)
# $PYVER - python version (2.7, 3.6...)

# Wrap variables in brackets when they are nested within a string.
#     DO 'this${variable}isnested/' NOT 'this$variableisnested'

name: 'my_module'
version: '0.1.0'
description: 'My first module.'
author: 'Me'
email: 'me@email.com'
requires: []
environment:
    MY_MODULE_VAR: 'Test'Environment keySetting a value will insert a key or overwrite it's existing value.SOME_VAR: 'SOME_VALUE'Use the $MODULE variable for module relative paths.RELATIVE_VAR: $MODULE/binUse lists to prepend values to a key.PATH:
    - $MODULE/binUsewin,linuxandmac or osxkeys to declare platform specific values. If you leave out a platform, the variable will not be included on that platform.PLATFORM_VAR:
    mac: /mnt/some/path
    linux: /Volumes/some/path
    win: C:/some/pathYou can also use platform keys when prepending values to a variable.PATH:
    - mac: $MODULE/macattack
      linux: $MODULE/penguin
      win: $MODULE/squaresReuse environment variables to simplify things.BASE: $MODULE/$PLATFORM/base
PATH:
    - $BASE/bin
PYTHONPATH:
    - $BASE/pythonAdvancedThe implicit set and prepend operations above cover the most common use cases when modifying environment variables. For more advanced use cases you can use the following explicit operation keys.SVAR:
    set:
        - Value0
        - Value1
PVAR:
    prepend:
        - X
RVAR:
    unset: 1
PATH:
    remove:
        - C:/Python27
        - C:/Python27/Scripts
PYTHONPATH:
    append:
        - $MODULE/python
        - $MODULE/libYou can also uses lists of opreations to perform complex modifications.PATH:
    - remove: /some/file/path
    - append: /some/other/path
    - prepend: /one/more/pathOne workflow that this enables is the use of modules solely for the purpose of overriding environment variables. Imagine you have a modulemy_tooland it uses a variableMY_TOOL_PLUGINSto lookup plugins.name: my_tool
...
environment:
    MY_TOOL_PLUGINS:
        - //studio/dev/my_tool/plugins
        - //studio/projects/test_project/pluginsNow imagine you have a new project and you wantmy_toolto look at a different location for plugins just for that project. Rather than create a new version of themy_toolmodule, create a override module. We might name this module after our project,project_b.name: project_b
...
environment:
    MY_TOOL_PLUGINS:
        set:
            - //studio/prod/my_tool/plugins
            - //studio/projects/project_b/pluginsAll we have to do is activatemy_toolandproject_bin that order to make sure our overrides are used.> cpenv activate my_tool project_bRequires keyThe requires key is a list of dependencies that a module needs to function. Currently this is only used for reference, these modules will not be activated automatically.Test a ModuleWhen you're working on a module navigate into it's root directory. Then you can activate it usingcpenv activate .. This is
the best way to validate your module prior to publishing.Publish a ModuleOnce you're Module is ready for production, usecpenv publish .to publish it. Publishing a Module uploads it to a Repo of your choosing.ReposRepos are storage locations for Modules that support finding, listing, uploading, and downloading Modules viarequirementslikemy_module-0.1.0. Cpenv is configured with the following LocalRepos by default:cwd- Your current working directoryuser- A user specific repohome- A machine wide repoUsecpenv repo listto display your configured Repos. LocalRepos point directly to folders on your local file system.
Customize the home Repo by setting theCPENV_HOMEenvironment variable.When you activate a module using a requirement, all configured Repos are searched and the best match is used. If the resolved
module is not in a LocalRepo it will be downloaded to your home Repo then activated. This is one of the key features of cpenv
and allows for strong distributed workflows. For example, you can configure a remote repo like the ShotgunRepo and store your modules directly in aShotgun studiodatabase.Visit the tk-cpenv repository for more info on using cpenv with ShotgunRequirementsRequirements are strings used to resolve and activate modules in Repos. They can be versionless likemy_moduleor require a
version likemy_module-0.1.0. Cpenv supports semver/calver, simple versions (v1), and what I like to callweirdversions
like 12.0v2 (The Foundry products). In the future cpenv may support more complex requirements by utilizingresolvelib.