From b245136d8d2295a7364a99145f176dd7ba4fd995 Mon Sep 17 00:00:00 2001 From: Nicolargo Date: Sat, 29 Nov 2014 11:15:08 +0100 Subject: Add patch for pip user install (thk to @asergi) (correct issue #383) --- setup.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index a823d15b..4028bd70 100755 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ import sys from setuptools import setup + def get_data_files(): data_files = [ ('share/doc/glances', ['AUTHORS', 'COPYING', 'NEWS', 'README.rst', @@ -14,21 +15,29 @@ def get_data_files(): ('share/man/man1', ['man/glances.1']) ] - if hasattr(sys, 'real_prefix') or 'bsd' in sys.platform: + if os.name == 'posix' and os.getuid() == 0: # Unix-like + root privileges + if 'bsd' in sys.platform: + conf_path = os.path.join(sys.prefix, 'etc', 'glances') + elif 'linux' in sys.platform: + conf_path = os.path.join('/etc', 'glances') + elif 'darwin' in sys.platform: + conf_path = os.path.join('/usr/local', 'etc', 'glances') + elif hasattr(sys, 'real_prefix'): # virtualenv conf_path = os.path.join(sys.prefix, 'etc', 'glances') - elif not hasattr(sys, 'real_prefix') and 'linux' in sys.platform: - conf_path = os.path.join('/etc', 'glances') - elif 'darwin' in sys.platform: - conf_path = os.path.join('/usr/local', 'etc', 'glances') - elif 'win32' in sys.platform: + elif 'win32' in sys.platform: # windows conf_path = os.path.join(os.environ.get('APPDATA'), 'glances') + else: # Unix-like + per-user install + conf_path = os.path.join('etc', 'glances') + data_files.append((conf_path, ['conf/glances.conf'])) for mo in glob.glob('i18n/*/LC_MESSAGES/*.mo'): - data_files.append((os.path.dirname(mo).replace('i18n/', 'share/locale/'), [mo])) + data_files.append( + (os.path.dirname(mo).replace('i18n/', 'share/locale/'), [mo])) return data_files + def get_requires(): requires = ['psutil>=2.0.0'] if sys.platform.startswith('win'): -- cgit v1.2.3