diff --git a/setup.py b/setup.py index d930eb2e..772faf4d 100644 --- a/setup.py +++ b/setup.py @@ -70,6 +70,8 @@ setup( #'Programming Language :: Python :: 3.3', ) ) +# real_prefix should only be set under a virtualenv +using_virtualenv = hasattr(sys, 'real_prefix') ''' @todo: need to clean this up or do it with puppet/chef ''' # Default Config Options @@ -108,10 +110,14 @@ else: # Get uid and gid of the current user to set permissions (Linux/OSX only) if platform.system().lower() != 'windows': - sudo_user = os.getenv("SUDO_USER") - uid = pwd.getpwnam(sudo_user).pw_uid - gid = pwd.getpwnam(sudo_user).pw_gid - + if using_virtualenv: + working_user = os.getenv("USER") + else: + working_user = os.getenv("SUDO_USER") + + uid = pwd.getpwnam(working_user).pw_uid + gid = pwd.getpwnam(working_user).pw_gid + config_dirs = os.listdir("configs") for dir in config_dirs: if not os.path.exists("{0}/{1}".format(config_dir, dir)):