@@ -797,25 +797,35 @@ def build_mupdf_windows(
797797 ):
798798
799799 assert mupdf_local
800-
801- if overwrite_config :
802- mupdf_config_h = f'{ mupdf_local } /include/mupdf/fitz/config.h'
803- prefix = '#define TOFU_CJK_EXT 1 /* PyMuPDF override. */\n '
804- with open (mupdf_config_h ) as f :
805- text = f .read ()
806- if text .startswith (prefix ):
807- print (f'Not modifying { mupdf_config_h } because already has prefix { prefix !r} .' )
808- else :
809- print (f'Prefixing { mupdf_config_h } with { prefix !r} .' )
810- text = prefix + text
811- st = os .stat (mupdf_config_h )
812- with open (mupdf_config_h , 'w' ) as f :
813- f .write (text )
814- os .utime (mupdf_config_h , (st .st_atime , st .st_mtime ))
815-
800+ mupdf_version_tuple = get_mupdf_version (mupdf_local )
801+ log (f'{ overwrite_config = } ' )
802+ log (f'{ mupdf_version_tuple = } ' )
816803 wp = pipcl .wdev .WindowsPython ()
817804 tesseract = '' if os .environ .get ('PYMUPDF_SETUP_MUPDF_TESSERACT' ) == '0' else 'tesseract-'
818805 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+
819829 if g_py_limited_api :
820830 windows_build_tail += f'-Py_LIMITED_API_{ pipcl .current_py_limited_api ()} '
821831 windows_build_tail += f'-x{ wp .cpu .bits } -py{ wp .version } '
0 commit comments