kill preprocessor, since there is nothing left there draft
authorDavid Douard <david.douard@logilab.fr>
Sun, 26 Oct 2014 00:26:31 +0200
changeset 1759 b9915807bddb
parent 1758 b1b931406fb2
child 1760 db82548222eb
kill preprocessor, since there is nothing left there Preprocessing is now handled via dedicated recipes.
__pkginfo__.py
_apycotlib/__init__.py
_apycotlib/atest.py
_narval/checkers/apycot/__init__.py
_narval/checkers/apycot/jslint.py
_narval/checkers/apycot/pypi.py
_narval/checkers/apycot/python.py
_narval/preprocessors/__init__.py
_narval/preprocessors/apycot/__init__.py
_narval/preprocessors/apycot/distutils.py
schema.py
--- a/__pkginfo__.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/__pkginfo__.py	Sun Oct 26 00:26:31 2014 +0200
@@ -64,10 +64,6 @@
                        listdir(join(NARVALDIR, 'checkers'))])
     data_files.append([join('share', 'narval', 'checkers', distname),
                        listdir(join(NARVALDIR, 'checkers', distname))])
-    data_files.append([join('share', 'narval', 'preprocessors'),
-                       listdir(join(NARVALDIR, 'preprocessors'))])
-    data_files.append([join('share', 'narval', 'preprocessors', distname),
-                       listdir(join(NARVALDIR, 'preprocessors', distname))])
 if isdir(join(NARVALDIR, 'data')): # test REQUIRED (to be importable from everywhere)
     data_files.append([join('share', 'narval', 'data'),
                        listdir(join(NARVALDIR, 'data'))])
--- a/_apycotlib/__init__.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/_apycotlib/__init__.py	Sun Oct 26 00:26:31 2014 +0200
@@ -29,6 +29,7 @@
 import ctypes
 
 from logilab.common.textutils import splitstrip
+from logilab.common.decorators import cached
 
 # regitry of available repositories, preprocessors and checkers
 
@@ -132,7 +133,7 @@
 _MARKER = ()
 
 class ApycotObject(object):
-    """base class for apycot checkers / preprocessors"""
+    """base class for apycot checkers"""
     options_def = {}
     status = None
 
@@ -237,6 +238,9 @@
 
 
 class Command(ApycotObject):
+    """An ApycotObject dedicated to run commands in a subprocess and
+    send its stdout/stderr to a Writer
+    """
     non_zero_status_code = ERROR
     status = SUCCESS
 
@@ -346,3 +350,52 @@
             return stdout, None, u'\n'.join(self.parser.unparsed)
         return stdout, stderr, None
 
+
+# copy from killed preprocessor/__init__.py
+
+def pyversion_available(python):
+    return not os.system('%s -V 2>/dev/null' % python)
+
+@cached
+def pyversions(test):
+    config = test.apycot_config()
+    tested_pyversions = config.get('tested_python_versions')
+    if tested_pyversions:
+        pyversions = set(splitstrip(tested_pyversions))
+    elif config.get('use_pkginfo_python_versions'):
+        from logilab.devtools.lib.pkginfo import PackageInfo
+        try:
+            pkginfodir = dirname(test.environ['pkginfo'])
+        except KeyError:
+            pkginfodir = test.project_path()
+        try:
+            pkginfo = PackageInfo(directory=pkginfodir)
+            pyversions = set(pkginfo.pyversions)
+        except (NameError, ImportError):
+            pyversions = set()
+        ignored_pyversions = config.get('ignored_python_versions')
+        if ignored_pyversions:
+            ignored_pyversions = set(ignored_pyversions)
+            ignored_pyversions = pyversions.intersection(
+                ignored_pyversions)
+            if ignored_pyversions:
+                for py_ver in ignored_pyversions:
+                    test.writer.debug('python version %s ignored', py_ver)
+                pyversions.difference_update(ignored_pyversions)
+    else:
+        pyversions = None
+    if pyversions:
+        pyversions_ = []
+        for pyver in pyversions:
+            python = 'python%s' % pyver
+            if not pyversion_available(python):
+                test.writer.error(
+                    'config asked for %s, but it\'s not available', pyver)
+            else:
+                pyversions_.append(python)
+        pyversions = pyversions_
+    else:
+        pyversions = ['python%s.%s' % sys.version_info[:2]]
+    return pyversions
+
+INSTALL_PREFIX = {}
--- a/_apycotlib/atest.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/_apycotlib/atest.py	Sun Oct 26 00:26:31 2014 +0200
@@ -5,7 +5,7 @@
 A test defines :
 * a unit of sources to test (a project)
 * a list of checks to apply to this unit
-* how to build the test environment (preprocessing, dependencies...)
+* how to build the test environment (dependencies...)
 """
 from __future__ import with_statement
 
@@ -78,8 +78,6 @@
         # or if an archive containing it should be uploaded
         self.keep_test_dir = options.get('keep_test_dir', False)
         self.archive = options.get('archive', False)
-        # set of preprocessors which have failed
-        self._failed_pp = set()
         self.executed_checkers = {}
         self.global_status = SUCCESS
         self.options = options
@@ -213,7 +211,7 @@
         if envvar == 'PYTHONPATH':
             update_path(orig_value, value)
 
-    # api to call a particular preprocessor / checker #########################
+    # api to call a particular checker #########################
 
     def run_checker(self, id, displayname=None, nonexecuted=False, **kwargs):
         """run all checks in the test environment"""
--- a/_narval/checkers/apycot/__init__.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/_narval/checkers/apycot/__init__.py	Sun Oct 26 00:26:31 2014 +0200
@@ -22,7 +22,6 @@
 class BaseChecker(ApycotObject):
     id = None
     __type__ = 'checker'
-    need_preprocessor = None
 
     _best_status = None
 
--- a/_narval/checkers/apycot/jslint.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/_narval/checkers/apycot/jslint.py	Sun Oct 26 00:26:31 2014 +0200
@@ -164,7 +164,6 @@
         """Js Lint checker for each *.js file"""
 
         id = 'jslint'
-        need_preprocessor = 'build_js'
         checked_extensions = ('.js', )
 
         def check_file(self, path):
--- a/_narval/checkers/apycot/pypi.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/_narval/checkers/apycot/pypi.py	Sun Oct 26 00:26:31 2014 +0200
@@ -6,7 +6,6 @@
 import apycotlib
 
 from checkers.apycot import BaseChecker
-from preprocessors.apycot.distutils import pyversions
 
 class PypiUploader(BaseChecker):
     id = 'pypi.upload'
@@ -27,7 +26,7 @@
         path = test.project_path()
         if not exists(join(path, 'setup.py')):
             raise apycotlib.SetupException('No file %s' % abspath(join(path, 'setup.py')))
-        python = pyversions(test)[0]
+        python = apycotlib.pyversions(test)[0]
         cmdargs = [python, 'setup.py', 'register', 'sdist', 'upload']
         if not self.options.get('verbose'):
             cmdargs.append('--quiet')
--- a/_narval/checkers/apycot/python.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/_narval/checkers/apycot/python.py	Sun Oct 26 00:26:31 2014 +0200
@@ -32,11 +32,10 @@
 except ImportError:
     coverage = None
 
-from apycotlib import register
+from apycotlib import register, INSTALL_PREFIX, pyversions
 from apycotlib import SUCCESS, FAILURE, PARTIAL, NODATA, ERROR
 from apycotlib import SimpleOutputParser, ParsedCommand
 
-from preprocessors.apycot.distutils import INSTALL_PREFIX, pyversions
 from checkers.apycot import BaseChecker, AbstractFilteredFileChecker
 
 def pyinstall_path(test):
@@ -199,7 +198,6 @@
     (from logilab.common)
     """
     id = 'pytest'
-    need_preprocessor = 'install'
     parsercls = PyTestParser
     parsed_content = 'stdout'
     options_def = PYVERSIONS_OPTIONS.copy()
@@ -433,7 +431,6 @@
 
     spawn py.test and parse output (expect a standard TextTestRunner)
     """
-    need_preprocessor = 'install'
     id = 'py.test'
     parsercls = PyDotTestParser
     parsed_content = 'stdout'
@@ -449,7 +446,6 @@
 class PyLintChecker(BaseChecker):
     """check that the python package as a decent pylint evaluation
     """
-    need_preprocessor = 'install'
     id = 'pylint'
     options_def = {
         'pylintrc': {
@@ -681,7 +677,6 @@
     spawn unittest and parse output (expect a standard TextTestRunner)
     """
     id = 'pychecker'
-    need_preprocessor = 'install'
 
     def do_check(self, test):
         """run the checker against <path> (usually a directory)"""
