Skip to content

Instantly share code, notes, and snippets.

@SteelPangolin SteelPangolin/
Last active Aug 29, 2015

What would you like to do?
Decorate SCons Environment constructor so that Homebrew paths are always included.
from functools import wraps
import SCons.Environment
# Homebrew install directory
homebrew = '/opt/homebrew'
flag_prepends = [
('CFLAGS', '-I{}/include'.format(homebrew)),
('CXXFLAGS', '-I{}/include'.format(homebrew)),
('LDFLAGS', '-L{}/lib' .format(homebrew)),
def add_homebrew_vars(environment_init):
def wrapper(self, *args, **kwargs):
for var, flag in flag_prepends:
flags_list = [flag]
if var in kwargs:
kwargs[var] = ' '.join(flags_list)
environment_init(self, *args, **kwargs)
self.PrependENVPath('PATH', '{}/bin'.format(homebrew))
return wrapper
SCons.Environment.Environment.__init__ = add_homebrew_vars(SCons.Environment.Environment.__init__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.