@@ -162,6 +162,7 @@ def main(argv):
162162 timeout = None
163163 pytest_k = None
164164 system_site_packages = False
165+ pyodide_build_version = None
165166
166167 options = os .environ .get ('PYMUDF_SCRIPTS_TEST_options' , '' )
167168 options = shlex .split (options )
@@ -221,6 +222,8 @@ def main(argv):
221222 valgrind = int (next (args ))
222223 elif arg == '--valgrind-args' :
223224 valgrind_args = next (args )
225+ elif arg == '--pyodide-build-version' :
226+ pyodide_build_version = next (args )
224227 else :
225228 assert 0 , f'Unrecognised option: { arg = } .'
226229
@@ -287,7 +290,7 @@ def do_test():
287290 elif command == 'wheel' :
288291 do_build (wheel = True )
289292 elif command == 'pyodide_wheel' :
290- build_pyodide_wheel ()
293+ build_pyodide_wheel (pyodide_build_version = pyodide_build_version )
291294 else :
292295 assert 0
293296
@@ -415,7 +418,7 @@ def build(
415418 gh_release .run (f'pip install{ build_isolation_text } -v { pymupdf_dir } ' , env_extra = env_extra )
416419
417420
418- def build_pyodide_wheel ():
421+ def build_pyodide_wheel (pyodide_build_version = None ):
419422 '''
420423 Build Pyodide wheel.
421424
@@ -447,8 +450,8 @@ def build_pyodide_wheel():
447450 # current devuan pyodide-build is pyodide_build-0.23.4.
448451 #
449452 env_extra ['PYMUPDF_SETUP_MUPDF_TESSERACT' ] = '0'
450-
451- command = f'{ pyodide_setup ( pymupdf_dir ) } && pyodide build --exports pyinit'
453+ setup = pyodide_setup ( pymupdf_dir , pyodide_build_version = pyodide_build_version )
454+ command = f'{ setup } && pyodide build --exports pyinit'
452455 gh_release .run (command , env_extra = env_extra )
453456
454457 # Copy wheel into `wheelhouse/` so it is picked up as a workflow
@@ -459,7 +462,11 @@ def build_pyodide_wheel():
459462 gh_release .run (f'ls -l { pymupdf_dir } /wheelhouse/' )
460463
461464
462- def pyodide_setup (directory , clean = False ):
465+ def pyodide_setup (
466+ directory ,
467+ clean = False ,
468+ pyodide_build_version = None ,
469+ ):
463470 '''
464471 Returns a command that will set things up for a pyodide build.
465472
@@ -501,17 +508,23 @@ def pyodide_setup(directory, clean=False):
501508 #
502509 # 2024-10-11: we only work with python-3.11; later versions fail with
503510 # pyodide-build==0.23.4 because `distutils` not available.
504- venv_pyodide = 'venv_pyodide_3.11'
505- python = sys .executable
506- if sys .version_info [:2 ] != (3 , 11 ):
507- log (f'Forcing use of python-3.11 because { sys .version = } is not 3.11.' )
508- python = 'python3.11'
511+ if pyodide_build_version :
512+ python = sys .executable
513+ a , b = sys .version_info [:2 ]
514+ venv_pyodide = f'venv_pyodide_{ a } .{ b } '
515+ else :
516+ pyodide_build_version = '0.23.4'
517+ venv_pyodide = 'venv_pyodide_3.11'
518+ python = sys .executable
519+ if sys .version_info [:2 ] != (3 , 11 ):
520+ log (f'Forcing use of python-3.11 because { sys .version = } is not 3.11.' )
521+ python = 'python3.11'
509522 if not os .path .exists ( f'{ directory } /{ venv_pyodide } ' ):
510523 command += f' && echo "### creating venv { venv_pyodide } "'
511524 command += f' && { python } -m venv { venv_pyodide } '
512525 command += f' && . { venv_pyodide } /bin/activate'
513526 command += f' && echo "### running pip install ..."'
514- command += f' && python -m pip install --upgrade pip wheel pyodide-build==0.23.4 '
527+ command += f' && python -m pip install --upgrade pip wheel pyodide-build=={ pyodide_build_version } '
515528 #command += f' && python -m pip install --upgrade pip wheel pyodide-build'
516529
517530 # Run emsdk install scripts and enter emsdk environment.
@@ -525,7 +538,9 @@ def pyodide_setup(directory, clean=False):
525538 command += ' && echo "### running ./emsdk_env.sh"'
526539 command += ' && . ./emsdk_env.sh' # Need leading `./` otherwise weird 'Not found' error.
527540
528- if 1 :
541+ if pyodide_build_version :
542+ command += ' && echo "### Not patching emsdk"'
543+ else :
529544 # Make our returned command replace emsdk/upstream/bin/wasm-opt
530545 # with a script that does nothing, otherwise the linker
531546 # command fails after it has created the output file. See:
0 commit comments