Ejemplo n.º 1
0
    def test(self):
        """Perform smoke tests on the installed package"""
        # Start with what we already have post-install
        tty.msg('test: Performing simple import test')
        self.import_module_test()

        data_dir = self.test_suite.current_test_data_dir

        # Now run defined tests based on expected executables
        dtd_path = data_dir.join('info.dtd')
        test_filename = 'test.xml'
        exec_checks = {
            'xml2-config': [
                ('--version', [str(self.spec.version)], 0)],
            'xmllint': [
                (['--auto', '-o', test_filename], [], 0),
                (['--postvalid', test_filename],
                 ['validity error', 'no DTD found', 'does not validate'], 3),
                (['--dtdvalid', dtd_path, test_filename],
                 ['validity error', 'does not follow the DTD'], 3),
                (['--dtdvalid', dtd_path, data_dir.join('info.xml')], [], 0)],
            'xmlcatalog': [
                ('--create', ['<catalog xmlns', 'catalog"/>'], 0)],
        }
        for exe in exec_checks:
            for options, expected, status in exec_checks[exe]:
                self.run_test(exe, options, expected, status)

        # Perform some cleanup
        fs.force_remove(test_filename)
Ejemplo n.º 2
0
 def delete_configure_to_force_update(self):
     if self.force_autoreconf:
         force_remove(self.configure_abs_path)
Ejemplo n.º 3
0
    def _save_distutil_vars(self):
        """
        Run before changing automatically generated contents of the
        _sysconfigdata.py, which is used by distutils to figure out what
        executables to use while compiling and linking extensions. If we build
        extensions with spack those executables should be spack's wrappers.
        Spack partially covers this by setting environment variables that
        are also accounted for by distutils. Currently there is one more known
        variable that must be set, which is LDSHARED, so the method saves its
        autogenerated value to pass it to the dependent package's setup script.
        """

        self._distutil_vars = {}

        input_filename = self.get_sysconfigdata_name()
        input_dict = None
        try:
            with open(input_filename) as input_file:
                match = re.search(r'build_time_vars\s*=\s*(?P<dict>{.*})',
                                  input_file.read(),
                                  flags=re.DOTALL)

                if match:
                    input_dict = ast.literal_eval(match.group('dict'))
        except (IOError, SyntaxError):
            pass

        if not input_dict:
            tty.warn("Failed to find 'build_time_vars' dictionary in file "
                     "'%s'. This might cause the extensions that are "
                     "installed with distutils to call compilers directly "
                     "avoiding Spack's wrappers." % input_filename)
            return

        for var_name in Python._DISTUTIL_VARS_TO_SAVE:
            if var_name in input_dict:
                self._distutil_vars[var_name] = input_dict[var_name]
            else:
                tty.warn("Failed to find key '%s' in 'build_time_vars' "
                         "dictionary in file '%s'. This might cause the "
                         "extensions that are installed with distutils to "
                         "call compilers directly avoiding Spack's wrappers."
                         % (var_name, input_filename))

        if len(self._distutil_vars) > 0:
            output_filename = None
            try:
                output_filename = join_path(
                    spack.store.layout.metadata_path(self.spec),
                    Python._DISTUTIL_CACHE_FILENAME)
                with open(output_filename, 'w') as output_file:
                    sjson.dump(self._distutil_vars, output_file)
            except Exception:
                tty.warn("Failed to save metadata for distutils. This might "
                         "cause the extensions that are installed with "
                         "distutils to call compilers directly avoiding "
                         "Spack's wrappers.")
                # We make the cache empty if we failed to save it to file
                # to provide the same behaviour as in the case when the cache
                # is initialized by the method load_distutils_data().
                self._distutil_vars = {}
                if output_filename:
                    force_remove(output_filename)
Ejemplo n.º 4
0
    def _save_distutil_vars(self, prefix):
        """
        Run before changing automatically generated contents of the
        _sysconfigdata.py, which is used by distutils to figure out what
        executables to use while compiling and linking extensions. If we build
        extensions with spack those executables should be spack's wrappers.
        Spack partially covers this by setting environment variables that
        are also accounted for by distutils. Currently there is one more known
        variable that must be set, which is LDSHARED, so the method saves its
        autogenerated value to pass it to the dependant package's setup script.
        """

        self._distutil_vars = {}

        input_filename = None
        for filename in [join_path(lib_dir,
                                   'python{0}'.format(self.version.up_to(2)),
                                   '_sysconfigdata.py')
                         for lib_dir in [prefix.lib, prefix.lib64]]:
            if os.path.isfile(filename):
                input_filename = filename
                break

        if not input_filename:
            return

        input_dict = None
        try:
            with open(input_filename) as input_file:
                match = re.search(r'build_time_vars\s*=\s*(?P<dict>{.*})',
                                  input_file.read(),
                                  flags=re.DOTALL)

                if match:
                    input_dict = ast.literal_eval(match.group('dict'))
        except (IOError, SyntaxError):
            pass

        if not input_dict:
            tty.warn('Failed to find \'build_time_vars\' dictionary in file '
                     '\'%s\'. This might cause the extensions that are '
                     'installed with distutils to call compilers directly '
                     'avoiding Spack\'s wrappers.' % input_filename)
            return

        for var_name in Python._DISTUTIL_VARS_TO_SAVE:
            if var_name in input_dict:
                self._distutil_vars[var_name] = input_dict[var_name]
            else:
                tty.warn('Failed to find key \'%s\' in \'build_time_vars\' '
                         'dictionary in file \'%s\'. This might cause the '
                         'extensions that are installed with distutils to '
                         'call compilers directly avoiding Spack\'s wrappers.'
                         % (var_name, input_filename))

        if len(self._distutil_vars) > 0:
            output_filename = None
            try:
                output_filename = join_path(
                    spack.store.layout.metadata_path(self.spec),
                    Python._DISTUTIL_CACHE_FILENAME)
                with open(output_filename, 'w') as output_file:
                    sjson.dump(self._distutil_vars, output_file)
            except:
                tty.warn('Failed to save metadata for distutils. This might '
                         'cause the extensions that are installed with '
                         'distutils to call compilers directly avoiding '
                         'Spack\'s wrappers.')
                # We make the cache empty if we failed to save it to file
                # to provide the same behaviour as in the case when the cache
                # is initialized by the method load_distutils_data().
                self._distutil_vars = {}
                if output_filename:
                    force_remove(output_filename)
Ejemplo n.º 5
0
 def delete_configure_to_force_update(self):
     if self.force_autoreconf:
         force_remove(self.configure_abs_path)
Ejemplo n.º 6
0
    def _save_distutil_vars(self, prefix):
        """
        Run before changing automatically generated contents of the
        _sysconfigdata.py, which is used by distutils to figure out what
        executables to use while compiling and linking extensions. If we build
        extensions with spack those executables should be spack's wrappers.
        Spack partially covers this by setting environment variables that
        are also accounted for by distutils. Currently there is one more known
        variable that must be set, which is LDSHARED, so the method saves its
        autogenerated value to pass it to the dependant package's setup script.
        """

        self._distutil_vars = {}

        input_filename = None
        for filename in [
                join_path(lib_dir, 'python{0}'.format(self.version.up_to(2)),
                          '_sysconfigdata.py')
                for lib_dir in [prefix.lib, prefix.lib64]
        ]:
            if os.path.isfile(filename):
                input_filename = filename
                break

        if not input_filename:
            return

        input_dict = None
        try:
            with open(input_filename) as input_file:
                match = re.search(r'build_time_vars\s*=\s*(?P<dict>{.*})',
                                  input_file.read(),
                                  flags=re.DOTALL)

                if match:
                    input_dict = ast.literal_eval(match.group('dict'))
        except (IOError, SyntaxError):
            pass

        if not input_dict:
            tty.warn('Failed to find \'build_time_vars\' dictionary in file '
                     '\'%s\'. This might cause the extensions that are '
                     'installed with distutils to call compilers directly '
                     'avoiding Spack\'s wrappers.' % input_filename)
            return

        for var_name in Python._DISTUTIL_VARS_TO_SAVE:
            if var_name in input_dict:
                self._distutil_vars[var_name] = input_dict[var_name]
            else:
                tty.warn(
                    'Failed to find key \'%s\' in \'build_time_vars\' '
                    'dictionary in file \'%s\'. This might cause the '
                    'extensions that are installed with distutils to '
                    'call compilers directly avoiding Spack\'s wrappers.' %
                    (var_name, input_filename))

        if len(self._distutil_vars) > 0:
            output_filename = None
            try:
                output_filename = join_path(
                    spack.store.layout.metadata_path(self.spec),
                    Python._DISTUTIL_CACHE_FILENAME)
                with open(output_filename, 'w') as output_file:
                    sjson.dump(self._distutil_vars, output_file)
            except:
                tty.warn('Failed to save metadata for distutils. This might '
                         'cause the extensions that are installed with '
                         'distutils to call compilers directly avoiding '
                         'Spack\'s wrappers.')
                # We make the cache empty if we failed to save it to file
                # to provide the same behaviour as in the case when the cache
                # is initialized by the method load_distutils_data().
                self._distutil_vars = {}
                if output_filename:
                    force_remove(output_filename)