Commits

Anonymous committed 80d25e9

Added `script` option

  • Participants
  • Parent commits ff11bde

Comments (0)

Files changed (3)

 
 * develop - List of directories, where ``setup.py`` file reside. Typically ``${buildout:develop}`` to list all developed apps.
 * use-interpreter - Name of python interpreter to use. Optional, when not specified, system interpreter is used.
-* command - Command line argument for the ``setup.py``. Optional.
+* command - Command line argument for the ``setup.py`` (or other defined script). Optional.
+* script - Name of the executed script. Defaults to ``setup.py``.
 
 Typical buildout.cfg snippet::
 
 
 setup(
     name="setup-recipe",
-    version='1.0.alpha2',
+    version='1.0.alpha3',
     entry_points={'zc.buildout': ['default = setup_recipe:Recipe']},
     url='https://bitbucket.org/mdvorak/setup-recipe',
     author='Michal Dvorak',

File setup_recipe/__init__.py

     Supported options:
     * develop - List of directories, where `setup.py` file reside. Typically `${buildout:develop}` to list all developed apps.
     * use-interpreter - Name of python interpreter to use. Optional, when not specified, system interpreter is used.
-    * command - Command line argument for the `setup.py`. Optional.
+    * command - Command line argument for the `setup.py` (or other defined script). Optional.
+    * script - Name of the executed script. Defaults to `setup.py`.
     """
 
     def __init__(self, buildout, name, options):
         # Read settings
         bin = self.buildout['python']['bin-directory']
         python = self.buildout['python']['executable']
-        script = os.path.join(bin, self.name)
+        output = os.path.join(bin, self.name)
         interpreter = os.path.join(bin, self.options.get('use-interpreter', python))
         command = self.options.get('command')
+        script = self.options.get('script', 'setup.py')
 
         # Write out the script. Ugly but functional.
-        f = open(script, 'w')
+        f = open(output, 'w')
         f.write('#!' + python + '\n')
 
         f.write('import os, sys\n')
         # Write settings
         f.write('INTERPRETER = "' + interpreter + '"\n')
         f.write('DEVELOP = ' + str(self.develop) + '\n')
+        f.write('SCRIPT = "' + script + '"\n')
 
         if command:
             f.write('CMD = ["' + command + '"]\n')
         # Loop that runs setup.py
         f.write('for dir in DEVELOP:\n')
         f.write('  print "Processing " + dir\n')
-        f.write('  r = call([INTERPRETER, os.path.join(dir, "setup.py")] + CMD + ARGS, cwd=dir)\n')
+        f.write('  r = call([INTERPRETER, os.path.join(dir, SCRIPT)] + CMD + ARGS, cwd=dir)\n')
         f.write('  if r != 0:\n')
         f.write('    sys.exit(r)\n\n')
 
         f.close()
 
         # Make it executable
-        os.chmod(script, 0755)
+        os.chmod(output, 0755)
 
-        return script
+        return output
 
     update = install