--- a/_narval/preprocessors/__init__.py	Thu Nov 13 15:17:12 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-# make it work in 'dev' mode: look for preprocessors in known cubes
-
-try:
-    import narvalbot
-except:
-    from cubes.narval import narvalbot
-    import sys
-    sys.modules['narvalbot'] = narvalbot
-
-if narvalbot.MODE == 'dev':
-    # we are running from sources, cubicweb *should* be available,
-    # let's use it as starting point to look for cubes in which there
-    # is a _narval directory
-    import os, os.path as osp
-    from cubicweb import CW_SOFTWARE_ROOT
-    cubesdir = osp.join(CW_SOFTWARE_ROOT, '..', 'cubes')
-    for cube in os.listdir(cubesdir):
-        pluginsdir = osp.abspath(osp.join(cubesdir, cube, '_narval', 'preprocessors'))
-        if osp.isdir(pluginsdir):
-            __path__.append(pluginsdir)
--- a/_narval/preprocessors/apycot/__init__.py	Thu Nov 13 15:17:12 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-"""preprocessors packages"""
-
-__docformat__ = "restructuredtext en"
-
-try:
-    import apycotlib
-except ImportError: # allow to run from sources
-    from cubes.apycot import _apycotlib as apycotlib
-    import sys
-    sys.modules['apycotlib'] = apycotlib
-
-from apycotlib import ApycotObject
-
-class BasePreProcessor(ApycotObject):
-    """an abstract class providing some common utilities for preprocessors
-    """
-    __type__ = 'preprocessor'
-
-    def run(self, test, path):
-        """Run preprocessor against source in <path> in <test> context"""
-        raise NotImplementedError()
--- a/_narval/preprocessors/apycot/distutils.py	Thu Nov 13 15:17:12 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-"""installation preprocessor using distutils setup.py
-
-:organization: Logilab
-:copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: General Public License version 2 - http://www.gnu.org/licenses
-"""
-from __future__ import with_statement
-
-__docformat__ = "restructuredtext en"
-
-import os
-import shutil
-import sys
-from os.path import join, exists, abspath, dirname
-from glob import glob
-
-from logilab.common.textutils import splitstrip
-from logilab.common.decorators import cached
-
-from apycotlib import register, SetupException
-from apycotlib import Command
-
-from preprocessors.apycot import BasePreProcessor
-
-def pyversion_available(python):
-    return not os.system('%s -V 2>/dev/null' % python)
-
-@cached
-def pyversions(test):
-    config = test.apycot_config()
-    tested_pyversions = config.get('tested_python_versions')
-    if tested_pyversions:
-        pyversions = set(splitstrip(tested_pyversions))
-    elif config.get('use_pkginfo_python_versions'):
-        from logilab.devtools.lib.pkginfo import PackageInfo
-        try:
-            pkginfodir = dirname(test.environ['pkginfo'])
-        except KeyError:
-            pkginfodir = test.project_path()
-        try:
-            pkginfo = PackageInfo(directory=pkginfodir)
-            pyversions = set(pkginfo.pyversions)
-        except (NameError, ImportError):
-            pyversions = set()
-        ignored_pyversions = config.get('ignored_python_versions')
-        if ignored_pyversions:
-            ignored_pyversions = set(ignored_pyversions)
-            ignored_pyversions = pyversions.intersection(
-                ignored_pyversions)
-            if ignored_pyversions:
-                for py_ver in ignored_pyversions:
-                    test.writer.debug('python version %s ignored', py_ver)
-                pyversions.difference_update(ignored_pyversions)
-    else:
-        pyversions = None
-    if pyversions:
-        pyversions_ = []
-        for pyver in pyversions:
-            python = 'python%s' % pyver
-            if not pyversion_available(python):
-                test.writer.error(
-                    'config asked for %s, but it\'s not available', pyver)
-            else:
-                pyversions_.append(python)
-        pyversions = pyversions_
-    else:
-        pyversions = ['python%s.%s' % sys.version_info[:2]]
-    return pyversions
-
-INSTALL_PREFIX = {}
--- a/schema.py	Thu Nov 13 15:17:12 2014 +0100
+++ b/schema.py	Sun Oct 26 00:26:31 2014 +0200
@@ -87,7 +87,7 @@
         description=_('name for this environment')
         )
     check_config = String(
-        description=_('preprocessor/checker options (one per line)'),
+        description=_('checker options (one per line)'),
         fulltextindexed=True
         )
     check_environment = String(
@@ -141,7 +141,7 @@
                       "automatically triggered")
         )
     check_config = String(
-        description=_('preprocessor/checker options (one per line)'),
+        description=_('checker options (one per line)'),
         fulltextindexed=True
         )
     check_environment = String(