MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / build_mupdf_windows

Function build_mupdf_windows

setup.py:790–882  ·  view source on GitHub ↗
(
        mupdf_local,
        build_type,
        overwrite_config,
        g_py_limited_api,
        PYMUPDF_SETUP_MUPDF_REFCHECK_IF,
        PYMUPDF_SETUP_MUPDF_TRACE_IF,
        )

Source from the content-addressed store, hash-verified

788
789
790def build_mupdf_windows(
791 mupdf_local,
792 build_type,
793 overwrite_config,
794 g_py_limited_api,
795 PYMUPDF_SETUP_MUPDF_REFCHECK_IF,
796 PYMUPDF_SETUP_MUPDF_TRACE_IF,
797 ):
798
799 assert mupdf_local
800 mupdf_version_tuple = get_mupdf_version(mupdf_local)
801 log(f'{overwrite_config=}')
802 log(f'{mupdf_version_tuple=}')
803 wp = pipcl.wdev.WindowsPython()
804 tesseract = '' if os.environ.get('PYMUPDF_SETUP_MUPDF_TESSERACT') == '0' else 'tesseract-'
805 windows_build_tail = f'build\\shared-{tesseract}{build_type}'
806
807 if overwrite_config:
808 if mupdf_version_tuple >= (1, 28):
809 # Tell mupdf build to use, for example, `/Build "ReleaseTofuCjkExt|x64"`.
810 # This avoids the need for us to modify mupdf's config.h.
811 windows_build_tail += '-TOFU_CJK_EXT'
812 log(f'Appending, {windows_build_tail=}')
813 else:
814 log(f'modifying mupdf:include/mupdf/fitz/config.h')
815 mupdf_config_h = f'{mupdf_local}/include/mupdf/fitz/config.h'
816 prefix = '#define TOFU_CJK_EXT 1 /* PyMuPDF override. */\n'
817 with open(mupdf_config_h) as f:
818 text = f.read()
819 if text.startswith(prefix):
820 log(f'Not modifying {mupdf_config_h} because already has prefix {prefix!r}.')
821 else:
822 log(f'Prefixing {mupdf_config_h} with {prefix!r}.')
823 text = prefix + text
824 st = os.stat(mupdf_config_h)
825 with open(mupdf_config_h, 'w') as f:
826 f.write(text)
827 os.utime(mupdf_config_h, (st.st_atime, st.st_mtime))
828
829 if g_py_limited_api:
830 windows_build_tail += f'-Py_LIMITED_API_{pipcl.current_py_limited_api()}'
831 windows_build_tail += f'-x{wp.cpu.bits}-py{wp.version}'
832 windows_build_dir = f'{mupdf_local}\\{windows_build_tail}'
833 #log( f'Building mupdf.')
834 devenv = os.environ.get('PYMUPDF_SETUP_DEVENV')
835 if not devenv:
836 try:
837 # Prefer VS-2022 as that is what Github provide in windows-2022.
838 log(f'Looking for Visual Studio 2022.')
839 vs = pipcl.wdev.WindowsVS(year=2022)
840 except Exception as e:
841 log(f'Failed to find VS-2022:\n'
842 f'{textwrap.indent(traceback.format_exc(), " ")}'
843 )
844 log(f'Looking for any Visual Studio.')
845 vs = pipcl.wdev.WindowsVS()
846 log(f'vs:\n{vs.description_ml(" ")}')
847 devenv = vs.devenv

Callers 1

buildFunction · 0.85

Calls 6

description_mlMethod · 0.95
get_mupdf_versionFunction · 0.85
logFunction · 0.70
getMethod · 0.45
writeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…