Closed wch closed 1 year ago
tzdata is a required dependency on windows. That specification is enabled by PEP 508 which makes it possible to condition requirements based on different markers in the installation environment.
I suspect it is pyodide/micropip not being fully compliant with these environment markers. But then there is this function in micropip dedicated to pep508 without any caveats!
I don't know what to make of it, something is not quite right.
Got it. pyodide is not Windows.
Welcome to the Pyodide terminal emulator 🐍
Python 3.10.2 (main, Jan 25 2023 18:32:53) on WebAssembly/Emscripten
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.system()
'Emscripten'
>>>
Testing that micropip respects environment markers
Welcome to the Pyodide terminal emulator 🐍
Python 3.10.2 (main, Jan 25 2023 18:32:53) on WebAssembly/Emscripten
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.system()
'Emscripten'
>>> platform.system = lambda: "Windows"
>>> platform.system()
'Windows'
>>> import micropip
>>> await micropip.install("mizani")
>>> import mizani.transforms
>>>
Here is a comment about tzdata
on Windows:
# There is no Windows port available and porting to Windows is not trivial.
# However, the compiled package can be used on Windows
On some platforms, the system does not provide
tzdata
, and this causesimport mizani.transforms
to result in an error.For example, on recent versions of Pyodide, tzdata is not included. If you run the following in the pyodide web console, it will result in an error.
The error comes from this line: https://github.com/has2k1/mizani/blob/eb780650a0c9105e466ca03053bd9fe2c06cfd0a/mizani/transforms.py#L54
I believe that Windows also does not include tzdata by default, but I don't know for sure. PEP 615 has something to say about this.
It is possible to make it work, by installing the
tzdata
module from PyPI. Running this in the pyodide web console will work:I don't know what the best way is to specify a dependency on the tzdata module -- it doesn't seem like it should be a hard dependency, because it is only necessary if the system doesn't provide tzdata.