Skip to content

Instantly share code, notes, and snippets.

@miyakogi
Last active August 29, 2015 14:15
Show Gist options
  • Save miyakogi/ec2e0332a7dc9ff3b138 to your computer and use it in GitHub Desktop.
Save miyakogi/ec2e0332a7dc9ff3b138 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import path, environ
from subprocess import check_output, call
from shlex import split
from codecs import open
home_dir = environ['HOME']
python_path = u'''
export PYTHONPATH=/Library/Python/2.7/site-packages:$PYTHONPATH
export PYTHONPATH=/(pipでのインストール先のパス)/site-packages:$PYTHONPATH
'''
if call(split('which brew')) == 0:
brew_prefix = unicode(check_output(split('brew --prefix')))
brew_python_path = u''.join([u'export PYTHONPATH=',
brew_prefix.replace(u'\n', u''),
u'/lib/python2.7/site-packages:$PYTHONPATH'])
python_path = u''.join([python_path, brew_python_path])
def main():
fpath = path.join(home_dir, 'dummy.sh')
with open(fpath, 'a', encoding='utf-8') as f:
f.write(python_path)
if __name__ == '__main__':
main()
@miyakogi
Copy link
Author

Python2ツラい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment