From ed2e1abe285d10582894f85bd584956bb4bc583d Mon Sep 17 00:00:00 2001 From: Jun Wang Date: Tue, 10 May 2016 16:47:50 +0800 Subject: [PATCH] Check env and install to correct path in debian and Ubuntu Change-Id: I023601e6c5b0ceb1243f3ae7d785aaae7bc17d94 --- setup.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/setup.py b/setup.py index 669282a..1c11f45 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,20 @@ from distutils.core import setup MOD_NAME = 'gitbuildsys' +def check_debian(): + """--install-layout is recognized after 2.5""" + if sys.version_info[:2] > (2, 5): + if len(sys.argv) > 1 and 'install' in sys.argv: + try: + import platform + (dist, _, _) = platform.linux_distribution() + # for debian-like distros, mods will be installed to + # ${PYTHONLIB}/dist-packages + if dist in ('debian', 'Ubuntu'): + sys.argv.append('--install-layout=deb') + except AttributeError: + pass + def get_version(mod_name): """Get version from module __init__.py""" path = os.path.join(mod_name, "__init__.py") @@ -25,6 +39,8 @@ def get_version(mod_name): print 'Unable to find version in %s' % path sys.exit(1) +check_debian() + setup(name='gbs', version=get_version(MOD_NAME), description='The command line tools for Tizen package developers', -- 2.34.1