Skip to content

Commit

Permalink
Merge pull request #491 from shorepine/mipweb
Browse files Browse the repository at this point in the history
MIP
  • Loading branch information
bwhitman authored Feb 5, 2025
2 parents 78985eb + c096bc5 commit f3590a4
Show file tree
Hide file tree
Showing 23 changed files with 300 additions and 197 deletions.
1 change: 1 addition & 0 deletions tulip/esp32s3/boards/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
freeze("$(PORT_DIR)/modules", "inisetup.py")
freeze("$(PORT_DIR)/modules", "espnow.py")
freeze("$(PORT_DIR)/modules", "flashbdev.py")
require("bundle-networking")

include("$(MPY_DIR)/extmod/asyncio")

Expand Down
2 changes: 1 addition & 1 deletion tulip/linux/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#endif

#ifndef MICROPY_PY_SYS_PATH_DEFAULT
#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:/usr/lib/micropython"
#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen"
#endif

#define MP_STATE_PORT MP_STATE_VM
Expand Down
1 change: 1 addition & 0 deletions tulip/linux/variants/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
freeze("$(MPY_DIR)/../amy", "juno.py")
freeze("$(MPY_DIR)/../amy", "amy_wave.py")
freeze("$(MPY_DIR)/../amy", "amy_constants.py")
require("bundle-networking")

2 changes: 1 addition & 1 deletion tulip/macos/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#endif

#ifndef MICROPY_PY_SYS_PATH_DEFAULT
#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:/usr/lib/micropython"
#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen"
#endif

#define MP_STATE_PORT MP_STATE_VM
Expand Down
2 changes: 2 additions & 0 deletions tulip/macos/variants/manifest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

include("$(MPY_DIR)/extmod/asyncio")
freeze("$(MPY_DIR)/../tulip/shared/py")
freeze("$(MPY_DIR)/../amy", "amy.py")
freeze("$(MPY_DIR)/../amy", "juno.py")
freeze("$(MPY_DIR)/../amy", "amy_wave.py")
freeze("$(MPY_DIR)/../amy", "amy_constants.py")
require("bundle-networking")

16 changes: 16 additions & 0 deletions tulip/shared/py/_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ def webnyi():
# Probably iOS
cd(tulip.app_path())

# Make sure user/lib exists and add it to sys.path
libdir = tulip.root_dir()+"user/lib"
if(not tulip.exists(libdir)):
mkdir(libdir)
sys.path.append(libdir)

# Remove other ones
try:
sys.path.remove('/lib')
except ValueError:
pass
try:
sys.path.remove('~/.micropython/lib')
except ValueError:
pass

gc.collect()

# Set up audio/midi.
Expand Down
10 changes: 6 additions & 4 deletions tulip/shared/py/tulip.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ def get_latest_release():
return (None, None, None, None)

def upgrade():
import time, sys, os, urequests
import time, sys, os
import tuliprequests as urequests
try:
import esp32, machine
from esp32 import Partition
Expand Down Expand Up @@ -602,7 +603,7 @@ def next(x):
return "OK"
return world_web.grab_bytes_direct(url, headers=headers).then(lambda x: next(x))
else:
import urequests
import tuliprequests as urequests
d = urequests.get(url, headers = headers).save(filename,mode)
return d

Expand All @@ -611,15 +612,16 @@ def url_get(url, headers={"User-Agent":"TulipCC/4.0"}):
import world_web
return world_web.grab_bytes_direct(url, headers=headers)
else:
import urequests
import tuliprequests as urequests
c = urequests.get(url, headers = headers)
return c


def url_put(url, filename, headers={"User-Agent":"TulipCC/4.0"}):
if(board()=="WEB"):
return webnyi()
import urequests, os
import os
import tuliprequests as urequests
filesize = os.stat(filename)[6]
f = open(filename, 'rb')
put_response = urequests.put(
Expand Down
File renamed without changes.
153 changes: 0 additions & 153 deletions tulip/shared/py/webrequests.py

This file was deleted.

2 changes: 1 addition & 1 deletion tulip/shared/py/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import tulip
if(tulip.board()!="WEB"):
import urequests as requests
import tuliprequests as urequests

MAX_DESCRIPTION_SIZE=50
MAX_USERNAME_SIZE=10
Expand Down
3 changes: 3 additions & 0 deletions tulip/web/mipweb/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
metadata(version="0.3.1", description="On-device package installer for network-capable boards")

package("mipweb", opt=3)
Loading

0 comments on commit f3590a4

Please sign in to comment.