Exemplo n.º 1
0
 def is_installed(self, environ, version=None, strict=False):
     options.set_debug(self.debug)
     try:
         pyjamas_root = os.environ['PYJAMAS_ROOT']
         pyjs_bin = os.path.join(pyjamas_root, 'bin')
         #pyjs_lib = os.path.join(pyjamas_root, 'build', 'lib')
         self.environment['PYJSBUILD'] = find_program('pyjsbuild',
                                                      [pyjs_bin])
         self.found = True
     except (KeyError, ConfigError, ImportError):
         if self.debug:
             print(sys.exc_info()[1])
         try:
             local = glob.glob(os.path.join(options.target_build_dir,
                                            'pyjamas-*'))
             local_bins = []
             if len(local):
                 local_bins.append(os.path.join(local[0], 'bin'))
             self.environment['PYJSBUILD'] = find_program('pyjsbuild',
                                                          local_bins)
             self.found = True
         except (ImportError, ConfigError):
             if self.debug:
                 print(sys.exc_info()[1])
     return self.found
Exemplo n.º 2
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        try:
            locations = glob.glob(os.path.join('C:' + os.sep + 'OpenSCG',
                                               'openjdk*'))
            java_runtime = find_program('java', locations)
            java_compiler = find_program('javac', locations)
            jar_archiver = find_program('jar', locations)

            if not self.__check_java_version(java_runtime, [version]):
                return self.found
            classpaths = []
            try:
                _sep_ = ':'
                if 'windows' in platform.system().lower():
                    _sep_ = ';'
                pathlist = os.environ['CLASSPATH'].split(_sep_)
                for path in pathlist:
                    classpaths.append(path)
            except KeyError:
                pass
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment['JAVA'] = java_runtime
        self.environment['JAVA_HOME'] = os.path.abspath(os.path.join(
                os.path.dirname(java_runtime), '..'))
        self.environment['JAVAC'] = java_compiler
        self.environment['JAR'] = jar_archiver
        self.environment['CLASSPATH'] = classpaths
        return self.found
Exemplo n.º 3
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        limit = False
        locations = []
        if self.exe.upper() in environ and environ[self.exe.upper()]:
            locations.append(os.path.dirname(environ[self.exe.upper()]))
            limit = True

        if not limit:
            try:
                locations.append(os.environ[self.exe.upper() + '_ROOT'])
            except KeyError:
                pass
            try:
                locations.append(environ['MINGW_DIR'])
                locations.append(environ['MSYS_DIR'])
            except KeyError:
                pass

        try:
            program = find_program(self.exe, locations, limit=limit)
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment[self.exe.upper()] = program
        return self.found
Exemplo n.º 4
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        lib_name = 'cdf'
        if 'windows' in platform.system().lower():
            lib_name += 'NativeLibrary'
        if version is None:
            version = '35_0'

        limit = False
        base_dirs = []
        if 'CDF_BASE' in environ and environ['CDF_BASE']:
            base_dirs.append(environ['CDF_BASE'])
            limit = True
        if 'CDF_LIB' in environ and environ['CDF_LIB']:
            base_dirs.append(environ['CDF_LIB'])
            limit = True
        if 'CDF_INC' in environ and environ['CDF_INC']:
            base_dirs.append(environ['CDF_INC'])
            limit = True
        if 'CDF_BIN' in environ and environ['CDF_BIN']:
            base_dirs.append(environ['CDF_BIN'])
            limit = True
        if 'CDF_LIB_DIR' in environ and environ['CDF_LIB_DIR']:
            base_dirs.append(environ['CDF_LIB_DIR'])
            limit = True
            if 'CDF_INCLUDE_DIR' in environ and environ['CDF_INCLUDE_DIR']:
                base_dirs.append(environ['CDF_INCLUDE_DIR'])

        if not limit:
            try:
                base_dirs += os.environ['LD_LIBRARY_PATH'].split(os.pathsep)
                base_dirs += os.environ['CPATH'].split(os.pathsep)
            except KeyError:
                pass
            if 'windows' in platform.system().lower():
                base_dirs.append(os.path.join('C:', os.sep, 'CDF Distribution',
                                              'cdf' + version + '-dist'))
            try:
                base_dirs.append(environ['MINGW_DIR'])
                base_dirs.append(environ['MSYS_DIR'])
            except KeyError:
                pass
        try:
            incl_dir = find_header(self.hdr, base_dirs, limit=limit)
            lib_dir, lib = find_library(self.lib, base_dirs, limit=limit)
            exe = find_program('cdfcompare',  base_dirs)
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment['CDF_INCLUDE_DIR'] = incl_dir
        self.environment['CDF_LIB_DIR'] = lib_dir
        self.environment['CDF_LIB_FILES'] = [lib]
        self.environment['CDF_LIBRARIES'] = [lib_name]
        os.environ['CDF_LIB'] = os.path.abspath(lib_dir)
        os.environ['CDF_INC'] = os.path.abspath(incl_dir)
        os.environ['CDF_BIN'] = os.path.abspath(os.path.dirname(exe))
        return self.found
