Esempio n. 1
0
 def install(self):
     outfiles = install_lib.install(self)
     src = find_lib()[0]
     dst = os.path.join(self.install_dir, 'lightgbm')
     dst, _ = self.copy_file(src, dst)
     outfiles.append(dst)
     return outfiles
Esempio n. 2
0
    def install(self):

        # run default install phase
        outfiles = _install_lib.install(self)

        # does nothing if we aren't installing from a live version
        if not re.match(r'^[0-9.]+\+/', __version__):
            return outfiles

        # calculate file path
        path = os.path.join(self.install_dir, 'blohg', 'version.py')

        changed = []

        # helper callback to build the new version string
        def build_version(match):
            changed.append(True)
            return match.group(1) + __version__ + match.group(3)

        # open the file and patch
        with codecs.open(path, encoding='utf-8') as fp:
            contents = re.sub(r"(\s*version\s*=\s*')(.+?)(')(?sm)",
                              build_version, fp.read())

        # if the file was sucessfully patched, save it again
        if changed:
            with codecs.open(path, 'w', encoding='utf-8') as fp:
                fp.write(contents)
        else:
            self.warn('Failed to set version.')

        return outfiles
Esempio n. 3
0
 def install(self):
     outfiles = install_lib.install(self)
     src = find_lib()[0]
     dst = os.path.join(self.install_dir, 'lightgbm')
     dst, _ = self.copy_file(src, dst)
     outfiles.append(dst)
     return outfiles
Esempio n. 4
0
    def install(self):
        installed = install_lib.install(self)

        # Retrieve datadir
        install = self.get_finalized_command('install')

        DATADIR = self._striproot(install.install_data)

        # Update the appsite.py file
        sitefile = 'appsite.py'
        libdir = os.path.join(self.install_dir, PKGNAME)
        filename = os.path.join(libdir, sitefile)
        log.info("updating %s -> %s", sitefile, libdir)

        from gsdview import appsite
        fp = open(filename, 'w')
        fp.write("'''%s'''" % appsite.__doc__)
        fp.write('''

# Automatically generated by setup.py.
# Please do not modify.

''')
        fp.write(self.stdinstall_schema % locals())
        fp.close()

        return installed
Esempio n. 5
0
 def install(self) -> List[str]:
     outfiles = install_lib.install(self)
     src = find_lib()[0]
     dst = Path(self.install_dir) / 'lightgbm'
     dst, _ = self.copy_file(src, str(dst))
     outfiles.append(dst)
     return outfiles
Esempio n. 6
0
    def install(self):
        installed = install_lib.install(self)

        # Retrieve datadir
        install = self.get_finalized_command('install')

        DATADIR = self._striproot(install.install_data)

        # Update the appsite.py file
        sitefile = 'appsite.py'
        libdir = os.path.join(self.install_dir, PKGNAME)
        filename = os.path.join(libdir, sitefile)
        log.info("updating %s -> %s", sitefile, libdir)

        from gsdview import appsite
        fp = open(filename, 'w')
        fp.write("'''%s'''" % appsite.__doc__)
        fp.write('''

# Automatically generated by setup.py.
# Please do not modify.

''')
        fp.write(self.stdinstall_schema % locals())
        fp.close()

        return installed
Esempio n. 7
0
    def install(self):
        ret = install_lib.install(self)

        def rewrite_file(path, val_dict):
            path = os.path.join(self.install_dir, path)
            print("Rewriting %s" % path)
            with codecs.open(path, "r", "utf-8") as f:
                data = f.read()

            for varname, val in val_dict.items():
                regexp = r"(?m)^(%s\s*=).*$" % varname
                repl = r"\1 %s" % repr(val)

                data = re.sub(regexp, repl, data)

            with codecs.open(path, "w", "utf-8") as f:
                f.write(data)

        rewrite_file(
            "repoman/__init__.py",
            {
                "VERSION": self.distribution.get_version(),
            },
        )

        return ret
