changeset 35:122c56779f2b

add functionality to run post-install python scripts
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 08 Aug 2011 18:08:49 -0700
parents 261e2d2d26ad
children 77285bafc36a
files carton.py setup.py
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/carton.py	Mon Jul 11 15:03:50 2011 -0700
+++ b/carton.py	Mon Aug 08 18:08:49 2011 -0700
@@ -71,6 +71,9 @@
 PACKAGE_SOURCES=%(PACKAGE_SOURCES)s
 CARTON=%(CARTON)s
 
+# post-install scripts
+PYTHON_SCRIPTS=%(PYTHON_SCRIPTS)s
+
 # parse options
 usage = os.path.basename(sys.argv[0]) + ' [options]'
 parser = OptionParser(usage=usage, description=__doc__)
@@ -158,6 +161,12 @@
 
 # cleanup virtualenv tempdir
 shutil.rmtree(tempdir)
+
+# run post-install scripts
+for script in PYTHON_SCRIPTS:
+    if not os.path.isabs(script):
+        script = os.path.join(os.path.abspath(ENV), script)
+    call([python, script])
 """
 
 def isURL(path):
@@ -178,6 +187,9 @@
     parser.add_option('-p', '--package', dest='package',
                       action='store_true', default=False,
                       help="create python packages from sources; do not take entire subdirectory")
+    parser.add_option('--python-script', dest='python_scripts', default=[],
+                      action='append',
+                      help="post-uncartoning python scripts to run in the virtualenv; these should be relative to $VIRTUAL_ENV")
     parser.add_option('--virtualenv', dest='virtualenv',
                       help="use this virtualenv URL or file tarball")
     options, args = parser.parse_args(args)
@@ -269,6 +281,7 @@
     variables = {'VIRTUAL_ENV': VIRTUAL_ENV.encode('zlib').encode('base64'),
                  'ENV': environment,
                  'CARTON': repr(carton),
+                 'PYTHON_SCRIPTS': repr(options.python_scripts),
                  'PACKAGE_SOURCES': repr(source_array)}
     f = file(outfile, 'w')
     f.write(template % variables)
--- a/setup.py	Mon Jul 11 15:03:50 2011 -0700
+++ b/setup.py	Mon Aug 08 18:08:49 2011 -0700
@@ -6,7 +6,7 @@
 except ImportError:
     description = None
 
-version = '0.2.1'
+version = '0.2.2'
 
 setup(name='carton',
       version=version,