- Dynamic behavior based on state of build process
- Environment variables set during the build process
- Git environment variables
- Mercurial environment variables
- Inherited environment variables
- Environment variables that affect the build process
- Environment variables to set build features
- Environment variables that affect the test process
There are times when you may want to process a single file in different ways at more than one step in the render-build-test flow of conda build. Conda build sets the CONDA_BUILD_STATE environment variable during each of these phases. The possible values are:
- RENDER—Set during evaluation of the
- BUILD—Set during processing of the
- TEST—Set during the running of any
run_testscripts, which also includes any commands defined in
The CONDA_BUILD_STATE variable is undefined outside of these locations.
During the build process, the following environment variables
are set, on Windows with
bld.bat and on macOS and Linux with
build.sh. By default, these are the only variables available
to your build script. Unless otherwise noted, no variables are
inherited from the shell environment in which you invoke
conda-build. To override this behavior, see
Inherited environment variables.
|CMAKE_GENERATOR||The CMake generator string for the current build
environment. On Linux systems, this is always
|CPU_COUNT||The number of CPUs on the system, as reported by
|SHLIB_EXT||The shared library extension.|
|DIRTY||Set to 1 if the
|HTTP_PROXY||Inherited from your shell environment.|
|HTTPS_PROXY||Inherited from your shell environment.|
|LANG||Inherited from your shell environment.|
|MAKEFLAGS||Inherited from your shell environment. May be used to set
additional arguments to make, such as
|PY_VER||Python version building against. Set with the
|NPY_VER||NumPy version to build against. Set with the
|PATH||Inherited from your shell environment and augmented with
|PREFIX||Build prefix to which the build script should install.|
|PKG_BUILDNUM||Build number of the package being built.|
|PKG_NAME||Name of the package being built.|
|PKG_VERSION||Version of the package being built.|
|PKG_BUILD_STRING||Complete build string of the package being built, including hash. EXAMPLE: py27h21422ab_0 . Conda-build 3.0+.|
|PKG_HASH||Hash of the package being built, without leading h. EXAMPLE: 21422ab . Conda-build 3.0+.|
|PYTHON||Path to the Python executable in the host prefix. Python is installed only in the host prefix when it is listed as a host requirement.|
|R||Path to the R executable in the build prefix. R is only installed in the build prefix when it is listed as a build requirement.|
|RECIPE_DIR||Directory of the recipe.|
|SP_DIR||Python’s site-packages location.|
|SRC_DIR||Path to where source is unpacked or cloned. If the source file is not a recognized file type—zip, tar, tar.bz2, or tar.xz—this is a directory containing a copy of the source file.|
|STDLIB_DIR||Python standard library location.|
Unix-style packages on Windows, which are usually statically
linked to executables, are built in a special
directory under the build prefix. The environment variables
listed in the following table are defined only on Windows.
|CYGWIN_PREFIX||Same as PREFIX, but as a Unix-style path, such as
|VS_MAJOR||The major version number of the Visual Studio version
activated within the build, such as
|VS_VERSION||The version number of the Visual Studio version activated
within the build, such as
|VS_YEAR||The release year of the Visual Studio version activated
within the build, such as
The environment variables listed in the following table are defined only on macOS and Linux.
|HOME||Standard $HOME environment variable.|
The environment variables listed in the following table are defined only on macOS.
|CXXFLAGS||Same as CFLAGS.|
|LDFLAGS||Same as CFLAGS.|
|MACOSX_DEPLOYMENT_TARGET||Same as the Anaconda Python macOS deployment target. Currently
The environment variable listed in the following table is defined only on Linux.
The environment variables listed in the following table are defined when the source is a git repository, specifying the source either with git_url or path.
|GIT_BUILD_STR||String that joins GIT_DESCRIBE_NUMBER and GIT_DESCRIBE_HASH by an underscore.|
|GIT_DESCRIBE_HASH||The current commit short-hash as displayed from
|GIT_DESCRIBE_NUMBER||String denoting the number of commits since the most recent tag.|
|GIT_DESCRIBE_TAG||String denoting the most recent tag from the current
commit, based on the output of
|GIT_FULL_HASH||String with the full SHA1 of the current HEAD.|
These can be used in conjunction with templated
files to set things—such as the build string—based on the
state of the git repository.
The environment variables listed in the following table are defined when the source is a mercurial repository.
|HG_BRANCH||String denoting the presently active branch.|
|HG_BUILD_STR||String that joins HG_NUM_ID and HG_SHORT_ID by an underscore.|
|HG_LATEST_TAG||String denoting the most recent tag from the current commit.|
|HG_LATEST_TAG_DISTANCE||String denoting number of commits since the most recent tag.|
|HG_NUM_ID||String denoting the revision number.|
|HG_SHORT_ID||String denoting the hash of the commit.|
Other than those mentioned above, no variables are inherited from
the environment in which you invoke conda build. You can choose
to inherit additional environment variables by adding them to
build: script_env: - TMPDIR - LD_LIBRARY_PATH # [linux] - DYLD_LIBRARY_PATH # [osx]
If an inherited variable is missing from your shell environment, it remains unassigned, but a warning is issued noting that it has no value assigned.
NOTE: Inheriting environment variables can make it difficult for others to reproduce binaries from source with your recipe. Use this feature with caution or avoid it.
NOTE: If you split your build and test phases with
you need to ensure that the environment variables present at build time and test
time match. If you do not, the package hashes may use different values, and your
package may not be testable, because the hashes will differ.
|CONDA_PY||The Python version used to build the package. Should
|CONDA_NPY||The NumPy version used to build the package, such as
|CONDA_PREFIX||The path to the conda environment used to build the
package, such as
The environment variables listed in the following table are inherited from the process running conda build. These variables control Features.
All of the above environment variables are also set during the test process, using the test prefix instead of the build prefix.