whitphx/stlite

detect os name is posix when running on windows

Closed this issue · 2 comments

Hello there

import os
print(os.name)

When running on windows, os.name return "posix" not NT or win32.
I try to use yarn install --cpu=x64 --os=windows, but doesn't work.

BR
Tony

Add some background:
I'm using serial lib in the script, the script works well in the browser but failed in the electron app.
here is the failed log:
ModuleNotFoundError: No module named 'fcntl' Traceback: File "streamlit/runtime/scriptrunner/script_runner.py", line 598, in _run_script File "/home/pyodide/pys/COM_Reciever.py", line 4, in <module> import serial File "/lib/python3.12/site-packages/serial/__init__.py", line 31, in <module> from serial.serialposix import Serial, PosixPollSerial, VTIMESerial # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/serial/serialposix.py", line 33, in <module> import fcntl

Hi, Stlite runs Streamlit on Pyodide, which is a Python runtime running in a browser or NodeJS process isolated from the host OS and it's not a Python runtime installed in the host OS, so the os.name is always "posix" on Stlite regardless of the host OS.

Upon that, the serial functionality can't be accessed from the Python code running in Stlite, while I'm not familiar with it so much and not sure why it works well in the browser...