How to use the bypy.utils.walk function in bypy

To help you get started, we’ve selected a few bypy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github norbusan / calibre-debian / bypy / windows / __main__.py View on Github external
shutil.copy2(x + '.manifest', env.dll_dir)
        except EnvironmentError as err:
            if err.errno != errno.ENOENT:
                raise

    bindir = os.path.join(PREFIX, 'bin')
    for x in ('pdftohtml', 'pdfinfo', 'pdftoppm', 'jpegtran-calibre', 'cjpeg-calibre', 'optipng-calibre', 'JXRDecApp-calibre'):
        copybin(os.path.join(bindir, x + '.exe'))
    for f in glob.glob(os.path.join(bindir, '*.dll')):
        if re.search(r'(easylzma|icutest)', f.lower()) is None:
            copybin(f)

    copybin(os.path.join(env.python_base, 'python%s.dll' % env.py_ver.replace('.', '')))
    for x in glob.glob(os.path.join(env.python_base, 'DLLs', '*')):  # python pyd modules
        copybin(x)
    for f in walk(os.path.join(env.python_base, 'Lib')):
        if f.lower().endswith('.dll') and 'scintilla' not in f.lower():
            copybin(f)
    add_plugins(env, ext_dir)

    printf('Adding Qt...')
    for x in QT_DLLS:
        copybin(os.path.join(QT_PREFIX, 'bin', x + '.dll'))
    copybin(os.path.join(QT_PREFIX, 'bin', 'QtWebEngineProcess.exe'))
    for x in 'libGLESv2 libEGL'.split():
        copybin(os.path.join(QT_PREFIX, 'bin', x + '.dll'))
    plugdir = j(QT_PREFIX, 'plugins')
    tdir = j(env.app_base, 'plugins')
    for d in QT_PLUGINS:
        imfd = os.path.join(plugdir, d)
        tg = os.path.join(tdir, d)
        if os.path.exists(tg):
github norbusan / calibre-debian / bypy / windows / __main__.py View on Github external
printf('Adding Qt...')
    for x in QT_DLLS:
        copybin(os.path.join(QT_PREFIX, 'bin', x + '.dll'))
    copybin(os.path.join(QT_PREFIX, 'bin', 'QtWebEngineProcess.exe'))
    for x in 'libGLESv2 libEGL'.split():
        copybin(os.path.join(QT_PREFIX, 'bin', x + '.dll'))
    plugdir = j(QT_PREFIX, 'plugins')
    tdir = j(env.app_base, 'plugins')
    for d in QT_PLUGINS:
        imfd = os.path.join(plugdir, d)
        tg = os.path.join(tdir, d)
        if os.path.exists(tg):
            shutil.rmtree(tg)
        shutil.copytree(imfd, tg)
    for f in walk(tdir):
        if not f.lower().endswith('.dll'):
            os.remove(f)
    for data_file in os.listdir(j(QT_PREFIX, 'resources')):
        shutil.copy2(j(QT_PREFIX, 'resources', data_file), j(env.app_base, 'resources'))
    shutil.copytree(j(QT_PREFIX, 'translations'), j(env.app_base, 'translations'))

    printf('Adding python...')

    def ignore_lib(root, items):
        ans = []
        for x in items:
            ext = os.path.splitext(x)[1].lower()
            if ext in ('.dll', '.chm', '.htm', '.txt'):
                ans.append(x)
        return ans
github norbusan / calibre-debian / bypy / macos / __main__.py View on Github external
for x in os.listdir(src):
            if x in ('site-packages', 'config', 'test', 'lib2to3', 'lib-tk',
                     'lib-old', 'idlelib', 'plat-mac', 'plat-darwin', 'site.py'):
                continue
            x = join(src, x)
            if os.path.isdir(x):
                self.add_package_dir(x, dest)
            elif os.path.splitext(x)[1] in ('.so', '.py'):
                shutil.copy2(x, dest)
                dest2 = join(dest, basename(x))
                if dest2.endswith('.so'):
                    self.fix_dependencies_in_lib(dest2)

        target = join(self.resources_dir, 'Python', 'lib')
        self.remove_bytecode(target)
        for path in walk(target):
            if path.endswith('.so'):
                self.fix_dependencies_in_lib(path)
github kovidgoyal / calibre / bypy / windows / __main__.py View on Github external
def sign_executables(env):
    files_to_sign = []
    for path in walk(env.base):
        if path.lower().endswith('.exe'):
            files_to_sign.append(path)
    printf('Signing {} exe files'.format(len(files_to_sign)))
    sign_files(env, files_to_sign)
github norbusan / calibre-debian / bypy / linux / __main__.py View on Github external
def strip_binaries(env):
    files = {j(env.bin_dir, x) for x in os.listdir(env.bin_dir)} | {
        x for x in {
            j(os.path.dirname(env.bin_dir), x) for x in os.listdir(env.bin_dir)} if os.path.exists(x)}
    for x in walk(env.lib_dir):
        x = os.path.realpath(x)
        if x not in files and is_elf(x):
            files.add(x)
    print('Stripping %d files...' % len(files))
    before = sum(os.path.getsize(x) for x in files)
    strip_files(files)
    after = sum(os.path.getsize(x) for x in files)
    print('Stripped %.1f MB' % ((before - after) / (1024 * 1024.)))
github norbusan / calibre-debian / bypy / windows / __main__.py View on Github external
def embed_manifests(env):
    printf('Embedding remaining manifests...')
    for manifest in walk(env.base):
        dll, ext = os.path.splitext(manifest)
        if ext != '.manifest':
            continue
        res = 2
        if os.path.splitext(dll)[1] == '.exe':
            res = 1
        if os.path.exists(dll) and open(manifest, 'rb').read().strip():
            run(MT, '-manifest', manifest, '-outputresource:%s;%d' % (dll, res))
        os.remove(manifest)
github kovidgoyal / calibre / bypy / macos / __main__.py View on Github external
for x in os.listdir(src):
            if x in ('site-packages', 'config', 'test', 'lib2to3', 'lib-tk',
                     'lib-old', 'idlelib', 'plat-mac', 'plat-darwin', 'site.py'):
                continue
            x = join(src, x)
            if os.path.isdir(x):
                self.add_package_dir(x, dest)
            elif os.path.splitext(x)[1] in ('.so', '.py'):
                shutil.copy2(x, dest)
                dest2 = join(dest, basename(x))
                if dest2.endswith('.so'):
                    self.fix_dependencies_in_lib(dest2)

        target = join(self.resources_dir, 'Python', 'lib')
        self.remove_bytecode(target)
        for path in walk(target):
            if path.endswith('.so'):
                self.fix_dependencies_in_lib(path)