My favorites | Sign in
Logo
waf
                
Search
for
Updated Jul 29, 2009 by jamie.alan.kirpatrick
Virtualenv  
Using Waf under virtualenv.

Introduction

The following code may be useful if you attempt to use Waf under virtualenv and additionally require use of the stock python tool.

"""
Monkey patch python detection under virtualenv.
We need to ensure the real Python instance is picked up for building
extensions and linking libraries etc.
"""
if hasattr(sys, "real_prefix"):
    from Configure import ConfigurationContext
    _find_program = ConfigurationContext.find_program
    def find_program(conf, program, **kwargs):
        if program == "python":
            search_path = sys.real_prefix
            if sys.platform != "win32":
                search_path = os.path.join(search_path, "bin")
            old_path = conf.environ["PATH"]
            conf.environ["PATH"] = search_path
            result = _find_program(conf, program, **kwargs)
            conf.environ["PATH"] = old_path
        return _find_program(conf, program, **kwargs) 
    ConfigurationContext.find_program = find_program

Sign in to add a comment
Hosted by Google Code