Exemplo n.º 5
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        try:
            wx_config = os.environ["WX_CONFIG"]
        except KeyError:
            locations = []
            try:
                locations.append(environ["MINGW_DIR"])
                locations.append(environ["MSYS_DIR"])
            except KeyError:
                pass
            try:
                wx_config = find_program("wx-config", locations)
            except ConfigError:
                if self.debug:
                    print(sys.exc_info()[1])
                return self.found
        try:
            cppflags_cmd = [wx_config, "--cppflags"]
            process = subprocess.Popen(cppflags_cmd, stdout=subprocess.PIPE)
            cflags = process.communicate()[0].split()

            ldflags_cmd = [wx_config, "--libs", "--gl-libs", "--static=no"]
            process = subprocess.Popen(ldflags_cmd, stdout=subprocess.PIPE)
            ldflags = process.communicate()[0].split()
            self.found = True
        except OSError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment["WX_CPP_FLAGS"] = cflags
        self.environment["WX_LD_FLAGS"] = ldflags
        return self.found
Exemplo n.º 6
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        if 'MSVC' in environ:
            raise Exception('MinGW *and* MS Visual C both specified ' +
                            'as the chosen compiler.')
        limit = False
        if 'MINGW_DIR' in environ and environ['MINGW_DIR']:
            mingw_root = environ['MINGW_DIR']
            limit = True

        if not limit:
            try:
                mingw_root = os.environ['MINGW_ROOT']
            except KeyError:
                locations = [os.path.join('C:', os.sep, 'MinGW')]
                for d in programfiles_directories():
                    locations.append(os.path.join(d, 'MinGW'))
                try:
                    gcc = find_program('mingw32-gcc', locations)
                    mingw_root = os.path.abspath(os.path.join(
                            os.path.dirname(gcc), '..'))
                except ConfigError:
                    if self.debug:
                        print(sys.exc_info[1])
                    return self.found

        msys_root = os.path.join(mingw_root, 'msys', '1.0')
        try:
            
            gcc = find_program('mingw32-gcc', [mingw_root], limit=limit)
            gxx = find_program('mingw32-g++', [mingw_root], limit=limit)
            gfort = find_program('mingw32-gfortran', [mingw_root], limit=limit)
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment['MINGW_DIR']     = mingw_root
        self.environment['MSYS_DIR']      = msys_root
        self.environment['MINGW_CC']      = gcc
        self.environment['MINGW_CXX']     = gxx
        self.environment['MINGW_FORTRAN'] = gfort
        return self.found
Exemplo n.º 7
0
    def install(self, environ, version, strict=False, locally=True):
        ## always locally, o.w. won't work
        locally = True
        if not self.found:
            src_dir = self.download(environ, version, strict)
            if options.VERBOSE:
                sys.stdout.write('PREREQUISITE pyjamas ')

            working_dir = os.path.join(options.target_build_dir, src_dir)
            if not os.path.exists(working_dir):
                os.rename(glob.glob(os.path.join(options.target_build_dir,
                                                 '*pyjs*'))[0], working_dir)

            ## Unique two-step installation
            log_file = os.path.join(options.target_build_dir, 'pyjamas.log')
            log = open(log_file, 'w')
            here = os.path.abspath(os.getcwd())
            os.chdir(working_dir)

            cmd_line = [sys.executable, 'bootstrap.py',]
            try:
                p = subprocess.Popen(cmd_line, stdout=log, stderr=log)
                status = process_progress(p)
            except KeyboardInterrupt:
                p.terminate()
                log.close()
                raise
            self.check_install(status, log, log_file)

            cmd_line = [sys.executable, 'run_bootstrap_first_then_setup.py',
                        'build']
            if not locally:
                sudo_prefix = []
                if not as_admin():
                    sudo_prefix = ['sudo']
                cmd_line = sudo_prefix + cmd_line + ['install']
            try:
                p = subprocess.Popen(cmd_line, stdout=log, stderr=log)
                status = process_progress(p)
                log.close()
            except KeyboardInterrupt:
                p.terminate()
                log.close()
                raise
            self.check_install(status, log, log_file)

            if options.VERBOSE:
                sys.stdout.write(' done\n')
            os.chdir(here)
            search_path = []
            if locally:
                search_path.append(working_dir)
            self.environment['PYJSBUILD'] = find_program('pyjsbuild',
                                                         search_path)
Exemplo n.º 8
0
 def is_installed(self, environ, version=None, strict=False):
     options.set_debug(self.debug)
     if version is None:
         version = '1.9.4'
     try:
         local_dir = os.path.join(options.target_build_dir, 'neo4j-*', 'bin')
         self.environment['NEO4J'] = find_program('neo4j', [local_dir])
         self.found = True
     except ConfigError:
         if self.debug:
             print(sys.exc_info()[1])
     return self.found
Exemplo n.º 9
0
 def is_installed(self, environ, version=None, strict=False):
     options.set_debug(self.debug)
     prev = prog_config.is_installed(self, environ, version, strict)
     if prev:
         locations = [os.path.dirname(self.environment[self.exe.upper()])]
         try:
             program = find_program('npm', locations, limit=True)
             self.environment['NPM'] = program
         except ConfigError:
             if self.debug:
                 print(sys.exc_info()[1])
             return False
     return prev
Exemplo n.º 10
0
    def is_installed(self, environ, version, strict=False):
        options.set_debug(self.debug)
        if 'MINGW_CC' in environ:
            raise Exception('MS Visual C *and* MinGW both specified ' +
                            'as the chosen compiler.')

        version, _, _ = get_msvc_version()
        dot_ver = '.'.join(version)

        vcvars = None
        nmake = None
        msvc = None

        msvc_dirs = []
        limit = False
        if 'MSVC' in environ and environ['MSVC']:
            msvc_dirs.append(os.path.dirname(environ['MSVC']))
            limit = True

        if not limit:
            for d in programfiles_directories():
                msvc_dirs.append(os.path.join(d,
                                              'Microsoft Visual Studio ' + dot_ver,
                                              'VC'))
        try:
            vcvars = find_program('vcvarsall', msvc_dirs, limit=limit)
            nmake = find_program('nmake', msvc_dirs, limit=limit)
            msvc = find_program('cl', msvc_dirs, limit=limit)
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment['MSVC_VARS'] = vcvars
        self.environment['NMAKE'] = nmake
        self.environment['MSVC'] = msvc
        return self.found
Exemplo n.º 11
0
 def finalize_options(self):
     build_ext.finalize_options(self)
     self.web_ext_modules = self.distribution.web_ext_modules
     if self.pyjspath is None:
         try:
             import pyjs  # pylint: disable=F0401
             self.pyjspath = os.path.dirname(pyjs.__file__)
         except ImportError:
             pass
     else:
         sys.path.insert(0, os.path.join(self.pyjspath, 'build', 'lib'))
     if self.pyjscompiler is None:
         try:
             self.pyjscompiler = find_program('pyjsbuild', [self.pyjspath])
         except ConfigError:
             pass  ## defer resolution
Exemplo n.º 12
0
 def is_installed(self, environ, version=None, strict=False):
     options.set_debug(self.debug)
     try:
         import wxglade.common
         ver = wxglade.common.version
         not_ok = (compare_versions(ver, version) == -1)
         if strict:
             not_ok = (compare_versions(ver, version) != 0)
         if not_ok:
             if self.debug:
                 print('Wrong version of wxGlade: ' +
                       str(ver) + ' vs ' + str(version))
             return self.found
         self.environment['WXGLADE'] = find_program('wxglade')
         self.found = True
     except (ImportError, ConfigError):
         if self.debug:
             print(sys.exc_info()[1])
     return self.found
Exemplo n.º 13
0
 def is_installed(self, environ, version=None, strict=False):
     self.found = lib_config.is_installed(self, environ, version, strict)
     if self.found:
         lib_dir = self.environment.get('LLVM_LIB_DIR', '')
         ## llvmpy *requires* RTTI flag, so system version will not work
         if lib_dir.endswith('llvm'):
             lib_dir = os.path.dirname(lib_dir)
         base_dir = os.path.dirname(lib_dir)
         if base_dir == '' or base_dir == '/usr':
             self.found = False
             return self.found
         ## LLVM_CONFIG_PATH is needed by llvmpy
         try:
             self.environment['LLVM_CONFIG_PATH'] = \
                 find_program('llvm-config',
                              [os.path.dirname(lib_dir)], limit=True)
         except ConfigError:
             self.found = False
     return self.found
Exemplo n.º 14
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        base_dirs = []
        if 'GIT' in environ and environ['GIT']:
            base_dirs.append(os.path.dirname(environ['GIT']))

        base_dirs.append(os.path.join('C:',  os.sep, 'msysgit', 'cmd'))
        for d in programfiles_directories():
            base_dirs.append(os.path.join(d, 'Git', 'cmd'))
        try:
            base_dirs.append(environ['MINGW_DIR'])
            base_dirs.append(environ['MSYS_DIR'])
        except KeyError:
            pass
        try:
            self.environment['GIT'] = find_program('git', base_dirs)
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
        return self.found
Exemplo n.º 15
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        limit = False
        locations = []
        if 'CTYPESGEN' in environ and environ['CTYPESGEN']:
            locations.append(os.path.dirname(environ['CTYPESGEN']))
            limit = True

        try:
            exe = find_program('ctypesgen.py', locations, limit=limit)
            import ctypesgencore
            lib = os.path.dirname(os.path.dirname(ctypesgencore.__file__))
            self.found = True
        except (ConfigError, ImportError):
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment['CTYPESGEN'] = exe
        self.environment['CTYPESGEN_PATH'] = lib
        return self.found
Exemplo n.º 16
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        limit = False
        base_dirs = []
        if 'GCCXML' in environ and environ['GCCXML']:
            base_dirs.append(os.path.dirname(environ['GCCXML']))
            limit = True

        if not limit:
            for d in programfiles_directories():
                base_dirs.append(os.path.join(d, 'GCC_XML'))
            try:
                base_dirs.append(environ['MINGW_DIR'])
                base_dirs.append(environ['MSYS_DIR'])
            except KeyError:
                pass
        try:
            self.environment['GCCXML'] = find_program('gccxml', base_dirs,
                                                      limit=limit)
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
        return self.found
