Permalink
Browse files

use setup.py to fix sys.path at install time for bin/euca-*; install …

…into @prefix@ instead of /usr/local
  • Loading branch information...
1 parent befbc9c commit f5604ae6b13fd0024c9ffeaaef0d1630cf982036 @grze grze committed Apr 20, 2011
Showing with 63 additions and 35 deletions.
  1. +2 −1 clc/eucadmin/setup.cfg.in
  2. +61 −34 clc/eucadmin/setup.py
@@ -1,2 +1,3 @@
[install]
-install_scripts=@prefix@/usr/sbin
+install_scripts=@prefix@/usr/sbin
+prefix=@prefix@/usr
View
@@ -29,46 +29,73 @@
#
# Author: Mitch Garnaat mgarnaat@eucalyptus.com
+import sys
+import os
from distutils.core import setup
+from distutils.sysconfig import get_python_lib
+import fileinput
+import ConfigParser
-setup(name = "eucadmin",
- version = '0.1',
- description = "Eucalyptus Admin Tools",
+cfg = ConfigParser.ConfigParser()
+cfg.read('setup.cfg')
+prefix = os.path.dirname(cfg.get('install', 'prefix'))
+install_scripts = cfg.get('install', 'install_scripts')
+path_header = 'import sys\nsys.path.append(\"%s/%s\")\n' % (prefix, get_python_lib())
+
+binaries = ["bin/euca-add-user", "bin/euca-add-user-group",
+ "bin/euca-delete-user", "bin/euca-delete-user-group",
+ "bin/euca-add-user", "bin/euca-add-user-group",
+ "bin/euca-delete-user",
+ "bin/euca-delete-user-group",
+ "bin/euca-deregister-cluster",
+ "bin/euca-deregister-storage-controller",
+ "bin/euca-deregister-walrus",
+ "bin/euca-describe-clusters",
+ "bin/euca-describe-components",
+ "bin/euca-describe-properties",
+ "bin/euca-describe-services",
+ "bin/euca-describe-storage-controllers",
+ "bin/euca-describe-user-groups",
+ "bin/euca-describe-users",
+ "bin/euca-describe-walruses",
+ "bin/euca-get-credentials",
+ "bin/euca-modify-cluster",
+ "bin/euca-modify-property",
+ "bin/euca-modify-storage-controller",
+ "bin/euca-modify-walrus",
+ "bin/euca-register-cluster",
+ "bin/euca-register-storage-controller",
+ "bin/euca-register-walrus"]
+mangled = [ "%s/%s" % (install_scripts,os.path.basename(x)) for x in binaries ]
+binaries.append("bin/euca_conf")
+
+setup(name="eucadmin",
+ version='0.1',
+ description="Eucalyptus Admin Tools",
long_description="CLI tools to help administer Eucalyptus",
- author = "Mitch Garnaat",
- author_email = "mgarnaat@eucalyptus.com",
- scripts = ["bin/euca-add-user", "bin/euca-add-user-group",
- "bin/euca-delete-user", "bin/euca-delete-user-group",
- "bin/euca-add-user", "bin/euca-add-user-group",
- "bin/euca_conf", "bin/euca-delete-user",
- "bin/euca-delete-user-group",
- "bin/euca-deregister-cluster",
- "bin/euca-deregister-storage-controller",
- "bin/euca-deregister-walrus",
- "bin/euca-describe-clusters",
- "bin/euca-describe-components",
- "bin/euca-describe-properties",
- "bin/euca-describe-services",
- "bin/euca-describe-storage-controllers",
- "bin/euca-describe-user-groups",
- "bin/euca-describe-users",
- "bin/euca-describe-walruses",
- "bin/euca-get-credentials",
- "bin/euca-modify-cluster",
- "bin/euca-modify-property",
- "bin/euca-modify-storage-controller",
- "bin/euca-modify-walrus",
- "bin/euca-register-cluster",
- "bin/euca-register-storage-controller",
- "bin/euca-register-walrus"],
- url = "http://eucalyptus.com/",
- packages = ['eucadmin'],
- license = 'BSD',
- platforms = 'Posix; MacOS X; Windows',
- classifiers = [ 'Development Status :: 5 - Production/Stable',
+ author="Mitch Garnaat",
+ author_email="mgarnaat@eucalyptus.com",
+ scripts=binaries,
+ url="http://eucalyptus.com/",
+ packages=['eucadmin'],
+ license='BSD',
+ platforms='Posix; MacOS X; Windows',
+ classifiers=[ 'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Topic :: Internet',
],
)
+
+if 'install' in sys.argv[1:]:
+ for line in fileinput.input(mangled, inplace=1,backup=None):
+ if fileinput.isfirstline():
+ print line,
+ print path_header,
+ elif line == 'import sys\n':
+ continue
+ elif line.startswith('sys.path.append'):
+ continue
+ else:
+ print line,

0 comments on commit f5604ae

Please sign in to comment.