Environment variables
Dynamic behavior based on state of build process
There are times when you may want to process a single file in different ways at more than 1 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
meta.yaml
file.BUILD---Set during processing of the
bld.bat
orbuild.sh
script files.TEST---Set during the running of any
run_test
scripts, which also includes any commands defined inmeta.yaml
in thetest/commands
section.
The CONDA_BUILD_STATE variable is undefined outside of these locations.
Environment variables set during the build process
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.
ARCH |
Either |
CMAKE_GENERATOR |
The CMake generator string for the current build
environment. On Linux systems, this is always
|
CONDA_BUILD=1 |
Always set. |
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. |
|
Complete build string of the package being built, including hash. EXAMPLE: py27h21422ab_0 . Conda-build 3.0+. |
|
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. |
PY3K |
|
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. |
build_platform |
The native subdir of the conda executable |
Unix-style packages on Windows, which are usually statically
linked to executables, are built in a special Library
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
|
LIBRARY_BIN |
|
LIBRARY_INC |
|
LIBRARY_LIB |
|
LIBRARY_PREFIX |
|
SCRIPTS |
|
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. |
PKG_CONFIG_PATH |
Path to |
The environment variables listed in the following table are defined only on macOS.
CFLAGS |
|
CXXFLAGS |
Same as CFLAGS. |
LDFLAGS |
Same as CFLAGS. |
MACOSX_DEPLOYMENT_TARGET |
Same as the Anaconda Python macOS deployment target. Currently |
OSX_ARCH |
|
The environment variable listed in the following table is defined only on Linux.
LD_RUN_PATH |
|
Git environment variables
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 meta.yaml
files to set things---such as the build string---based on the
state of the git repository.
Mercurial environment variables
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. |
Inherited environment variables
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
meta.yaml
:
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.
Additionally, values can be set by including =
followed by the desired value:
build:
script_env:
- MY_VAR=some value
Warning
Inheriting environment variables can make it difficult for
others to reproduce binaries from source with your recipe. Use
this feature with caution or explicitly set values using the =
syntax.
Note
If you split your build and test phases with --no-test
and --test
,
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.
Environment variables that affect the build process
CONDA_PY |
The Python version used to build the package. Should
be |
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 |
Environment variables that affect the test process
All of the above environment variables are also set during the test process, using the test prefix instead of the build prefix.