예제 #1
0
    def apply_includes_excludes(self, files) -> t.List[str]:
        files = super().apply_includes_excludes(files)
        reduced_files = {f for f in files if not self.drop_unrequired_files(f)}

        if reduced_files != set(files):
            log.info("Found .git/__pycache__ files - ignoring for deployment")

        # assume already sorted?
        return sorted(reduced_files)
예제 #2
0
    def build(self, target: Path):
        with tarfile.TarFile.open(target, mode="w:gz", compresslevel=6, format=tarfile.PAX_FORMAT) as tf:
            files_to_add: t.List[str] = self.apply_includes_excludes(self.select_files())

            for relpath in files_to_add:
                path = osp.join(self.cfgdir, relpath)
                ti: tarfile.TarInfo = tf.gettarinfo(path, arcname=relpath)
                ti = clean_tarinfo(ti)
                if ti.isfile():
                    with open(path, "rb") as f:
                        tf.addfile(ti, f)
                else:
                    tf.addfile(ti)  # Symlinks & ?

        log.info(f"Built bundle: {target}")