From 61b0ecbcdc8f0ee3d7790977438cb13bdabb5e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B5=E6=88=90=E7=A3=8A?= Date: Tue, 8 Jul 2014 12:18:29 +0800 Subject: [PATCH] Make Setup.py Support for zsh. When i use zsh for my default shell, `python setup.py` don't take the correct information for me.This change make it works. --- setup.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 9a309edd02..e4343529d9 100755 --- a/setup.py +++ b/setup.py @@ -79,6 +79,7 @@ class SetEnvVar(object): MAC_CHECK_FILES = [ '.bash_profile', '.bash_login', '.profile' ] LINUX_CHECK_FILES = [ '.bashrc' ] + ZSH_CHECK_FILES = ['.zshrc' ] RE_FORMAT = r'^export[ \t]+%s=(.+)' def __init__(self): @@ -96,13 +97,23 @@ class SetEnvVar(object): def _is_mac(self): return sys.platform == 'darwin' - def _get_filepath_for_setup(self): + def _is_zsh(self): + return os.environ.get('SHELL')[-3:] == "zsh" + def _get_unix_file_list(self): file_list = None - if self._isLinux(): + + if self._is_zsh(): + file_list = SetEnvVar.ZSH_CHECK_FILES + elif self._isLinux(): file_list = SetEnvVar.LINUX_CHECK_FILES elif self._is_mac(): file_list = SetEnvVar.MAC_CHECK_FILES + + return file_list + + def _get_filepath_for_setup(self): + file_list = self._get_unix_file_list(); file_to_write = None if file_list is None: @@ -213,11 +224,7 @@ class SetEnvVar(object): ret = os.environ[var] except Exception: if not self._isWindows(): - file_list = None - if self._isLinux(): - file_list = SetEnvVar.LINUX_CHECK_FILES - elif self._is_mac(): - file_list = SetEnvVar.MAC_CHECK_FILES + file_list = self._get_unix_file_list() if file_list is not None: home = os.path.expanduser('~')