Last active
August 29, 2015 14:15
-
-
Save miyakogi/ec2e0332a7dc9ff3b138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python2ツラい