Skip to content

Instantly share code, notes, and snippets.

@ChrisBeaumont
Created January 10, 2013 02:06
Show Gist options
  • Save ChrisBeaumont/4498773 to your computer and use it in GitHub Desktop.
Save ChrisBeaumont/4498773 to your computer and use it in GitHub Desktop.
Workaround linker issue when installing scikit-learn on a mac that uses macports
from subprocess import check_call
#remove build directory
check_call('rm -rf build'.split())
#compile and capture stdout
with open('build.log', 'w') as log:
check_call('python setup.py install --user'.split(), stdout=log)
log = open('build.log').read().splitlines()
#find all linker commands that used -L/opt/local/lib
bad_cmds = filter(lambda x: '-L/opt/local/lib' in x, log)
#strip out this part, and re-run
for cmd in bad_cmds:
cmd2 = cmd.replace('-L/opt/local/lib', '')
print cmd2
check_call(cmd2.split())
check_call('python setup.py install --user'.split())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment