示例#1
0
 def install(self, environ, version, strict=False, locally=True):
     if not 'darwin' in platform.system().lower():
         return
     python_version = ''
     mkdir(options.target_build_dir)
     log = open(os.path.join(options.target_build_dir,
                             'homebrew_build.log'), 'w')
     if not self.found:
         check_call('ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"',
                    stdout=log, stderr=log)
     if not self.brews_found:
         call(['brew', 'doctor'], stdout=log, stderr=log)
         call(['brew', 'install', 'git'], stdout=log, stderr=log)
         for repo in self.repositories:
             call(['brew', 'tap', repo], stdout=log, stderr=log)
         call(['brew', 'install', 'python' + python_version, '--universal',
                     '--framework'], stdout=log, stderr=log)
         call([pip_executable(), 'install', 'numpy'],
                    stdout=log, stderr=log)
         call([pip_executable(), 'install', 'distribute'],
                    stdout=log, stderr=log)
         call(['brew', 'install', 'sip'], stdout=log, stderr=log)
         call(['brew', 'install', 'pyqt'], stdout=log, stderr=log)
         call([pip_executable(), 'install', 'py2app'],
                    stdout=log, stderr=log)
     log.close()
     if not self.is_installed(environ, version. strict):
         raise Exception("Homebrew installation failed.")
示例#2
0
 def install(self, environ, version, strict=False, locally=True):
     if not self.found:
         env = dict()
         if 'windows' in platform.system().lower():
             env['LIBS'] = '-lws2_32'
             try:
                 ## zlib prerequisite
                 check_call(['mingw-get', 'install', 'libz-dev'])
             except subprocess.CalledProcessError:
                 pass
         if locally or 'windows' in platform.system().lower():
             src_dir = self.download(environ, version, strict)
             autotools_install_without_fetch(environ, src_dir, locally,
                               extra_cfg=['--enable-cxx','--enable-fortran'],
                               addtnl_env=env)
         else:
             global_install('HDF5', None,
                            brew='hdf5', port='hdf5',
                            deb='libhdf5-dev', rpm='hdf5-devel')
         if not self.is_installed(environ, version, strict):
             raise Exception('HDF5 installation failed.')
示例#3
0
 def install(self, environ, version, strict=False, locally=True):
     if not self.found:
         if locally or not 'darwin' in platform.system().lower():
             here = os.path.abspath(os.getcwd())
             if locally:
                 prefix = os.path.abspath(options.target_build_dir)
                 if not prefix in options.local_search_paths:
                     options.add_local_search_path(prefix)
             else:
                 prefix = options.global_prefix
             ## MinGW shell strips backslashes
             prefix = convert2unixpath(prefix)
             
             src_dir = self.download(environ, version, strict)
             oper_sys = 'linux'
             if 'windows' in platform.system().lower():
                 oper_sys = 'mingw'
             elif 'darwin' in platform.system().lower():
                 oper_sys = 'macosx'
             build_dir = os.path.join(options.target_build_dir, src_dir)
             os.chdir(build_dir)
             log = open('build.log', 'w')
             if 'windows' in platform.system().lower():
                 try:
                     ## ncurses prerequisite
                     check_call(['mingw-get', 'install', 'pdcurses'])
                     check_call(['mingw-get', 'install', 'libpdcurses'])
                 except subprocess.CalledProcessError:
                     pass
                 mingw_check_call(environ, ['make',
                                            'OS=mingw', 'ENV=gnu', 'all'],
                                  stdout=log, stderr=log)
                 mingw_check_call(environ, ['make',
                                            'INSTALLDIR=' + prefix, 'install'],
                                  stdout=log, stderr=log)
             else:
                 check_call(['make', 'OS=' + oper_sys, 'ENV=gnu', 'all'],
                            stdout=log, stderr=log)
                 if locally:
                     check_call(['make', 'INSTALLDIR=' + prefix, 'install'],
                                stdout=log, stderr=log)
                 else:
                     admin_check_call(['make', 'INSTALLDIR=' + prefix,
                                       'install'], stdout=log, stderr=log)
             log.close()
             os.chdir(here)
         else:
             global_install('CDF', None, brew='cdf', port='cdf')
         if not self.is_installed(environ, version, strict):
             raise Exception('CDF installation failed.')
示例#4
0
 def install(self, environ, version, strict=False, locally=True):
     if not self.found:
         if locally or 'windows' in platform.system().lower():
             ## NB: broken on Windows!
             src_dir = self.download(environ, version, strict)
             here = os.path.abspath(os.getcwd())
             if locally:
                 prefix = os.path.abspath(options.target_build_dir)
                 if not prefix in options.local_search_paths:
                     options.add_local_search_path(prefix)
             else:
                 prefix = options.global_prefix
             prefix = convert2unixpath(prefix)  ## MinGW shell strips backslashes
             build_dir = os.path.join(options.target_build_dir,
                                      src_dir, '_build')
             mkdir(build_dir)
             os.chdir(build_dir)
             log = open('build.log', 'w')
             if 'windows' in platform.system().lower():
                 # Assumes MinGW present, detected, and loaded in environment
                 mingw_check_call(environ, ['../configure',
                                            '--prefix="' + prefix + '"',
                                            '--shared', #'-O ',
                                            '-b 32', '-Si nocygin 1'],
                                  stdout=log, stderr=log)
                 mingw_check_call(environ, ['make'], stdout=log, stderr=log)
                 mingw_check_call(environ, ['make', 'install'],
                                  stdout=log, stderr=log)
             else:
                 check_call(['../configure', '--prefix=' + prefix,
                             '--shared'], stdout=log, stderr=log)
                 check_call(['make'], stdout=log, stderr=log)
                 if locally:
                     check_call(['make', 'install'], stdout=log, stderr=log)
                 else:
                     admin_check_call(['make', 'install'],
                                      stdout=log, stderr=log)
             log.close()
             os.chdir(here)
         else:
             global_install('ATLAS', None,
                            ## part of XCode
                            deb='libatlas-dev', rpm='atlas-devel')
         if not self.is_installed(environ, version, strict):
             raise Exception('ATLAS installation failed.')
示例#5
0
    def install(self, environ, version, strict=False, locally=True):
        if not self.found:
            if version is None:
                version = '5.16.3'
            website = ('http://www.perl.org/',)
            if locally and not 'windows' in platform.system().lower():
                sys.stderr.write('Perl was not found, ' +
                                 'but should be already installed by default.' +
                                 '\nInstalling locally anyway.\n')
                ## MinGW build is *not* straight-forward - hence not implemented
                website = ('http://www.cpan.org/',
                           'src/' + version.split('.')[0] + '.0/')
                src_dir = 'perl-' + str(version)
                archive = src_dir + '.tar.gz'
                fetch(''.join(website), archive, archive)
                unarchive(archive, src_dir)

                if locally:
                    prefix = os.path.abspath(options.target_build_dir)
                    if not prefix in options.local_search_paths:
                        options.add_local_search_path(prefix)
                else:
                    prefix = options.global_prefix
                here = os.path.abspath(os.getcwd())
                os.chdir(options.target_build_dir)
                log = open('build.log', 'w')
                check_call(['./Configure', '-des',
                            '-Dprefix=' + prefix],
                           stdout=log, stderr=log)
                check_call(['make'], stdout=log, stderr=log)
                check_call(['make', 'install'], stdout=log, stderr=log)
                log.close()
                os.chdir(here)
            else:
                if 'darwin' in platform.system().lower():
                    raise Exception('Perl is included with OSX. What happened?')
                if 'windows' in platform.system().lower():
                    website = ('http://strawberry-perl.googlecode.com/',
                               'files/')
                    version = '5.16.2.2'
                global_install('Perl', website,
                               'strawberry-perl-' + str(version) + '-32bit.msi',
                               deb='libperl-dev', rpm='perl-devel')
            if not self.is_installed(environ, version, strict):
                raise Exception('Perl installation failed.')
示例#6
0
    def run(self):
        failed = False
        build = self.get_finalized_command('build')
        if self.sublevel == 0 and not build.ran:
            self.run_command('build')

        if self.distribution.subpackages != None:
            subs = []
            for (pkg_name, pkg_dir) in self.distribution.subpackages:
                rf = RequirementsFinder(os.path.join(pkg_dir, 'setup.py'))
                if rf.is_sysdevel_build:
                    subs.append((pkg_name, pkg_dir))
            idx = 0
            for i in range(len(sys.argv)):
                idx = i
                if 'setup.py' in sys.argv[idx]:
                    break
            argv = list(sys.argv[idx+1:])
            for arg in sys.argv:
                if arg == 'clean' or '--sublevel' in arg:
                    argv.remove(arg)

            argv += ['--sublevel=' + str(self.sublevel + 1)]
            failed = process_subpackages(build.distribution.parallel_build,
                                         'test',
                                         os.path.abspath(build.build_base),
                                         subs, argv, False)

        ## PYTHON
        if self._has_python_tests():
            self.run_command('build')
            build = self.get_finalized_command('build')
            build_dir = os.path.abspath(build.build_base)
            environ = self.distribution.environment

            pkg_dirs = [build_dir, os.path.abspath(build.build_lib),
                        os.path.join(build_dir, 'python')]
            lib_dirs = [os.path.abspath(build.build_temp)]
            try:
                lib_dirs += environ['PATH']  ## need dlls for windows
            except KeyError:
                pass
            try:
                lib_dirs.append(os.path.join(environ['MINGW_DIR'], 'bin'))
                lib_dirs.append(os.path.join(environ['MSYS_DIR'], 'bin'))
                lib_dirs.append(os.path.join(environ['MSYS_DIR'], 'lib'))
            except KeyError:
                pass
            #postfix = '.'.join(build.build_temp.split('.')[1:])        

            for pkg, units in self._get_python_tests():
                test_dir = os.path.join(build_dir, 'test_' + pkg)
                if not os.path.exists(test_dir):
                    copy_tree('test', test_dir, excludes=['.svn*', 'CVS*'])
                f = open(os.path.join(test_dir, '__init__.py'), 'w')
                f.write("__all__ = ['" +
                        "', '".join(units) + "']\n")
                f.close()
                outfile = os.path.join(build_dir, 'test_' + pkg + '.py')
                create_testscript('test_' + pkg, units, outfile, pkg_dirs)
                wrap = create_test_wrapper(outfile, build_dir, lib_dirs)
                log.info('Python unit tests for ' + pkg)
                try:
                    check_call([wrap])
                except subprocess.CalledProcessError:
                    failed = True
                    print(sys.exc_info()[1])

        ## FORTRAN
        if self._has_fortran_tests():
            env = configure_package('fruit')
            fortran_unittest_framework = [
                os.path.join(env['FRUIT_SOURCE_DIR'], src)
                for src in env['FRUIT_SOURCE_FILES']]
            orig_exes = self.distribution.native_executables

            build = self.get_finalized_command('build')
            lib_dir = os.path.abspath(build.build_temp)
            for pkg, units in self._get_fortran_tests():
                for unit in units:
                    unit.sources = fortran_unittest_framework + unit.sources + \
                        create_fruit_driver(unit.name, unit.sources[0])
                    unit.library_dirs.append(lib_dir)
                    self.distribution.native_executables.append(unit)

            ## build w/ distutils thru backdoor
            cmd_obj = self.get_command_obj('build_exe')
            cmd_obj.ensure_finalized()
            cmd_obj.run()
            self.distribution.native_executables = orig_exes

            for pkg, units in self._get_fortran_tests():
                log.info('Fortran unit tests for ' + pkg)
                for unit in units:
                    try:
                        check_call([os.path.join(lib_dir, unit.name)])
                    except subprocess.CalledProcessError:
                        failed = True
                        print(sys.exc_info()[1])

        ## C
        if self._has_c_tests():
            env = configure_package('cunit')
            orig_exes = self.distribution.native_executables

            build = self.get_finalized_command('build')
            lib_dir = os.path.abspath(build.build_temp)
            for pkg, units in self._get_c_tests():
                for unit in units:
                    unit.sources += create_cunit_driver(unit.name,
                                                             unit.sources[0])
                    unit.include_dirs.append(env['CUNIT_INCLUDE_DIR'])
                    unit.libraries.append(env['CUNIT_LIBRARIES'])
                    unit.library_dirs.append(env['CUNIT_LIB_DIR'])
                    self.distribution.native_executables.append(unit)

            ## build w/ distutils thru backdoor
            cmd_obj = self.get_command_obj('build_exe')
            cmd_obj.ensure_finalized()
            cmd_obj.run()
            self.distribution.native_executables = orig_exes

            for pkg, units in self._get_c_tests():
                log.info('C unit tests for ' + pkg)
                for unit in units:
                    try:
                        check_call([os.path.join(lib_dir, unit.name)])
                    except subprocess.CalledProcessError:
                        failed = True
                        print(sys.exc_info()[1])

        ## C++
        if self._has_cpp_tests():
            env = configure_package('cppunit')
            orig_exes = self.distribution.native_executables

            build = self.get_finalized_command('build')
            lib_dir = os.path.abspath(build.build_temp)
            for pkg, units in self._get_cpp_tests():
                for unit in units:
                    unit.sources += create_cppunit_driver(unit.name)
                    unit.include_dirs.append(env['CPPUNIT_INCLUDE_DIR'])
                    unit.libraries.append(env['CPPUNIT_LIBRARIES'])
                    unit.library_dirs.append(env['CPPUNIT_LIB_DIR'])
                    self.distribution.native_executables.append(unit)

            ## build w/ distutils thru backdoor
            cmd_obj = self.get_command_obj('build_exe')
            cmd_obj.ensure_finalized()
            cmd_obj.run()
            self.distribution.native_executables = orig_exes

            for pkg, units in self._get_cpp_tests():
                log.info('C++ unit tests for ' + pkg)
                for unit in units:
                    try:
                        check_call([os.path.join(lib_dir, unit.name)])
                    except subprocess.CalledProcessError:
                        failed = True
                        print(sys.exc_info()[1])

        ## Javascript
        if self._has_js_tests():
            env = configure_package('qunitsuite')
            from qunitsuite.suite import QUnitSuite  \
                # pylint: disable=F0401,E0602
            for pkg, units in self._get_js_tests():
                for unit in units:
                    suite = QUnitSuite(unit)
                    result = unittest.TextTestRunner(verbosity=2).run(suite)
                    if len(result.errors) > 0:
                        failed = True
                        for error in result.errors:
                            print(error[1])
                    if len(result.failures) > 0:
                        failed = True
                        for failure in result.failures:
                            print(failure[1])

        if failed:
            sys.exit(1)
示例#7
0
    def install(self, environ, version, strict=False, locally=True):
        if not self.found:
            if locally or ('darwin' in platform.system().lower() and
                           system_uses_homebrew()):
                here = os.path.abspath(os.getcwd())
                if locally:
                    prefix = os.path.abspath(options.target_build_dir)
                    if not prefix in options.local_search_paths:
                        options.add_local_search_path(prefix)
                else:
                    prefix = options.global_prefix
                ## MinGW shell strips backslashes
                prefix = convert2unixpath(prefix)

                src_dir = 'gccxml'
                if not os.path.exists(os.path.join(here, options.download_dir,
                                                   src_dir)):
                    os.chdir(options.download_dir)
                    gitsite = 'https://github.com/gccxml/gccxml.git'
                    check_call([environ['GIT'], 'clone', gitsite, src_dir])
                    os.chdir(here)
                build_dir = os.path.join(options.download_dir,
                                         src_dir, '_build')
                mkdir(build_dir)
                os.chdir(build_dir)
                log = open('build.log', 'w')
                if 'windows' in platform.system().lower():
                    if 'MSVC' in environ:
                        config_cmd = [environ['CMAKE'], '..',
                                      '-G', '"NMake Makefiles"',
                                      '-DCMAKE_INSTALL_PREFIX=' + prefix]
                        #TODO test msvc cmake build; probably wrong
                        check_call([environ['MSVC_VARS']],
                                   stdout=log, stderr=log)
                        check_call(config_cmd, stdout=log, stderr=log)
                        check_call([environ['NMAKE']], stdout=log, stderr=log)
                        check_call([environ['NMAKE'], 'install'],
                                   stdout=log, stderr=log)
                    else:  ## MinGW
                        config_cmd = [environ['CMAKE'], '..',
                                      '-G', '"MSYS Makefiles"',
                                      '-DCMAKE_INSTALL_PREFIX=' + prefix,
                                      '-DCMAKE_MAKE_PROGRAM=/bin/make.exe']
                        mingw_check_call(environ, config_cmd,
                                         stdout=log, stderr=log)
                        mingw_check_call(environ, ['make'],
                                         stdout=log, stderr=log)
                        mingw_check_call(environ, ['make', 'install'],
                                         stdout=log, stderr=log)
                else:
                    config_cmd = [environ['CMAKE'], '..',
                                  '-G', 'Unix Makefiles',
                                  '-DCMAKE_INSTALL_PREFIX=' + prefix]
                    check_call(config_cmd, stdout=log, stderr=log)
                    check_call(['make'], stdout=log, stderr=log)
                    if locally:
                        check_call(['make', 'install'], stdout=log, stderr=log)
                    else:
                        admin_check_call(['make', 'install'],
                                         stdout=log, stderr=log)
                log.close()
                os.chdir(here)
            else:
                if version is None:
                    version = '0.6.0'
                website = ('http://www.gccxml.org/',
                           'files/v' + major_minor_version(version) + '/')
                global_install('GCCXML', website,
                               winstaller='gccxml-' + str(version) + '-win32.exe',
                               brew=None, port='gccxml-devel',
                               deb='gccxml', rpm='gccxml')
            if not self.is_installed(environ, version, strict):
                raise Exception('GCC-XML installation failed.')