Esempio n. 8
0
    def install(self):

        # run default install phase
        outfiles = _install_lib.install(self)

        # does nothing if we aren't installing from a live version
        if not re.match(r'^[0-9.]+\+/', __version__):
            return outfiles

        # calculate file path
        path = os.path.join(self.install_dir, 'blohg', 'version.py')

        changed = []

        # helper callback to build the new version string
        def build_version(match):
            changed.append(True)
            return match.group(1) + __version__ + match.group(3)

        # open the file and patch
        with codecs.open(path, encoding='utf-8') as fp:
            contents = re.sub(r"(\s*version\s*=\s*')(.+?)(')(?sm)",
                              build_version, fp.read())

        # if the file was sucessfully patched, save it again
        if changed:
            with codecs.open(path, 'w', encoding='utf-8') as fp:
                fp.write(contents)
        else:
            self.warn('Failed to set version.')

        return outfiles
Esempio n. 9
0
    def install(self):
        build_cmd = self.get_finalized_command('build_ext')
        for ext_module in build_cmd.get_outputs():
            output = os.path.join(self.build_dir,
                                  os.path.basename(ext_module))
            self.copy_file(ext_module, output)

        return install_lib.install(self)
Esempio n. 10
0
 def install(self):
     outfiles = install_lib.install(self)
     if not self.nocompilation:
         src = find_lib()
         if src:
             dst, _ = self.copy_file(src, os.path.join(self.install_dir, 'rgf'))
             outfiles.append(dst)
         else:
             logger.error("Cannot find executable file. Installing without it.")
     return outfiles
Esempio n. 11
0
 def install(self):
     result = _install_lib.install(self)
     files = list(listfiles(self.install_dir))
     so_extentions = list(filter(lambda f: fnmatch.fnmatch(f, '*.so'), files))
     for source in filter(self._filter_files_with_ext, files):
         _source_name, _source_ext = os.path.splitext(source)
         if any(filter(lambda f: fnmatch.fnmatch(f, _source_name+"*.so"), so_extentions)):
             print('Removing extention sources [{}].'.format(source))
             os.remove(source)
     minify_static_files('', files, self.static_exclude)
     return result
Esempio n. 12
0
 def install(self):
     outfiles = install_lib.install(self)
     if not self.nocompilation:
         src = find_rgf_lib()
         if src:
             dst, _ = self.copy_file(src, os.path.join(self.install_dir, 'rgf'))
             outfiles.append(dst)
         else:
             logger.error("Cannot find RGF executable file. Installing without it.")
         sources = find_fastrgf_lib()
         if sources:
             for src in sources:
                 dst, _ = self.copy_file(src, os.path.join(self.install_dir, 'rgf'))
                 outfiles.append(dst)
         else:
             logger.error("Cannot find FastRGF executable files. Installing without them.")
     return outfiles
Esempio n. 13
0
 def install(self):
     # Patch installation paths into catapult/__init__.py.
     get_command_obj = self.distribution.get_command_obj
     root = get_command_obj("install").root
     prefix = get_command_obj("install").install_data
     if root is not None:
         prefix = os.path.abspath(prefix)
         prefix = prefix.replace(os.path.abspath(root), "")
     data_dir = Path(prefix) / "share" / "catapult"
     locale_dir = Path(prefix) / "share" / "locale"
     init_path = Path(self.build_dir) / "catapult" / "__init__.py"
     init_text = init_path.read_text("utf-8")
     patt = r"^DATA_DIR = .*$"
     repl = f"DATA_DIR = Path({str(data_dir)!r})"
     init_text = re.sub(patt, repl, init_text, flags=re.MULTILINE)
     assert init_text.count(repl) == 1
     patt = r"^LOCALE_DIR = .*$"
     repl = f"LOCALE_DIR = Path({str(locale_dir)!r})"
     init_text = re.sub(patt, repl, init_text, flags=re.MULTILINE)
     assert init_text.count(repl) == 1
     init_path.write_text(init_text, "utf-8")
     return install_lib.install(self)
Esempio n. 14
0
 def install(self):
     # Patch installation paths into nfoview/paths.py.
     get_command_obj = self.distribution.get_command_obj
     root = get_command_obj("install").root
     prefix = get_command_obj("install").install_data
     if root is not None:
         prefix = os.path.abspath(prefix)
         prefix = prefix.replace(os.path.abspath(root), "")
     data_dir = Path(prefix) / "share" / "nfoview"
     locale_dir = Path(prefix) / "share" / "locale"
     path = Path(self.build_dir) / "nfoview" / "paths.py"
     text = path.read_text("utf-8")
     patt = r"^DATA_DIR = .*$"
     repl = "DATA_DIR = {!r}".format(str(data_dir))
     text = re.sub(patt, repl, text, flags=re.MULTILINE)
     assert text.count(repl) == 1
     patt = r"^LOCALE_DIR = .*$"
     repl = "LOCALE_DIR = {!r}".format(str(locale_dir))
     text = re.sub(patt, repl, text, flags=re.MULTILINE)
     assert text.count(repl) == 1
     path.write_text(text, "utf-8")
     return install_lib.install(self)
Esempio n. 15
0
    def install(self):
        ret = install_lib.install(self)

        def rewrite_file(path, val_dict):
            path = os.path.join(self.install_dir, path)
            print('Rewriting %s' % path)
            with codecs.open(path, 'r', 'utf-8') as f:
                data = f.read()

            for varname, val in val_dict.items():
                regexp = r'(?m)^(%s\s*=).*$' % varname
                repl = r'\1 %s' % repr(val)

                data = re.sub(regexp, repl, data)

            with codecs.open(path, 'w', 'utf-8') as f:
                f.write(data)

        rewrite_file('repoman/__init__.py', {
            'VERSION': self.distribution.get_version(),
        })

        return ret
Esempio n. 16
0
    def install(self):
        ret = install_lib.install(self)

        def rewrite_file(path, val_dict):
            path = os.path.join(self.install_dir, path)
            print("Rewriting %s" % path)
            with codecs.open(path, "r", "utf-8") as f:
                data = f.read()

            for varname, val in val_dict.items():
                regexp = r"(?m)^(%s\s*=).*$" % varname
                repl = r"\1 %s" % repr(val)

                data = re.sub(regexp, repl, data)

            with codecs.open(path, "w", "utf-8") as f:
                f.write(data)

        rewrite_file(
            "portage/__init__.py",
            {
                "VERSION": self.distribution.get_version(),
            },
        )

        def re_sub_file(path, pattern_repl_items):
            path = os.path.join(self.install_dir, path)
            print("Rewriting %s" % path)
            with codecs.open(path, "r", "utf-8") as f:
                data = f.read()
            for pattern, repl in pattern_repl_items:
                data = re.sub(pattern, repl, data, flags=re.MULTILINE)
            with codecs.open(path, "w", "utf-8") as f:
                f.write(data)

        val_dict = {}
        if create_entry_points:
            re_sub_file(
                "portage/const.py",
                (
                    (
                        r"^(GLOBAL_CONFIG_PATH\s*=\s*[\"'])(.*)([\"'])",
                        lambda m: "{}{}{}".format(
                            m.group(1),
                            m.group(2).partition("/usr")[-1],
                            m.group(3),
                        ),
                    ),
                    (
                        r"^(PORTAGE_BASE_PATH\s*=\s*)(.*)",
                        lambda m: "{}{}".format(
                            m.group(1),
                            'os.path.join(os.path.realpath(__import__("sys").prefix), "lib/portage")',
                        ),
                    ),
                    (
                        r"^(EPREFIX\s*=\s*)(.*)",
                        lambda m: "{}{}".format(
                            m.group(1),
                            '__import__("sys").prefix',
                        ),
                    ),
                ),
            )
        else:
            val_dict.update({
                "PORTAGE_BASE_PATH": self.portage_base,
                "PORTAGE_BIN_PATH": self.portage_bindir,
            })
        rewrite_file("portage/const.py", val_dict)

        return ret