Check env and install to correct path in debian and Ubuntu
authorJun Wang <junbill.wang@samsung.com>
Tue, 10 May 2016 08:47:50 +0000 (16:47 +0800)
committerSoonKyu Park <sk7.park@samsung.com>
Thu, 16 Jun 2016 00:49:30 +0000 (09:49 +0900)
Change-Id: I023601e6c5b0ceb1243f3ae7d785aaae7bc17d94

setup.py

index 669282a..1c11f45 100644 (file)
--- 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',