Commit a10ba14b authored by Romain Casati's avatar Romain Casati
Browse files

Patching micropip to ignore requests package.

parent 0abeaf63
......@@ -285,6 +285,20 @@ def patch_qrcode():
svg.SvgFragmentImage.download = meta_download('.svg')
def patch_micropip():
""" Do not load the requests package from PyPi. """
import micropip
old_ar = micropip.PACKAGE_MANAGER.add_requirement
def add_requirement(requirement, ctx, transaction):
if requirement.startswith('requests'):
return
return old_ar(requirement, ctx, transaction)
micropip.PACKAGE_MANAGER.add_requirement = add_requirement
def patch(modules):
""" Patch a list of modules. """
if isinstance(modules, str):
......
......@@ -109,7 +109,7 @@ def _load_internal(packages):
return micropip_install([_internal_pkgs_dict[p]['path']
for p in packages])
return _load_pyodide('micropip').then(micropip_wrapper)
return load_and_patch('micropip').then(micropip_wrapper)
def _internal_dependencies(packages):
......
......@@ -165,3 +165,12 @@ def test_qrcode(selenium):
assert result['display']['display_type'] == 'multiple'
with open(_test_data / "qrcode-basthon.svg") as f:
assert result['display']['content']['image/svg+xml'] == f.read()
def test_micropip(selenium):
# at this point, folium should have loaded requests
# so we check that this is our version
result = selenium.run_basthon("""
import requests
requests.__author__ == 'Romain Casati'""")
assert result['result']['result']['text/plain'] == 'True'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment