Skip to content

Commit

Permalink
add pkg_resources to prepare #33
Browse files Browse the repository at this point in the history
  • Loading branch information
brainelectronics committed Jun 16, 2023
1 parent d911e69 commit f1b00da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
]
],
"deps": [
["github:brainelectronics/micropython-modules", "develop"]
["github:brainelectronics/micropython-modules", "develop"],
["pkg_resources", "0.2.1"]
],
"version": "1.11.0"
}
Empty file added pkg_resources/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions pkg_resources/pkg_resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import uio

c = {}


def resource_stream(package, resource):
if package not in c:
try:
if package:
p = __import__(package + ".R", None, None, True)
else:
p = __import__("R")
c[package] = p.R
except ImportError:
if package:
p = __import__(package)
d = p.__path__
else:
d = "."
# if d[0] != "/":
# import uos
# d = uos.getcwd() + "/" + d
c[package] = d + "/"

p = c[package]
if isinstance(p, dict):
return uio.BytesIO(p[resource])
return open(p + resource, "rb")
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'wifi_manager',
'microdot',
'utemplate',
'pkg_resources',
],
# Although 'package_data' is the preferred approach, in some case you may
# need to place data files outside of your packages. See:
Expand Down

0 comments on commit f1b00da

Please sign in to comment.