Skip to content

Commit 04274b3

Browse files
Fix os.path
1 parent e87ce3f commit 04274b3

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Replace built-in os module.
2+
from uos import *
3+
4+
# Provide optional dependencies (which may be installed separately).
5+
try:
6+
from . import path
7+
except ImportError:
8+
pass

internal_filesystem/main.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
print(f"{sys.version=}")
1313
print(f"{sys.implementation=}")
1414

15-
# Patch (u)os module so os.path works like in CPython - do this before starting apps
16-
#import os as _os
17-
#import path as _path
18-
#_os.path = _path
19-
#sys.modules["os"] = _os
20-
#sys.modules["uos"] = _os
15+
# Ensure os.path is available before starting apps.
16+
# internal_filesystem/lib/os/__init__.py provides a pure-Python os package
17+
# (from micropython-lib) that wraps uos and exposes os.path.
18+
import os as _os
19+
sys.modules["os"] = _os
20+
sys.modules["uos"] = _os
2121

2222
print("Free space on root filesystem:")
2323
import os
@@ -42,4 +42,3 @@
4242
time.sleep(5) # sleep so the user has time to connect to serial console
4343
sys.print_exception(e) # print it after the sleep so user can see it on serial console
4444
print("MicroPythonOS exiting.")
45-

0 commit comments

Comments
 (0)