[narval] kill DistutilsProcessor draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:49:22 +0100
changeset 1749 7cdbb66fb2c4
parent 1748 e5bee2960261
child 1750 6c752f8e5fc5
[narval] kill DistutilsProcessor it's now handled by setup recipes
_narval/preprocessors/apycot/distutils.py
--- a/_narval/preprocessors/apycot/distutils.py	Thu Nov 13 14:48:20 2014 +0100
+++ b/_narval/preprocessors/apycot/distutils.py	Thu Nov 13 14:49:22 2014 +0100
@@ -69,63 +69,3 @@
     return pyversions
 
 INSTALL_PREFIX = {}
-
-class DistutilsProcessor(BasePreProcessor):
-    """python setup.py pre-processor
-
-       Use a distutils'setup.py script to install a Python package. The
-       setup.py should provide an "install" function which run the setup and
-       return a "dist" object (i.e. the object return by the distutils.setup
-       function). This preprocessor may modify the PATH and PYTHONPATH
-       environment variables.
-    """
-    id = 'python_setup'
-    _python_path_set = None
-
-    options_def = {
-        'verbose': {
-            'type': 'int', 'default': False,
-            'help': 'set verbose mode'
-            },
-        }
-
-    # PreProcessor interface ##################################################
-
-    def run(self, test, path=None):
-        """run the distutils setup.py install method on a path if
-        the path is not yet installed
-        """
-        if path is None:
-            path = test.project_path()
-        if not DistutilsProcessor._python_path_set:
-            py_lib_dir = join(test.tmpdir, 'local', 'lib', 'python')
-            # setuptools need this directory to exists
-            if not exists(py_lib_dir):
-                os.makedirs(py_lib_dir)
-            test.update_env(path, 'PYTHONPATH', py_lib_dir, os.pathsep)
-            test.update_env(path, 'PATH', join(test.tmpdir, 'local', 'bin'),
-                            os.pathsep)
-            DistutilsProcessor._python_path_set = py_lib_dir
-            sitecustomize = open(join(py_lib_dir, 'sitecustomize.py'), 'w')
-            sitecustomize.write('''import sys, os.path as osp
-sys.path.insert(0, osp.join(%r, "python%%s.%%s" %% sys.version_info[:2], "site-packages"))
-''' % join(test.tmpdir, 'local', 'lib'))
-            sitecustomize.close()
-        # cache to avoid multiple installation of the same module
-        if path in INSTALL_PREFIX:
-            return
-        if not exists(join(path, 'setup.py')):
-            raise SetupException('No file %s' % abspath(join(path, 'setup.py')))
-        python = pyversions(test)[0]
-        INSTALL_PREFIX[path] = join(test.tmpdir, 'local', 'lib', 'python')
-        cmdargs = [python, 'setup.py', 'install', '--home',
-                   join(test.tmpdir, 'local')]
-        if not self.options.get('verbose'):
-            cmdargs.append('--quiet')
-        cmd = Command(self.writer, cmdargs, raises=True, cwd=path)
-        cmd.run()
-        if exists(join(path, 'build')):
-            shutil.rmtree(join(path, 'build')) # remove the build directory
-
-
-register('preprocessor', DistutilsProcessor)