comparison mupdf-source/thirdparty/tesseract/nsis/find_deps.py @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 #!/usr/bin/env python3
2 #
3 # Copyright (C) 2024 Stefan Weil
4 #
5 # SPDX-License-Identifier: MIT
6 #
7 # Find the DLL files which are required for a given set of
8 # Windows executables and libraries.
9
10 import argparse
11 import os
12 import pefile
13
14 VERBOSE = False
15
16 def find_dependencies(binary, search_path, analyzed_deps):
17 pe = pefile.PE(binary)
18 pe.parse_data_directories()
19 if VERBOSE:
20 print(f'{binary}:')
21 # print(pe.dump_info())
22
23 for entry in pe.DIRECTORY_ENTRY_IMPORT:
24 name = entry.dll.decode('utf-8')
25 if name in analyzed_deps:
26 if VERBOSE:
27 print(f'skip {name} (already analyzed)')
28 continue
29 analyzed_deps.add(name)
30 fullpath = os.path.join(search_path, name)
31 if not os.path.exists(fullpath):
32 # Not found, maybe system DLL. Skip it.
33 if VERBOSE:
34 print(f'skip {name} (not found, maybe system DLL)')
35 continue
36 print(fullpath)
37 analyzed_deps = find_dependencies(fullpath, search_path, analyzed_deps)
38
39 return analyzed_deps
40
41 def main():
42 """
43 Command-line interface for universal dependency scanner.
44 """
45
46 parser = argparse.ArgumentParser(description='Find and copy DLL dependencies')
47 parser.add_argument('files', nargs='+', help='Paths to executable or library files')
48 parser.add_argument('--dlldir', dest='dlldir', default='/mingw64/bin/',
49 help='path to dll files')
50
51 args = parser.parse_args()
52
53 # try:
54 # Find dependencies
55 analyzed_deps = set()
56 for binary in args.files:
57 if True:
58 analyzed_deps = find_dependencies(binary, args.dlldir, analyzed_deps)
59 # except:
60 # print(f'error: failed to find dependencies for {binary}')
61
62
63 if __name__ == '__main__':
64 main()