My favorites | Sign in
waf
Project Home Issues Source
Search
for
Virtualenv  
Using Waf under virtualenv.
Updated Sep 10, 2011

Introduction

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

"""
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
Powered by Google Project Hosting