Skip to content

Commit 74d2f79

Browse files
authored
Merge pull request #94 from wnienhaus/mip_support
Add package.json for MIP package manager
2 parents 25bf34e + 4e2bbe4 commit 74d2f79

File tree

4 files changed

+83
-3
lines changed

4 files changed

+83
-3
lines changed

README.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ To get going run the following directly on the ESP32:
6262

6363
.. code-block:: python
6464
65-
# Step 1: Install micropython-esp32-ulp
6665
# IMPORTANT: Ensure the ESP32 is connected to a network with internet connectivity.
66+
67+
# Step 1: Install micropython-esp32-ulp (for MicroPython v1.20 or newer)
68+
import mip
69+
mip.install('github:micropython/micropython-esp32-ulp')
70+
71+
# Step 1: Install micropython-esp32-ulp (for MicroPython older than v1.20)
6772
import upip
6873
upip.install('micropython-esp32-ulp')
6974

docs/index.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ Overview
1313
Installation
1414
------------
1515

16-
On the ESP32, install using upip:
16+
On the ESP32, install using mip (or upip on older MicroPythons):
1717

1818
.. code-block:: python
1919
20-
# ensure the ESP32 is connected to a network with internet connectivity
20+
# step 1: ensure the ESP32 is connected to a network with internet connectivity
21+
22+
# step 2 (for MicroPython 1.20 or newer)
23+
import mip
24+
mip.install('github:micropython/micropython-esp32-ulp')
25+
26+
# step 2 (for MicroPython older than 1.20)
2127
import upip
2228
upip.install('micropython-esp32-ulp')
2329

package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"v":1,
3+
"urls":[
4+
["esp32_ulp/__init__.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/__init__.py"],
5+
["esp32_ulp/__main__.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/__main__.py"],
6+
["esp32_ulp/assemble.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/assemble.py"],
7+
["esp32_ulp/definesdb.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/definesdb.py"],
8+
["esp32_ulp/link.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/link.py"],
9+
["esp32_ulp/nocomment.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/nocomment.py"],
10+
["esp32_ulp/opcodes.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/opcodes.py"],
11+
["esp32_ulp/opcodes_s2.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/opcodes_s2.py"],
12+
["esp32_ulp/parse_to_db.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/parse_to_db.py"],
13+
["esp32_ulp/preprocess.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/preprocess.py"],
14+
["esp32_ulp/soc.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/soc.py"],
15+
["esp32_ulp/soc_s2.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/soc_s2.py"],
16+
["esp32_ulp/soc_s3.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/soc_s3.py"],
17+
["esp32_ulp/util.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/util.py"]
18+
]
19+
}

tools/genpkgjson.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Tool for generating package.json for the MIP package manager
3+
4+
Run this tool from the repo root, like:
5+
6+
python tools/genpkgjson.py > package.json
7+
8+
Note:
9+
This tool works with both python3 and micropyton.
10+
"""
11+
12+
import os
13+
import json
14+
15+
PACKAGE_JSON_VERSION=1
16+
17+
# Update the repo when working with a fork
18+
GITHUB_REPO="micropython/micropython-esp32-ulp"
19+
20+
21+
def get_files(path):
22+
files = [f'{path}/{f}' for f in os.listdir(path)]
23+
return files
24+
25+
26+
def build_urls(repo_base, files):
27+
return [[f, f'github:{repo_base}/{f}'] for f in files]
28+
29+
30+
def print_package_json(urls):
31+
"""
32+
Custom-formatting JSON output for better readability
33+
34+
json.dumps in MicroPython cannot format the output and python3
35+
puts each element of each urls' sub-arrays onto a new line.
36+
Here we print each file and its source url onto the same line.
37+
"""
38+
print('{')
39+
print(f' "v":{PACKAGE_JSON_VERSION},')
40+
print(' "urls":[')
41+
print(',\n'.join([f' {json.dumps(u)}' for u in sorted(urls)]))
42+
print(' ]')
43+
print('}')
44+
45+
46+
if __name__ == '__main__':
47+
library_root = 'esp32_ulp'
48+
files = get_files(library_root)
49+
urls = build_urls(GITHUB_REPO, files)
50+
print_package_json(urls)

0 commit comments

Comments
 (0)