Skip to content

Commit

Permalink
Merge pull request micropython#94 from wnienhaus/mip_support
Browse files Browse the repository at this point in the history
Add package.json for MIP package manager
  • Loading branch information
wnienhaus authored Sep 6, 2023
2 parents 25bf34e + 4e2bbe4 commit 74d2f79
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ To get going run the following directly on the ESP32:

.. code-block:: python
# Step 1: Install micropython-esp32-ulp
# IMPORTANT: Ensure the ESP32 is connected to a network with internet connectivity.
# Step 1: Install micropython-esp32-ulp (for MicroPython v1.20 or newer)
import mip
mip.install('github:micropython/micropython-esp32-ulp')
# Step 1: Install micropython-esp32-ulp (for MicroPython older than v1.20)
import upip
upip.install('micropython-esp32-ulp')
Expand Down
10 changes: 8 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ Overview
Installation
------------

On the ESP32, install using upip:
On the ESP32, install using mip (or upip on older MicroPythons):

.. code-block:: python
# ensure the ESP32 is connected to a network with internet connectivity
# step 1: ensure the ESP32 is connected to a network with internet connectivity
# step 2 (for MicroPython 1.20 or newer)
import mip
mip.install('github:micropython/micropython-esp32-ulp')
# step 2 (for MicroPython older than 1.20)
import upip
upip.install('micropython-esp32-ulp')
Expand Down
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"v":1,
"urls":[
["esp32_ulp/__init__.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/__init__.py"],
["esp32_ulp/__main__.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/__main__.py"],
["esp32_ulp/assemble.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/assemble.py"],
["esp32_ulp/definesdb.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/definesdb.py"],
["esp32_ulp/link.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/link.py"],
["esp32_ulp/nocomment.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/nocomment.py"],
["esp32_ulp/opcodes.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/opcodes.py"],
["esp32_ulp/opcodes_s2.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/opcodes_s2.py"],
["esp32_ulp/parse_to_db.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/parse_to_db.py"],
["esp32_ulp/preprocess.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/preprocess.py"],
["esp32_ulp/soc.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/soc.py"],
["esp32_ulp/soc_s2.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/soc_s2.py"],
["esp32_ulp/soc_s3.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/soc_s3.py"],
["esp32_ulp/util.py", "github:micropython/micropython-esp32-ulp/esp32_ulp/util.py"]
]
}
50 changes: 50 additions & 0 deletions tools/genpkgjson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
Tool for generating package.json for the MIP package manager
Run this tool from the repo root, like:
python tools/genpkgjson.py > package.json
Note:
This tool works with both python3 and micropyton.
"""

import os
import json

PACKAGE_JSON_VERSION=1

# Update the repo when working with a fork
GITHUB_REPO="micropython/micropython-esp32-ulp"


def get_files(path):
files = [f'{path}/{f}' for f in os.listdir(path)]
return files


def build_urls(repo_base, files):
return [[f, f'github:{repo_base}/{f}'] for f in files]


def print_package_json(urls):
"""
Custom-formatting JSON output for better readability
json.dumps in MicroPython cannot format the output and python3
puts each element of each urls' sub-arrays onto a new line.
Here we print each file and its source url onto the same line.
"""
print('{')
print(f' "v":{PACKAGE_JSON_VERSION},')
print(' "urls":[')
print(',\n'.join([f' {json.dumps(u)}' for u in sorted(urls)]))
print(' ]')
print('}')


if __name__ == '__main__':
library_root = 'esp32_ulp'
files = get_files(library_root)
urls = build_urls(GITHUB_REPO, files)
print_package_json(urls)

0 comments on commit 74d2f79

Please sign in to comment.