Exemplo n.º 17
0
    def run(self):
        if not self.distribution.doc_modules:
            return

        ## Make sure that sources are complete in build_lib.
        self.run_command('build_src')
        ## Ditto extensions
        self.run_command('build_ext')

        build = self.get_finalized_command('build')
        buildpy = self.get_finalized_command('build_py')
        ## packages and files are in build.build_lib (see build_py.py)
        target = os.path.join(os.path.abspath(build.build_base), 'http')
        mkdir(target)
        build_verbose = self.distribution.verbose
        environ = self.distribution.environment

        for dext in self.distribution.doc_modules:
            if self.distribution.verbose:
                print('building documentation "' + dext.name + '" sources')

            doc_dir = os.path.abspath(dext.source_directory)
            extra_dirs = dext.extra_directories
            src_dir = os.path.abspath(dext.name)
            here = os.getcwd()

            reprocess = True
            ref = os.path.join(target, dext.name + '.html')
            root_dir = dext.name
            if os.path.exists(ref) and not self.force:
                reprocess = False
                for root, _, filenames in os.walk(src_dir):
                    for fn in fnmatch.filter(filenames, '*.rst'):
                        doc = os.path.join(root, fn)
                        if os.path.getmtime(ref) < os.path.getmtime(doc):
                            reprocess = True
                            break
                        src = os.path.join(root_dir, root[len(doc_dir)+1:],
                                            fn[:-3] + 'py')
                        if os.path.exists(src):
                            if os.path.getmtime(ref) < os.path.getmtime(src):
                                reprocess = True
                                break
            if reprocess:
                working_dir = os.path.abspath(build.build_lib)
                for package in buildpy.packages:
                    pkgdir = buildpy.get_package_dir(package)
                    pkgsrcdir = os.path.join(os.path.dirname(src_dir), pkgdir)
                    configure_files(environ, pkgsrcdir,
                                    '*.rst', os.path.join(working_dir, pkgdir))

                cfg_dir = os.path.join(working_dir, dext.source_directory)
                environ['BUILD_DIR'] = working_dir

                copy_tree(doc_dir, working_dir, True,
                          excludes=[dext.name, '.svn', 'CVS', '.git', '.hg*'])
                copy_tree(os.path.join(doc_dir, dext.name),
                          os.path.join(cfg_dir, dext.name), True,
                          excludes=['.svn', 'CVS', '.git', '.hg*'])
                for d in extra_dirs:
                    subdir = os.path.basename(os.path.normpath(d))
                    copy_tree(d, os.path.join(target, subdir), True,
                              excludes=['.svn', 'CVS', '.git', '.hg*'])

                if os.path.exists(os.path.join(doc_dir, dext.doxygen_cfg)):
                    ## Doxygen + breathe
                    print('Config ' + os.path.join(doc_dir, dext.doxygen_cfg))
                    configure_file(environ,
                                   os.path.join(doc_dir, dext.doxygen_cfg),
                                   os.path.join(working_dir, dext.doxygen_cfg),
                                   style=dext.style)
                    for s in dext.doxygen_srcs:
                        configure_file(environ,
                                       os.path.join(doc_dir, s),
                                       os.path.join(working_dir, s),
                                       style=dext.style)
                    try:
                        doxygen_exe = find_program('doxygen')
                    except Exception:  # pylint: disable=W0703
                        sys.stderr.write('ERROR: Doxygen not installed ' +
                                         '(required for documentation).\n')
                        return

                    reprocess = True
                    ref = os.path.join(working_dir, 'html', 'index.html')
                    if os.path.exists(ref) and not self.force:
                        reprocess = False
                        for d in environ['C_SOURCE_DIRS'].split(' '):
                            for orig in glob.glob(os.path.join(d, '*.h*')):
                                if os.path.getmtime(ref) < \
                                   os.path.getmtime(orig):
                                    reprocess = True
                                    break
                    if reprocess:
                        if self.distribution.verbose:
                            out = sys.stdout
                            err = sys.stderr
                        else:
                            out = err = open('doxygen.log', 'w')
                        os.chdir(working_dir)
                        cmd_line = [doxygen_exe, dext.doxygen_cfg]
                        status = subprocess.call(cmd_line,
                                                 stdout=out, stderr=err)
                        if status != 0:
                            raise Exception("Command '" + str(cmd_line) +
                                            "' returned non-zero exit status "
                                            + str(status))

                        if not self.distribution.verbose:
                            out.close()
                        copy_tree('html', os.path.join(target, 'html'), True,
                                  excludes=['.svn', 'CVS', '.git', '.hg*'])
                        copy_tree('xml', os.path.join(cfg_dir, 'xml'), True)
                        os.chdir(here)
                        create_breathe_stylesheet(target)

                for f in dext.extra_docs:
                    shutil.copy(os.path.join(doc_dir, f), target)

                ## Sphinx
                if dext.without_sphinx:
                    return
                if dext.sphinx_config is None:
                    level_up = os.path.dirname(os.path.dirname(__file__))
                    dext.sphinx_config = os.path.join(level_up,
                                                      'sphinx_conf.py.in')
                elif os.path.dirname(dext.sphinx_config) == '':
                    dext.sphinx_config =  os.path.join(doc_dir,
                                                       dext.sphinx_config)
                configure_file(environ, dext.sphinx_config,
                               os.path.join(cfg_dir, 'conf.py'))
                import warnings
                try:
                    import sphinx  # pylint: disable=W0612
                except ImportError:
                    configure_package('breathe')  ## requires sphinx
                    sys.path.insert(0, os.path.join(options.target_build_dir,
                                                    options.local_lib_dir))

                from sphinx.application import Sphinx
                if 'windows' in platform.system().lower() or \
                   not build_verbose:
                    from sphinx.util.console import nocolor
                warnings.filterwarnings("ignore",
                                        category=PendingDeprecationWarning)
                warnings.filterwarnings("ignore", category=UserWarning)

                status = sys.stdout
                if not build_verbose:
                    status = open('sphinx.log', 'w')
                if 'windows' in platform.system().lower() or not build_verbose:
                    nocolor()
                try:
                    ## args: srcdir, confdir, outdir, doctreedir, buildername
                    sphinx_app = Sphinx(os.path.join(working_dir, dext.name),
                                        cfg_dir, target,
                                        os.path.join(target, '.doctrees'),
                                        'html', status=status)
                    sphinx_app.build(force_all=True, filenames=None)
                except Exception:  # pylint: disable=W0703
                    if build_verbose:
                        print('ERROR: ' + str(sys.exc_info()[1]))
                    else:
                        pass
                if not build_verbose:
                    status.close()
                warnings.resetwarnings()
Exemplo n.º 18
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        openmpi_lib_list = ['mpi', 'mpi_cxx', 'mpi_f90']
        arch = 'i686'
        if struct.calcsize('P') == 8:
            arch = 'x86_64'

        base_dirs = []
        limit = False
        if 'OPENMPI_LIB_DIR' in environ and environ['OPENMPI_LIB_DIR']:
            base_dirs.append(environ['OPENMPI_LIB_DIR'])
            limit = True
            if 'OPENMPI_INCLUDE_DIR' in environ and environ['OPENMPI_INCLUDE_DIR']:
                base_dirs.append(environ['OPENMPI_INCLUDE_DIR'])

        if not limit:
            try:
                base_dirs += os.environ['LD_LIBRARY_PATH'].split(os.pathsep)
                base_dirs += os.environ['CPATH'].split(os.pathsep)
            except KeyError:
                pass
            try:
                base_dirs.append(os.environ['OPENMPI_ROOT'])
            except KeyError:
                pass
            for d in programfiles_directories():
                base_dirs.append(os.path.join(d, 'OPENMPI'))
            try:
                base_dirs.append(environ['MINGW_DIR'])
                base_dirs.append(environ['MSYS_DIR'])
            except KeyError:
                pass

        try:
            subdirs = [os.path.join('openmpi', 'lib')]
            openmpi_lib_dir, openmpi_libs  = find_libraries(openmpi_lib_list[0],
                                                            base_dirs, subdirs)
            openmpi_inc_dir = find_header(self.hdr, base_dirs,
                                          ['openmpi', 'openmpi-' + arch,])
            openmpi_exe = find_program('mpicc', base_dirs +
                                       [os.path.join(openmpi_lib_dir, '..')])
            openmpi_exe_dir = os.path.abspath(os.path.dirname(openmpi_exe))
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        os.environ['PATH'] = os.environ.get('PATH', '') + \
                             os.pathsep + openmpi_exe_dir
        self.environment['OPENMPI_PATH'] = openmpi_exe_dir
        self.environment['OPENMPI_INCLUDE_DIR'] = openmpi_inc_dir
        self.environment['OPENMPI_LIB_DIR'] = openmpi_lib_dir
        self.environment['OPENMPI_LIBRARIES'] = openmpi_lib_list
        self.environment['OPENMPI_LIB_FILES'] = openmpi_libs
        try:
            p = subprocess.Popen([openmpi_exe, '-show'],
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out, err = p.communicate()
            if err != '':
                self.found = False
                return self.found
            self.environment['OPENMPI_FLAGS'] = out.split()[1:]
        except OSError:
            self.found = False
        return self.found
Exemplo n.º 19
0
def make_doc(src_file, target_dir=None, mode='docbook'):
    if target_dir is None:
        pth = os.path.relpath(os.path.dirname(src_file)).split(os.sep)[1:]
        # pylint: disable=W0142
        target_dir = os.path.join(options.target_build_dir, *pth)

    emacs_exe = find_program('emacs')
    src_dir = os.path.abspath(os.path.dirname(src_file))
    mkdir(target_dir)
    copy_tree(src_dir, target_dir)
    cfg_filename = os.path.join(target_dir, '.emacs')
    cfg = open(cfg_filename, 'w')
    cfg.write("(require 'org-latex)\n" +
              "(unless (boundp 'org-export-latex-classes)\n" +
              "  (setq org-export-latex-classes nil))\n" +
              "(add-to-list 'org-export-latex-classes\n" +
              "             '(\"short-book\"\n" +
              "               \"\\\\documentclass{book}\"\n" +
              "               (\"\\\\chapter{%s}\" . \"\\\\chapter*{%s}\")\n" +
              "               (\"\\\\section{%s}\" . \"\\\\section*{%s}\")\n" +
              "               (\"\\\\subsection{%s}\" . \"\\\\subsection*{%s}\")\n" +
              "               (\"\\\\subsubsection{%s}\" . \"\\\\subsubsection*{%s}\"))\n" +
              "             )\n"
          )
    cfg.close()

    ## Check version of org-mode
    cmd_line = [emacs_exe, '--batch', "--execute='(message (org-version))'"]
    p = subprocess.Popen(" ".join(cmd_line), shell=True,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    _, err = p.communicate()
    version_eight = False
    try:
        last = err.split('\n')[-2]
        if int(last[:last.index('.')]) > 7:
            version_eight = True
    except:
        raise Exception("Emacs does not have Org mode support.")

    ## Emacs Org mode export
    cmd_line = [emacs_exe, '--batch',
                "--execute='(load-file \"" + cfg_filename + "\"))'",
                '--visit=' + src_file]
    base_filename = os.path.splitext(os.path.basename(src_file))[0]
    if 'pdflatex' in mode:
        cmd_line.append("--execute='(org-export-as-pdf nil)'")
        result_files = [base_filename + '.tex', base_filename + '.pdf',]
    elif 'latex' in mode:
        cmd_line.append("--execute='(org-export-as-latex nil)'")
        result_files = [base_filename + '.tex']
    elif 'html' in mode:
        cmd_line.append("--execute='(org-export-as-html nil)'")
        result_files = [base_filename + '.html']
    else:
        if version_eight:
            ## TODO  texinfo for org v8.0+
            raise Exception("Emacs Org mode v8.0+ is not (yet) supported")
        else:
            cmd_line.append("--execute='(org-export-as-docbook nil)'")
            result_files = [base_filename + '.xml']

    subprocess.check_call(" ".join(cmd_line), shell=True)
    os.remove(cfg_filename)

    for r in result_files:
        shutil.move(os.path.join(src_dir, r),
                    os.path.join(target_dir, r))
    return os.path.join(target_dir, result_files[-1])
Exemplo n.º 20
0
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        mpich_lib_list = ['mpich', 'mpichcxx', 'mpichf90']
        if 'windows' in platform.system().lower():
            mpich_lib_list = ['mpi', 'mpicxx', 'fmpich2g']
        arch = 'i686'
        if struct.calcsize('P') == 8:
            arch = 'x86_64'

        base_dirs = []
        limit = False
        if 'MPICH_LIB_DIR' in environ and environ['MPICH_LIB_DIR']:
            base_dirs.append(environ['MPICH_LIB_DIR'])
            limit = True
            if 'MPICH_INCLUDE_DIR' in environ and environ['MPICH_INCLUDE_DIR']:
                base_dirs.append(environ['MPICH_INCLUDE_DIR'])

        if not limit:
            try:
                base_dirs += os.environ['LD_LIBRARY_PATH'].split(os.pathsep)
                base_dirs += os.environ['CPATH'].split(os.pathsep)
            except KeyError:
                pass
            try:
                base_dirs.append(os.environ['MPICH_ROOT'])
            except KeyError:
                pass
            for d in programfiles_directories():
                base_dirs.append(os.path.join(d, 'MPICH2'))
            try:
                base_dirs.append(environ['MINGW_DIR'])
                base_dirs.append(environ['MSYS_DIR'])
            except KeyError:
                pass

        try:
            mpich_lib_dir, mpich_libs  = find_libraries(mpich_lib_list[0],
                                                        base_dirs)
            mpich_inc_dir = find_header(self.hdr, base_dirs,
                                        ['mpich2', 'mpich2-' + arch,])
            mpich_exe = find_program('mpicc', base_dirs +
                                     [os.path.join(mpich_lib_dir, '..')])
            mpich_exe_dir = os.path.abspath(os.path.dirname(mpich_exe))
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        os.environ['PATH'] = os.environ.get('PATH', '') + \
                             os.pathsep + mpich_exe_dir
        self.environment['MPICH_PATH'] = mpich_exe_dir
        self.environment['MPICH_INCLUDE_DIR'] = mpich_inc_dir
        self.environment['MPICH_LIB_DIR'] = mpich_lib_dir
        self.environment['MPICH_LIBRARIES'] = mpich_lib_list
        self.environment['MPICH_LIB_FILES'] = mpich_libs
        try:
            p = subprocess.Popen([mpich_exe, '-compile_info', '-link_info'],
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out, err = p.communicate()
            if err != '':
                self.found = False
                return self.found
            self.environment['MPICH_FLAGS'] = out.split()[1:]
        except OSError:
            self.found = False
        return self.found
Exemplo n.º 21
0
def make_doc(src_file, target_dir=None, stylesheet=None):
    (XSLTPROC, JAVA_SAXON, NET_SAXON) = range(3)

    src_dir = os.path.abspath(os.path.dirname(src_file))
    if target_dir is None:
        pth = os.path.relpath(os.path.dirname(src_file)).split(os.sep)[1:]
        # pylint: disable=W0142
        target_dir = os.path.join(options.target_build_dir, *pth)
    if stylesheet is None:
        stylesheet = 'http://docbook.sourceforge.net/release/fo/docbook.xsl'

    fop_exe = find_program('fop')
    java_exe = find_program('java')
    try:  ## prefer xsltproc
        xslt_exe = [find_program('xsltproc')]
        which = XSLTPROC
    except Exception:  # pylint: disable=W0703
        try:
            classpaths = []
            try:
                for path in os.environ['CLASSPATH'].split(os.pathsep):
                    classpaths.append(os.path.dirname(path))
            except KeyError:
                pass
            try:
                classpaths.append(os.path.join(os.environ['JAVA_HOME'], 'lib'))
            except KeyError:
                pass
            saxon_jar = find_file('saxon*.jar',
                                  ['/usr/share/java', '/usr/local/share/java',
                                   '/opt/local/share/java',] + classpaths)
            resolver_jar = find_file('resolver*.jar',
                                     ['/usr/share/java',
                                      '/usr/local/share/java',
                                      '/opt/local/share/java',] + classpaths)
            xslt_exe = [java_exe, '-classpath',
                        os.pathsep.join([saxon_jar, resolver_jar]),
                        '-jar', saxon_jar]
            which = JAVA_SAXON
        except Exception:  # pylint: disable=W0703
            xslt_exe = [find_program('saxon')]
            which = NET_SAXON

    if not os.path.exists(target_dir):
        mkdir(target_dir)
    copy_tree(src_dir, target_dir)

    ## Need to respect relative paths
    here = os.getcwd()
    os.chdir(target_dir)
    src_base = os.path.basename(src_file)
    fo_src = os.path.splitext(src_base)[0] + '.fo'
    pdf_dst = os.path.splitext(src_base)[0] + '.pdf'

    if which == XSLTPROC:
        cmd_line = xslt_exe + ['-xinclude', '-o', fo_src, stylesheet, src_base]
    elif which == JAVA_SAXON:
        cmd_line = xslt_exe + ['-o', fo_src, src_base, stylesheet]
    else:
        cmd_line = xslt_exe + [src_base, '-o:' + fo_src, '-xsl:' + stylesheet]
        if 'XML_CATALOG_FILES' in os.environ:
            cmd_line += ['-catalog:' + os.environ['XML_CATALOG_FILES']]
    subprocess.check_call(" ".join(cmd_line), shell=True)

    cmd_line = [fop_exe, '-fo', fo_src, '-pdf', pdf_dst]
    subprocess.check_call(" ".join(cmd_line), shell=True)
    os.chdir(here)
Exemplo n.º 22
0
    def is_installed(self, environ, version=None, strict=False):
        if version is None:
            ver = '5'
        else:
            ver = version.split('.')[0]

        options.set_debug(self.debug)
        lib_ver = ''
        base_dirs = []
        limit = False
        if 'PERL_LIB_DIR' in environ and environ['PERL_LIB_DIR']:
            base_dirs.append(environ['PERL_LIB_DIR'])
            limit = True
            if 'PERL_INCLUDE_DIR' in environ and environ['PERL_INCLUDE_DIR']:
                base_dirs.append(environ['PERL_INCLUDE_DIR'])

        if not limit:
            try:
                base_dirs += os.environ['LD_LIBRARY_PATH'].split(os.pathsep)
                base_dirs += os.environ['CPATH'].split(os.pathsep)
            except KeyError:
                pass
            try:
                base_dirs.append(os.environ['PERL_CORE'])
            except KeyError:
                pass
            try:
                base_dirs.append(os.environ['PERL_ROOT'])
            except KeyError:
                pass
            if 'windows' in platform.system().lower():
                ## Strawberry Perl from http://strawberryperl.com
                base_dirs.append(os.path.join('C:', os.sep,
                                              'strawberry', 'perl'))
                try:
                    base_dirs.append(environ['MSYS_DIR'])  ## msys includes perl
                except KeyError:
                    pass
            elif 'darwin' in platform.system().lower():
                base_dirs.append(os.path.join('/', 'System', 'Library', 'Perl',
                                              ver + '*', 'darwin-*'))

        try:
            perl_exe = find_program('perl', base_dirs)
            incl_dir = find_header(self.hdr, base_dirs,
                                   ['CORE', os.path.join('lib', 'CORE'),
                                    os.path.join('perl', 'CORE'),
                                    os.path.join('perl' + ver, 'CORE'),
                                    os.path.join('lib', 'perl' + ver,
                                                 ver + '.*', 'msys', 'CORE'),
                                    ])
            lib_dir, perl_lib  = find_library(self.lib, base_dirs,
                                              [os.path.join('perl', 'bin'),
                                               incl_dir,])
            if 'windows' in platform.system().lower():
                lib_ver = perl_lib[0].split('.')[0].split('perl')[1]
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment['PERL'] = perl_exe
        self.environment['PERL_INCLUDE_DIR'] = incl_dir
        self.environment['PERL_LIB_DIR'] = lib_dir
        self.environment['PERL_LIBRARIES'] = ['perl' + lib_ver]
        self.environment['PERL_LIB_FILES'] = [perl_lib]
        return self.found