Search code examples
bjamjamb2

Access environment variables inside a jam configuration file


I am trying to cross compile Boost python library with x86_64-w64-mingw32 compiler on a Linux host. I need to specify the path to python libraries and include files inside my user-config.jam file. Instead of hard coding this path I would like to read it through an environment variable.

Below are the contents of my user-config.jam file:

import os ;
local PYTHON_DEPS_1 = os.environ[PYTHON_DEPS] ;
using python : 2.7 : /usr/local/bin/python2.7 : $(PYTHON_DEPS_1)/usr/include/python2.7 : $(PYTHON_DEPS_1)/usr/lib ;

However the above expands to the below include path used during boost python module build in the compiler command line:

" -I"os.environ[PYTHON_DEPS]/usr/include/python2.7"

Can someone please guide how to properly use environment variables ?


Solution

  • Try changing your

    local PYTHON_DEPS_1 = os.environ[PYTHON_DEPS] ;
    

    to

    local PYTHON_DEPS_1 = [ os.environ PYTHON_DEPS ] ;