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

Support for pyroutelib3.

parent 4941d47e
......@@ -189,18 +189,19 @@ ou de dessiner avec Turtle ;
%
\end{center}
%
Vous pouvez aussi afficher des cartes (avec Folium), des graphes
(avec Graphviz) ou même faire du traitement d'image (avec PIL).
Vous pouvez aussi afficher des graphes (avec Graphviz), des cartes et
des itinéaires (avec Folium et Pyroutelib3) ou même faire du
traitement d'image (avec PIL).
\begin{center}
%
\includegraphics[width=0.3\textwidth]{medias/screenshots/gallery/centre-france}
%
\hfil
%
\includegraphics[width=0.3\textwidth]{medias/screenshots/gallery/graphviz-notebook}
%
\hfil
%
\includegraphics[width=0.3\textwidth]{medias/screenshots/gallery/centre-france}
%
\hfil
%
\includegraphics[width=0.3\textwidth]{medias/screenshots/gallery/moon}
%
......
......@@ -299,6 +299,33 @@ def patch_micropip():
micropip.PACKAGE_MANAGER.add_requirement = add_requirement
def patch_osmiter():
"""
Remove error when loading lzma module by replacing with empty file.
"""
from pathlib import Path
lzma = Path('/lib/python3.8/lzma.py')
lzma.unlink()
with lzma.open('w'):
pass
def patch_pyroutelib3():
"""
Using requests.get instead of urllib.request.urlretrieve.
"""
import pyroutelib3.datastore as ds
import requests
def urlretrieve(url, filename):
response = requests.get(url)
with open(filename, 'wb') as f:
f.write(response.content)
ds.urlretrieve = urlretrieve
def patch(modules):
""" Patch a list of modules. """
if isinstance(modules, str):
......
......@@ -72,6 +72,13 @@ _internal_pkgs_dict = {
"path": "qrcode", # loaded from PyPi
"deps": ["PIL"], # to force patching
},
"osmiter": {
"path": "osmiter", # loaded from PyPi
},
"pyroutelib3": {
"path": "pyroutelib3", # loaded from PyPi
"deps": ["osmiter", "requests"],
},
}
# checking that 'path' is in dict allows to add dependencies to pyodide packages
......
["Bio", "IPython", "PIL", "__future__", "__main__", "_abc", "_ast", "_bootlocale", "_codecs", "_collections", "_collections_abc", "_compat_pickle", "_compression", "_contextvars", "_dummy_thread", "_frozen_importlib", "_frozen_importlib_external", "_functools", "_heapq", "_imp", "_io", "_ivp", "_locale", "_markupbase", "_operator", "_posixsubprocess", "_py_abc", "_pydecimal", "_pyio", "_signal", "_sitebuiltins", "_socket", "_sre", "_stat", "_string", "_strptime", "_sysconfigdata__emscripten_", "_testcapi", "_thread", "_threading_local", "_warnings", "_weakref", "_weakrefset", "abc", "aifc", "antigravity", "argparse", "asciitree", "ast", "astropy", "asynchat", "asyncio", "asyncore", "atexit", "atomicwrites", "attr", "autograd", "bar", "base64", "basthon", "bdb", "binhex", "bisect", "bleach", "bs4", "builtins", "bz2", "cProfile", "calendar", "cgi", "cgitb", "chunk", "cloudpickle", "cmd", "code", "codecs", "codeop", "collections", "colorsys", "compileall", "concurrent", "configparser", "contextlib", "contextvars", "copy", "copyreg", "crypt", "cssselect", "csv", "cycler", "cytoolz", "dataclasses", "datetime", "dateutil", "decimal", "decorator", "difflib", "dis", "distlib", "distutils", "doctest", "docutils", "dummy_threading", "easy_install", "email", "encodings", "enum", "errno", "filecmp", "fileinput", "fnmatch", "folium", "foo", "formatter", "fractions", "freesasa", "ftplib", "functools", "future", "genericpath", "getopt", "getpass", "gettext", "glob", "graphviz", "gzip", "hashlib", "heapq", "hmac", "html", "html5lib", "http", "imageio", "imaplib", "imghdr", "imp", "importlib", "inspect", "io", "ipaddress", "itertools", "jedi", "jinja2", "joblib", "js", "json", "keyword", "kiwisolver", "linecache", "locale", "logging", "lxml", "lzma", "mailbox", "mailcap", "markupsafe", "marshal", "math", "matplotlib", "micropip", "mimetypes", "mne", "modulefinder", "more_itertools", "mpl_toolkits", "mpmath", "msgpack", "multiprocessing", "netrc", "networkx", "nltk", "nntplib", "nose", "ntpath", "nturl2path", "numbers", "numcodecs", "numpy", "opcode", "operator", "optparse", "os", "p5", "packaging", "pandas", "parso", "pathlib", "patsy", "pdb", "pickle", "pickletools", "pipes", "pkg_resources", "pkgutil", "platform", "plistlib", "pluggy", "poplib", "posix", "posixpath", "pprint", "profile", "proj4py", "pstats", "pty", "py", "py_compile", "pyclbr", "pydoc", "pydoc_data", "pygments", "pyodide", "pyodide_interrupts", "pyparsing", "pysat", "pystone", "pytest", "pytz", "pywt", "qrcode", "queue", "quopri", "random", "re", "regex", "reprlib", "requests", "rlcompleter", "runpy", "sched", "scipy", "secrets", "select", "selectors", "setuptools", "shelve", "shlex", "shutil", "signal", "site", "sitecustomize", "six", "skimage", "sklearn", "smtpd", "smtplib", "sndhdr", "socket", "socketserver", "soupsieve", "sqlite3", "sre_compile", "sre_constants", "sre_parse", "ssl", "stat", "statistics", "statsmodels", "string", "stringprep", "struct", "subprocess", "sunau", "symbol", "sympy", "symtable", "sys", "sysconfig", "tabnanny", "tarfile", "telnetlib", "tempfile", "textwrap", "this", "threading", "time", "timeit", "token", "tokenize", "toolz", "trace", "traceback", "tracemalloc", "traits", "tty", "turtle", "tutor", "types", "typing", "uncertainties", "unittest", "urllib", "uu", "uuid", "warnings", "wave", "weakref", "webbrowser", "webencodings", "wsgiref", "xdrlib", "xlrd", "xml", "xmlrpc", "yt", "zarr", "zipapp", "zipfile", "zipimport"]
\ No newline at end of file
["Bio", "IPython", "PIL", "__future__", "__main__", "_abc", "_ast", "_bootlocale", "_codecs", "_collections", "_collections_abc", "_compat_pickle", "_compression", "_contextvars", "_dummy_thread", "_frozen_importlib", "_frozen_importlib_external", "_functools", "_heapq", "_imp", "_io", "_ivp", "_locale", "_markupbase", "_operator", "_posixsubprocess", "_py_abc", "_pydecimal", "_pyio", "_signal", "_sitebuiltins", "_socket", "_sre", "_stat", "_string", "_strptime", "_sysconfigdata__emscripten_", "_testcapi", "_thread", "_threading_local", "_warnings", "_weakref", "_weakrefset", "abc", "aifc", "antigravity", "argparse", "asciitree", "ast", "astropy", "asynchat", "asyncio", "asyncore", "atexit", "atomicwrites", "attr", "autograd", "bar", "base64", "basthon", "bdb", "binhex", "bisect", "bleach", "bs4", "builtins", "bz2", "cProfile", "calendar", "cgi", "cgitb", "chunk", "cloudpickle", "cmd", "code", "codecs", "codeop", "collections", "colorsys", "compileall", "concurrent", "configparser", "contextlib", "contextvars", "copy", "copyreg", "crypt", "cssselect", "csv", "cycler", "cytoolz", "dataclasses", "datetime", "dateutil", "decimal", "decorator", "difflib", "dis", "distlib", "distutils", "doctest", "docutils", "dummy_threading", "easy_install", "email", "encodings", "enum", "errno", "filecmp", "fileinput", "fnmatch", "folium", "foo", "formatter", "fractions", "freesasa", "ftplib", "functools", "future", "genericpath", "getopt", "getpass", "gettext", "glob", "graphviz", "gzip", "hashlib", "heapq", "hmac", "html", "html5lib", "http", "imageio", "imaplib", "imghdr", "imp", "importlib", "inspect", "io", "ipaddress", "itertools", "jedi", "jinja2", "joblib", "js", "json", "keyword", "kiwisolver", "linecache", "locale", "logging", "lxml", "lzma", "mailbox", "mailcap", "markupsafe", "marshal", "math", "matplotlib", "micropip", "mimetypes", "mne", "modulefinder", "more_itertools", "mpl_toolkits", "mpmath", "msgpack", "multiprocessing", "netrc", "networkx", "nltk", "nntplib", "nose", "ntpath", "nturl2path", "numbers", "numcodecs", "numpy", "opcode", "operator", "optparse", "os", "osmiter", "p5", "packaging", "pandas", "parso", "pathlib", "patsy", "pdb", "pickle", "pickletools", "pipes", "pkg_resources", "pkgutil", "platform", "plistlib", "pluggy", "poplib", "posix", "posixpath", "pprint", "profile", "proj4py", "pstats", "pty", "py", "py_compile", "pyclbr", "pydoc", "pydoc_data", "pygments", "pyodide", "pyodide_interrupts", "pyparsing", "pyroutelib3", "pysat", "pystone", "pytest", "pytz", "pywt", "qrcode", "queue", "quopri", "random", "re", "regex", "reprlib", "requests", "rlcompleter", "runpy", "sched", "scipy", "secrets", "select", "selectors", "setuptools", "shelve", "shlex", "shutil", "signal", "site", "sitecustomize", "six", "skimage", "sklearn", "smtpd", "smtplib", "sndhdr", "socket", "socketserver", "soupsieve", "sqlite3", "sre_compile", "sre_constants", "sre_parse", "ssl", "stat", "statistics", "statsmodels", "string", "stringprep", "struct", "subprocess", "sunau", "symbol", "sympy", "symtable", "sys", "sysconfig", "tabnanny", "tarfile", "telnetlib", "tempfile", "textwrap", "this", "threading", "time", "timeit", "token", "tokenize", "toolz", "trace", "traceback", "tracemalloc", "traits", "tty", "turtle", "tutor", "types", "typing", "uncertainties", "unittest", "urllib", "uu", "uuid", "warnings", "wave", "weakref", "webbrowser", "webencodings", "wsgiref", "xdrlib", "xlrd", "xml", "xmlrpc", "yt", "zarr", "zipapp", "zipfile", "zipimport"]
\ No newline at end of file
Please wait a moment while I gather a list of all available modules...
Bio binascii js requests
IPython binhex json rlcompleter
PIL bisect keyword runpy
__future__ bleach kiwisolver sched
_abc bs4 linecache scipy
_ast builtins locale secrets
_bisect bz2 logging select
_blake2 cProfile lxml selectors
_bootlocale calendar lzma setuptools
_bz2 cgi mailbox shelve
_codecs cgitb mailcap shlex
_codecs_cn chunk markupsafe shutil
_codecs_hk cloudpickle marshal signal
_codecs_iso2022 cmath math site
_codecs_jp cmd matplotlib sitecustomize
_codecs_kr code micropip six
_codecs_tw codecs mimetypes skimage
_collections codeop mmap sklearn
_collections_abc collections mne smtpd
_compat_pickle colorsys modulefinder smtplib
_compression compileall more_itertools sndhdr
_contextvars concurrent mpl_toolkits socket
_crypt configparser mpmath socketserver
_csv contextlib msgpack soupsieve
_datetime contextvars multiprocessing sqlite3
_decimal copy netrc sre_compile
_dummy_thread copyreg networkx sre_constants
_functools crypt nltk sre_parse
_heapq cssselect nntplib ssl
_imp csv nose stat
_io cycler ntpath statistics
_ivp cytoolz nturl2path statsmodels
_json dataclasses numbers string
_locale datetime numcodecs stringprep
_lsprof dateutil numpy struct
_markupbase decimal opcode subprocess
_md5 decorator operator sunau
_multibytecodec difflib optparse symbol
_operator dis os sympy
_pickle distlib p5 symtable
_posixsubprocess distutils packaging sys
_py_abc doctest pandas sysconfig
_pydecimal docutils parser tabnanny
_pyio dummy_threading parso tarfile
_queue easy_install pathlib telnetlib
_random email patsy tempfile
_sha1 encodings pdb textwrap
_sha256 enum pickle this
_sha3 errno pickletools threading
_sha512 faulthandler pipes time
_signal filecmp pkg_resources timeit
_sitebuiltins fileinput pkgutil token
_socket fnmatch platform tokenize
_sqlite3 folium plistlib toolz
_sre formatter pluggy trace
_stat fractions poplib traceback
_string freesasa posix tracemalloc
_strptime ftplib posixpath traits
_struct functools pprint tty
_symtable future profile turtle
_sysconfigdata__emscripten_ gc proj4py tutor
_testcapi genericpath pstats types
_thread getopt pty typing
_threading_local getpass pwd uncertainties
_tracemalloc gettext py unicodedata
_warnings glob py_compile unittest
_weakref graphviz pyclbr urllib
_weakrefset gzip pydoc uu
abc hashlib pydoc_data uuid
aifc heapq pyexpat warnings
antigravity hmac pygments wave
argparse html pyodide weakref
array html5lib pyodide_interrupts webbrowser
asciitree http pyparsing webencodings
ast imageio pysat wsgiref
astropy imaplib pystone xdrlib
asynchat imghdr pytest xlrd
asyncio imp pytz xml
asyncore importlib pywt xmlrpc
atexit inspect qrcode xxsubtype
atomicwrites io queue yt
attr ipaddress quopri zarr
autograd itertools random zipapp
base64 jedi re zipfile
basthon jinja2 regex zipimport
bdb joblib reprlib zlib
Bio binhex keyword rlcompleter
IPython bisect kiwisolver runpy
PIL bleach linecache sched
__future__ bs4 locale scipy
_abc builtins logging secrets
_ast bz2 lxml select
_bisect cProfile lzma selectors
_blake2 calendar mailbox setuptools
_bootlocale cgi mailcap shelve
_bz2 cgitb markupsafe shlex
_codecs chunk marshal shutil
_codecs_cn cloudpickle math signal
_codecs_hk cmath matplotlib site
_codecs_iso2022 cmd micropip sitecustomize
_codecs_jp code mimetypes six
_codecs_kr codecs mmap skimage
_codecs_tw codeop mne sklearn
_collections collections modulefinder smtpd
_collections_abc colorsys more_itertools smtplib
_compat_pickle compileall mpl_toolkits sndhdr
_compression concurrent mpmath socket
_contextvars configparser msgpack socketserver
_crypt contextlib multiprocessing soupsieve
_csv contextvars netrc sqlite3
_datetime copy networkx sre_compile
_decimal copyreg nltk sre_constants
_dummy_thread crypt nntplib sre_parse
_functools cssselect nose ssl
_heapq csv ntpath stat
_imp cycler nturl2path statistics
_io cytoolz numbers statsmodels
_ivp dataclasses numcodecs string
_json datetime numpy stringprep
_locale dateutil opcode struct
_lsprof decimal operator subprocess
_markupbase decorator optparse sunau
_md5 difflib os symbol
_multibytecodec dis osmiter sympy
_operator distlib p5 symtable
_pickle distutils packaging sys
_posixsubprocess doctest pandas sysconfig
_py_abc docutils parser tabnanny
_pydecimal dummy_threading parso tarfile
_pyio easy_install pathlib telnetlib
_queue email patsy tempfile
_random encodings pdb textwrap
_sha1 enum pickle this
_sha256 errno pickletools threading
_sha3 faulthandler pipes time
_sha512 filecmp pkg_resources timeit
_signal fileinput pkgutil token
_sitebuiltins fnmatch platform tokenize
_socket folium plistlib toolz
_sqlite3 formatter pluggy trace
_sre fractions poplib traceback
_stat freesasa posix tracemalloc
_string ftplib posixpath traits
_strptime functools pprint tty
_struct future profile turtle
_symtable gc proj4py tutor
_sysconfigdata__emscripten_ genericpath pstats types
_testcapi getopt pty typing
_thread getpass pwd uncertainties
_threading_local gettext py unicodedata
_tracemalloc glob py_compile unittest
_warnings graphviz pyclbr urllib
_weakref gzip pydoc uu
_weakrefset hashlib pydoc_data uuid
abc heapq pyexpat warnings
aifc hmac pygments wave
antigravity html pyodide weakref
argparse html5lib pyodide_interrupts webbrowser
array http pyparsing webencodings
asciitree imageio pyroutelib3 wsgiref
ast imaplib pysat xdrlib
astropy imghdr pystone xlrd
asynchat imp pytest xml
asyncio importlib pytz xmlrpc
asyncore inspect pywt xxsubtype
atexit io qrcode yt
atomicwrites ipaddress queue zarr
attr itertools quopri zipapp
autograd jedi random zipfile
base64 jinja2 re zipimport
basthon joblib regex zlib
bdb js reprlib
binascii json requests
Enter any module name to get more help. Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".
......
......@@ -160,3 +160,13 @@ def test__ivp(selenium):
def test_qrcode(selenium):
# already tested in test_patched_modules
assert True
def test_osmiter(selenium):
# already tested in test_patched_modules
assert True
def test_pyroutelib3(selenium):
# already tested in test_patched_modules
assert True
......@@ -167,6 +167,27 @@ def test_qrcode(selenium):
assert result['display']['content']['image/svg+xml'] == f.read()
def test_osmiter(selenium):
# tested in test_pyroutelib3
assert True
def test_pyroutelib3(selenium):
result = selenium.run_basthon("""
from pyroutelib3 import Router
depart = [47.08428480854615, 2.3939454203269217]
arrivee = [47.08187952227819, 2.398992969262373]
router = Router("foot")
node_depart = router.findNode(*depart)
node_arrivee = router.findNode(*arrivee)
status, route = router.doRoute(node_depart, node_arrivee)
status
""")
assert result['result']['result']['text/plain'] == "'success'"
def test_micropip(selenium):
# at this point, folium should have loaded requests
# so we check that this is our version
......
......@@ -128,4 +128,7 @@ examples = {
"qrcode-strange.py": {
'desc': "Un drôle de code QR...",
},
"pyroutelib3.ipynb": {
'desc': "Un calcul d'intinéraire avec Pyroutelib3",
},
}
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