MINGW-packages/mingw-w64-python-pymupdf/0001-pymupdf-add-mingw-setup.patch
2023-11-11 06:51:49 +00:00

89 lines
3.5 KiB
Diff

diff --git a/pipcl.py b/pipcl.py
index c8cf4ee..8f25ede 100644
--- a/pipcl.py
+++ b/pipcl.py
@@ -1469,7 +1469,7 @@ def build_extension(
rpath_flag = ''
else:
- rpath_flag = "-Wl,-rpath,'$ORIGIN',-z,origin"
+ rpath_flag = ""
path_so = f'{outdir}/{path_so_leaf}'
# Fun fact - on Linux, if the -L and -l options are before '{path_cpp}'
# they seem to be ignored...
@@ -1566,7 +1566,7 @@ def build_extension(
#
-def base_compiler(vs=None, pythonflags=None, cpp=False, use_env=True):
+def base_compiler(vs=None, pythonflags=None, cpp=False, use_env=False):
'''
Returns basic compiler command and PythonFlags.
@@ -1722,7 +1722,7 @@ def run( command, capture=False, check=1):
lines = _command_lines( command)
nl = '\n'
log2( f'Running: {nl.join(lines)}')
- sep = ' ' if windows() else '\\\n'
+ sep = ' '
command2 = sep.join( lines)
if capture:
return subprocess.run(
@@ -1740,7 +1740,7 @@ def darwin():
return sys.platform.startswith( 'darwin')
def windows():
- return platform.system() == 'Windows'
+ return platform.system() == 'Windows' and 'MSC' in sys.version
def wasm():
return os.environ.get( 'OS') in ('wasm', 'wasm-mt')
@@ -1812,12 +1812,12 @@ class PythonFlags:
python_config = pc
assert python_config, f'Cannot find python-config'
else:
- python_config = f'{python_exe}-config'
+ python_config = f'python-config'
log1(f'Using {python_config=}.')
- self.includes = run( f'{python_config} --includes', capture=1).strip()
+ self.includes = run( f'sh -c "{python_config} --includes"', capture=1).strip()
#if darwin():
# self.ldflags =
- self.ldflags = run( f'{python_config} --ldflags', capture=1).strip()
+ self.ldflags = run( f'sh -c "{python_config} --ldflags"', capture=1).strip()
if linux():
# It seems that with python-3.10 on Linux, we can get an
# incorrect -lcrypt flag that on some systems (e.g. WSL)
diff --git a/setup.py b/setup.py
index d386b14..e0c431c 100644
--- a/setup.py
+++ b/setup.py
@@ -500,7 +500,7 @@ linux = sys.platform.startswith( 'linux') or 'gnu' in sys.platform
openbsd = sys.platform.startswith( 'openbsd')
freebsd = sys.platform.startswith( 'freebsd')
darwin = sys.platform.startswith( 'darwin')
-windows = platform.system() == 'Windows' or platform.system().startswith('CYGWIN')
+windows = platform.system() == 'Windows' and 'MSC' in sys.version
pyodide = os.environ.get('OS') == 'pyodide'
@@ -1094,7 +1094,7 @@ def _extension_flags( mupdf_local, mupdf_build_dir, build_type):
libraries = f'{mupdf_local}\\platform\\{infix}\\{wp.cpu.windows_subdir}{build_type_infix}\\{libs}'
compiler_extra = ''
else:
- libs = ['mupdf']
+ libs = ['mupdf', 'mupdf-third', 'jbig2dec', 'openjp2', 'jpeg', 'png', 'z', 'freetype', 'gumbo', 'harfbuzz']
defines = None
compiler_extra += (
' -Wall'
@@ -1122,6 +1122,9 @@ def _extension_flags( mupdf_local, mupdf_build_dir, build_type):
# Use system MuPDF.
includes = list()
pi = os.environ.get('PYMUPDF_INCLUDES')
+ mingw_prefix = os.getenv("MINGW_PREFIX", "/mingw64")
+ includes.append(f'{mingw_prefix}/include')
+ includes.append(f'{mingw_prefix}/include/freetype2')
if pi:
includes += pi.split(':')
pmi = os.environ.get('PYMUPDF_MUPDF_INCLUDE')