Build Pyodide wheel. This runs `pyodide build` inside the PyMuPDF directory, which in turn runs setup.py in a Pyodide build environment.
(pyodide_build_version=None)
| 1168 | |
| 1169 | |
| 1170 | def build_pyodide_wheel(pyodide_build_version=None): |
| 1171 | ''' |
| 1172 | Build Pyodide wheel. |
| 1173 | |
| 1174 | This runs `pyodide build` inside the PyMuPDF directory, which in turn runs |
| 1175 | setup.py in a Pyodide build environment. |
| 1176 | ''' |
| 1177 | log(f'## Building Pyodide wheel.') |
| 1178 | |
| 1179 | # Our setup.py does not know anything about Pyodide; we set a few |
| 1180 | # required environmental variables here. |
| 1181 | # |
| 1182 | env_extra = dict() |
| 1183 | |
| 1184 | # Disable libcrypto because not available in Pyodide. |
| 1185 | env_extra['HAVE_LIBCRYPTO'] = 'no' |
| 1186 | |
| 1187 | # Tell MuPDF to build for Pyodide. |
| 1188 | env_extra['OS'] = 'pyodide' |
| 1189 | |
| 1190 | # Build a single wheel without a separate PyMuPDFb wheel. |
| 1191 | env_extra['PYMUPDF_SETUP_FLAVOUR'] = 'pb' |
| 1192 | |
| 1193 | # 2023-08-30: We set PYMUPDF_SETUP_MUPDF_BUILD_TESSERACT=0 because |
| 1194 | # otherwise mupdf thirdparty/tesseract/src/ccstruct/dppoint.cpp fails to |
| 1195 | # build because `#include "errcode.h"` finds a header inside emsdk. This is |
| 1196 | # pyodide bug https://github.com/pyodide/pyodide/issues/3839. It's fixed in |
| 1197 | # https://github.com/pyodide/pyodide/pull/3866 but the fix has not reached |
| 1198 | # pypi.org's pyodide-build package. E.g. currently in tag 0.23.4, but |
| 1199 | # current devuan pyodide-build is pyodide_build-0.23.4. |
| 1200 | # |
| 1201 | env_extra['PYMUPDF_SETUP_MUPDF_TESSERACT'] = '0' |
| 1202 | setup = pyodide_setup(pymupdf_dir, pyodide_build_version=pyodide_build_version) |
| 1203 | command = f'{setup} && echo "### Running pyodide build" && pyodide build --exports whole_archive' |
| 1204 | |
| 1205 | command = command.replace(' && ', '\n && ') |
| 1206 | |
| 1207 | run(command, env_extra=env_extra) |
| 1208 | |
| 1209 | # Copy wheel into `wheelhouse/` so it is picked up as a workflow |
| 1210 | # artifact. |
| 1211 | # |
| 1212 | run(f'ls -l {pymupdf_dir}/dist/') |
| 1213 | run(f'mkdir -p {pymupdf_dir}/wheelhouse && cp -p {pymupdf_dir}/dist/* {pymupdf_dir}/wheelhouse/') |
| 1214 | run(f'ls -l {pymupdf_dir}/wheelhouse/') |
| 1215 | |
| 1216 | |
| 1217 | def pyodide_setup( |
no test coverage detected
searching dependent graphs…