コード例 #1
0
ファイル: geos.py プロジェクト: sean-m-brennan/pysysdevel
    def is_installed(self, environ, version=None, strict=False):
        options.set_debug(self.debug)
        locations = []
        limit = False
        if 'GEOS_LIB_DIR' in environ and environ['GEOS_LIB_DIR']:
            locations.append(environ['GEOS_LIB_DIR'])
            limit = True
            if 'GEOS_INCLUDE_DIR' in environ and environ['GEOS_INCLUDE_DIR']:
                locations.append(environ['GEOS_INCLUDE_DIR'])

        if not limit:
            try:
                locations += os.environ['LD_LIBRARY_PATH'].split(os.pathsep)
            except KeyError:
                pass
            try:
                locations.append(os.environ['GEOS_ROOT'])
            except KeyError:
                pass
            if 'windows' in platform.system().lower():
                locations.append(os.path.join('C:', os.sep, 'OSGeo4W'))
            try:
                locations.append(environ['MINGW_DIR'])
                locations.append(environ['MSYS_DIR'])
            except KeyError:
                pass
        try:
            lib_dir, libs  = find_libraries(self.lib, locations, limit=limit)
            inc_dir = find_header(self.hdr, locations, limit=limit)
            quoted_ver = get_header_version(os.path.join(inc_dir, self.hdr),
                                            'GEOS_VERSION ')
            ver = quoted_ver[1:-1]
            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 ' + self.lib + ': ' +
                          str(ver) + ' vs ' + str(version))
                return self.found
            self.found = True
        except ConfigError:
            if self.debug:
                e = sys.exc_info()[1]
                print(e)
            return self.found

        self.environment['GEOS_INCLUDE_DIR'] = inc_dir
        self.environment['GEOS_LIBRARY_DIR'] = lib_dir
        self.environment['GEOS_LIBRARIES'] = ['geos', ' geos_c',]
        self.environment['GEOS_LIB_FILES'] = libs
        return self.found
コード例 #2
0
ファイル: boost.py プロジェクト: sean-m-brennan/pysysdevel
    def is_installed(self, environ, version=None, strict=False):
        if version is None:
            required_version = "1_44_0"
        else:
            required_version = version.replace(".", "_")

        # TODO not detecting if boost installed

        options.set_debug(self.debug)
        base_dirs = []
        limit = False
        if "BOOST_LIB_DIR" in environ and environ["BOOST_LIB_DIR"]:
            base_dirs.append(environ["BOOST_LIB_DIR"])
            limit = True
            if "BOOST_INCLUDE_DIR" in environ and environ["BOOST_INCLUDE_DIR"]:
                base_dirs.append(environ["BOOST_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:
                boost_root = os.environ["BOOST_ROOT"]
                boost_root = boost_root.strip('"')
                if os.path.exists(os.path.join(boost_root, "stage", "lib")):
                    base_dirs.append(os.path.join(boost_root, "stage"))
                base_dirs.append(boost_root)
            except KeyError:
                pass
            try:
                base_dirs.append(os.environ["BOOST_LIBRARY_DIR"])
            except KeyError:
                pass
            try:
                base_dirs.append(environ["MINGW_DIR"])
                base_dirs.append(environ["MSYS_DIR"])
            except KeyError:
                pass
        try:
            incl_dir = find_header(os.path.join("boost", "version.hpp"), base_dirs, ["boost-*"], limit=limit)
            lib_dir, libs = find_libraries("boost", base_dirs, limit=limit)
            # TODO boost lib_dir is wrong in windows (maybe)
            boost_version = get_header_version(os.path.join(incl_dir, "boost", "version.hpp"), "BOOST_LIB_VERSION")
            boost_version = boost_version.strip('"')
            not_ok = compare_versions(boost_version, required_version) == -1
            if strict:
                not_ok = compare_versions(boost_version, required_version) != 0
            if not_ok:
                if self.debug:
                    print("Wrong version of Boost: " + str(boost_version) + " vs " + str(required_version))
                return self.found
            self.found = True
        except ConfigError:
            if self.debug:
                print(sys.exc_info()[1])
            return self.found

        self.environment["BOOST_INCLUDE_DIR"] = incl_dir
        self.environment["BOOST_LIB_DIR"] = lib_dir
        self.environment["BOOST_LIB_FILES"] = libs
        self.environment["BOOST_LIBRARIES"] = [
            "boost_python",
            "boost_date_time",
            "boost_filesystem",
            "boost_graph",
            "boost_iostreams",
            "boost_prg_exec_monitor",
            "boost_program_options",
            "boost_regex",
            "boost_serialization",
            "boost_signals",
            "boost_system",
            "boost_thread",
            "boost_unit_test_framework",
            "boost_wave",
            "boost_wserialization",
        ]
        return self.found