[recipes] update quick ans setup.distutils recipes draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:53:00 +0100
changeset 1751 56eb553a3618
parent 1750 6c752f8e5fc5
child 1752 31c34cf9f19f
[recipes] update quick ans setup.distutils recipes
recipes/apycot.quick.py
recipes/apycot.setup.distutils.py
--- a/recipes/apycot.quick.py	Thu Nov 13 14:50:54 2014 +0100
+++ b/recipes/apycot.quick.py	Thu Nov 13 14:53:00 2014 +0100
@@ -1,24 +1,27 @@
 # an apycot recipe that run unit tests for python projects
 import os
 from os.path import join
+import sys
+
 from checkers.apycot import python # trigger registration
 from apycotlib import narvalactions as na
 # `plan` (narvalbot.engine.Plan) exists in the globals
 
 with na.apycot_environment(plan) as test:
-    for pe, rev in test.dependencies():
+    for cset, url, repoeid, checkout, setup in test.dependencies():
         # first need to retrieve the sources of the dependency
-        vcsrepo = pe['repository']
         # use the correct recipe to make the checkout and ensure the working
         # directory is at the selected revision
-        src = join(test.tmpdir, 'src', str(vcsrepo['eid']))
-        test.exec_recipe(vcsrepo['checkout_recipe'], rev=rev,
+        src = join(test.tmpdir, 'src', str(repoeid))
+        test.exec_recipe(checkout, rev=cset,
                          dst_dir=src,
-                         source_url=vcsrepo['source_url'])
+                         source_url=url)
         # now perform the setup process (build and install)
-        test.exec_recipe(pe['setup_recipe'],
+        test.exec_recipe(setup,
+                         test=test,
                          prefix=test.tmpdir,
-                         writer=test.writer,
                          wdir=src)
 
-    checker, status = test.run_checker('pyunit')
+    repoeid = test.penvironment['repository']['eid']
+    checker, status = test.run_checker('pyunit',
+                                   path=join(test.tmpdir, 'src', str(repoeid)))
--- a/recipes/apycot.setup.distutils.py	Thu Nov 13 14:50:54 2014 +0100
+++ b/recipes/apycot.setup.distutils.py	Thu Nov 13 14:53:00 2014 +0100
@@ -1,23 +1,29 @@
 # normally executed with following builtin variables:
 # :prefix: where to install
-# :writer: log reporter
 # :wdir: working directory
+# :test: the apyclotlib.atest.Test instance
 
-from apycotlib import Command
+import os
+from os.path import join
+from apycotlib import Command, SUCCESS
 
 # ensure environment variables are OK
 test.update_env(wdir, 'PATH',
-                join(wdir, 'sbin'),
-                os.pathset)
-test.update_env(wdir, 'PATH',
-                join(wdir, 'bin'),
-                os.pathset)
+                os.pathsep.join((join(prefix, 'sbin'), join(wdir, 'sbin'),)),
+                os.pathsep)
 test.update_env(wdir, 'PYTHONPATH',
-                join(wdir, 'lib', 'python'),
-                os.pathset)
+                join(prefix, 'lib', 'python'),
+                os.pathsep)
 test.update_env(wdir, 'LD_LIBRARY_PATH',
-                join(wdir, 'lib'),
-                os.pathset)
+                join(prefix, 'lib'),
+                os.pathsep)
 
+test.writer.warning('Installing with prefix=%s' % prefix)
 cmdargs = ['python', 'setup.py', 'install', '--home', prefix]
-Command(writer, cmdargs, raises=True, cwd=wdir)
+st = Command(test.writer, cmdargs, raises=True, cwd=wdir).run()
+if st == SUCCESS:
+    test.writer.info('Installation successfull')
+else:
+    test.writer.error('Installation failed (%s)'% st)
+
+