示例#8
0
    def install(self, environ, version, strict=False, locally=True):
        if not self.found:
            if locally or "windows" in platform.system().lower():
                src_dir = self.download(environ, version, strict)

                here = os.path.abspath(os.getcwd())
                if locally:
                    prefix = os.path.abspath(options.target_build_dir)
                    if not prefix in options.local_search_paths:
                        options.add_local_search_path(prefix)
                else:
                    prefix = options.global_prefix

                os.chdir(os.path.join(options.target_build_dir, src_dir))
                log = open("build.log", "w")
                err = open("build.errors", "w")
                ## unique build process
                if "windows" in platform.system().lower():
                    os_environ = os.environ.copy()
                    new_path = (
                        os_environ["PATH"]
                        + os.path.join(environ["MINGW_DIR"], "bin")
                        + ";"
                        + os.path.join(environ["MSYS_DIR"], "bin")
                        + ";"
                    )
                    os_environ["PATH"] = new_path.encode("ascii", "ignore")
                    cmd_line = "bootstrap.bat mingw"
                    # cmd_line = 'bootstrap.bat msvc'
                    p = subprocess.Popen(cmd_line, env=os_environ, stdout=log, stderr=err)
                    status = p.wait()
                    if status != 0:
                        raise subprocess.CalledProcessError(status, cmd_line)
                    toolset = "toolset=gcc"
                    # toolset = 'toolset=msvc'
                    cmd_line = (
                        "bjam.exe install link=shared link=static "
                        + toolset
                        + " variant=release threading=single "
                        + '--prefix="'
                        + prefix
                        + '"'
                    )
                    p = subprocess.Popen(cmd_line, env=os_environ, stdout=log, stderr=err)
                    status = p.wait()
                    if status != 0:
                        raise subprocess.CalledProcessError(status, cmd_line)
                else:
                    check_call(["./bootstrap.sh"], stdout=log, stderr=err)
                    subprocess.call(["./bjam", "install", "--prefix=" + prefix], stdout=log, stderr=err)
                    ## may return an error even if everything built
                log.close()
                err.close()
                os.chdir(here)
            else:
                global_install(
                    "Boost",
                    None,
                    brew="boost",
                    port="boost +python" + "".join(get_python_version()),
                    deb="libboost-dev",
                    rpm="boost-devel",
                )
            if not self.is_installed(environ, version, strict):
                raise Exception("Boost installation failed.")