@@ -162,6 +162,7 @@ def main(argv):
162
162
timeout = None
163
163
pytest_k = None
164
164
system_site_packages = False
165
+ pyodide_build_version = None
165
166
166
167
options = os .environ .get ('PYMUDF_SCRIPTS_TEST_options' , '' )
167
168
options = shlex .split (options )
@@ -221,6 +222,8 @@ def main(argv):
221
222
valgrind = int (next (args ))
222
223
elif arg == '--valgrind-args' :
223
224
valgrind_args = next (args )
225
+ elif arg == '--pyodide-build-version' :
226
+ pyodide_build_version = next (args )
224
227
else :
225
228
assert 0 , f'Unrecognised option: { arg = } .'
226
229
@@ -287,7 +290,7 @@ def do_test():
287
290
elif command == 'wheel' :
288
291
do_build (wheel = True )
289
292
elif command == 'pyodide_wheel' :
290
- build_pyodide_wheel ()
293
+ build_pyodide_wheel (pyodide_build_version = pyodide_build_version )
291
294
else :
292
295
assert 0
293
296
@@ -415,7 +418,7 @@ def build(
415
418
gh_release .run (f'pip install{ build_isolation_text } -v { pymupdf_dir } ' , env_extra = env_extra )
416
419
417
420
418
- def build_pyodide_wheel ():
421
+ def build_pyodide_wheel (pyodide_build_version = None ):
419
422
'''
420
423
Build Pyodide wheel.
421
424
@@ -447,8 +450,8 @@ def build_pyodide_wheel():
447
450
# current devuan pyodide-build is pyodide_build-0.23.4.
448
451
#
449
452
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'
452
455
gh_release .run (command , env_extra = env_extra )
453
456
454
457
# Copy wheel into `wheelhouse/` so it is picked up as a workflow
@@ -459,7 +462,11 @@ def build_pyodide_wheel():
459
462
gh_release .run (f'ls -l { pymupdf_dir } /wheelhouse/' )
460
463
461
464
462
- def pyodide_setup (directory , clean = False ):
465
+ def pyodide_setup (
466
+ directory ,
467
+ clean = False ,
468
+ pyodide_build_version = None ,
469
+ ):
463
470
'''
464
471
Returns a command that will set things up for a pyodide build.
465
472
@@ -501,17 +508,23 @@ def pyodide_setup(directory, clean=False):
501
508
#
502
509
# 2024-10-11: we only work with python-3.11; later versions fail with
503
510
# 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'
509
522
if not os .path .exists ( f'{ directory } /{ venv_pyodide } ' ):
510
523
command += f' && echo "### creating venv { venv_pyodide } "'
511
524
command += f' && { python } -m venv { venv_pyodide } '
512
525
command += f' && . { venv_pyodide } /bin/activate'
513
526
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 } '
515
528
#command += f' && python -m pip install --upgrade pip wheel pyodide-build'
516
529
517
530
# Run emsdk install scripts and enter emsdk environment.
@@ -525,7 +538,9 @@ def pyodide_setup(directory, clean=False):
525
538
command += ' && echo "### running ./emsdk_env.sh"'
526
539
command += ' && . ./emsdk_env.sh' # Need leading `./` otherwise weird 'Not found' error.
527
540
528
- if 1 :
541
+ if pyodide_build_version :
542
+ command += ' && echo "### Not patching emsdk"'
543
+ else :
529
544
# Make our returned command replace emsdk/upstream/bin/wasm-opt
530
545
# with a script that does nothing, otherwise the linker
531
546
# command fails after it has created the output file. See:
0 commit comments