Commits

Michal Dvorak committed 4c20e54

Added README contents + additional docs

  • Participants
  • Parent commits 889ac9f

Comments (0)

Files changed (3)

 Setup Buildout Recipe
 =====================
 
-TODO
+Runs the setup.py in all specified directories, using custom interpreter, e.g. the one generated by zc.buildout.egg
+recipe. Its intended be used to run any commands that require libraries (eggs) from buildout.
+Any additional command line arguments are passed to the setup.py. Setup is always run in working directory where it
+resides.
+
+Parameters
+use-interpreter - Name of python interpreter to use.
+develop - List of directories, where setup.py files reside. Typically ${buildout:develop} to list all developed apps.
+command - Command line argument for the setup.py. Optional.
+
+Typical buildout.cfg snippet
+
+[python]
+recipe = zc.recipe.egg
+interpreter = python
+eggs = ${buildout:eggs}
+
+[test]
+recipe = setup-recipe
+use-interpreter = ${python:interpreter}
+develop = ${buildout:develop}
+command = test
+
+Running `./bin/test` will then run `./bin/python setup.py test` for every developed project.
 def read(fname):
     return open(os.path.join(os.path.dirname(__file__), fname)).read()
 
+description = "Runs the setup.py in all specified directories, using custom interpreter, "\
+              "e.g. the one generated by zc.buildout.egg recipe."
+
 setup(
     name="setup-recipe",
-    version='0.1',
-    entry_points = {'zc.buildout': ['default = setup_recipe:Recipe']},
+    version='1.0.alpha0',
+    entry_points={'zc.buildout': ['default = setup_recipe:Recipe']},
     url='https://bitbucket.org/mdvorak/setup-recipe',
     author='Michal Dvorak',
     author_email='mikee@mdvorak.org',
-    description='TODO',
+    description=description,
     long_description=read('README.txt'),
     packages=find_packages(),
     classifiers=[

File setup_recipe/__init__.py

 import os, re
 
 class Recipe(object):
+    """
+    Buildout recipe that writes out script into bin directory. Script then runs setup.py
+    in all configured directories using specified python interpreter.
+
+    Supported options:
+    use-interpreter - Name of python interpreter to use.
+    develop - List of directories, where setup.py files reside. Typically ${buildout:develop} to list all developed apps.
+    command - Command line argument for the setup.py. Optional.
+    """
+
     def __init__(self, buildout, name, options):
         self.buildout, self.name, self.options = buildout, name, options
 
             self.develop.append(os.path.abspath(dir))
 
     def install(self):
+        # Read settings
         bin = self.buildout['python']['bin-directory']
         python = self.buildout['python']['executable']
         script = os.path.join(bin, self.name)
         interpreter = os.path.join(bin, self.options['use-interpreter'])
         command = self.options.get('command')
 
+        # Write out the script. Ugly but functional.
         f = open(script, 'w')
         f.write('#!' + python + '\n')
 
         f.write('import os, sys\n')
         f.write('from subprocess import call\n\n')
 
+        # Write settings
         f.write('INTERPRETER = "' + interpreter + '"\n')
         f.write('DEVELOP = ' + str(self.develop) + '\n')
 
 
         f.write('ARGS = sys.argv[1:]\n\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) if len(dir) else 0\n')
         f.write('  if r != 0:\n')
         f.write('    sys.exit(r)\n\n')
 
+        # Finished
         f.write('print "All OK"\n')
         f.write('sys.exit(0)\n')
 
         f.close()
-        os.chmod(script, 0777)
+
+        # Make it executable
+        os.chmod(script, 0755)
 
         return script