kopia lustrzana https://github.com/micropython/micropython-lib
upip: Remove unneed cruft.
upip now works only with MicroPython, and the only Py-level dependency is upip_utarfile.pull/106/head
rodzic
62671a4795
commit
cbc423ae41
36
upip/upip.py
36
upip/upip.py
|
@ -1,28 +1,9 @@
|
||||||
def upip_import(mod, sub=None):
|
import sys
|
||||||
try:
|
|
||||||
mod_ = mod
|
|
||||||
if sub:
|
|
||||||
mod_ += "_" + sub
|
|
||||||
return __import__("upip_" + mod_)
|
|
||||||
except ImportError:
|
|
||||||
m = __import__(mod)
|
|
||||||
if sub:
|
|
||||||
return getattr(m, sub)
|
|
||||||
return m
|
|
||||||
|
|
||||||
sys = upip_import("sys")
|
|
||||||
import uos as os
|
import uos as os
|
||||||
import uerrno as errno
|
import uerrno as errno
|
||||||
|
import ujson as json
|
||||||
import uzlib
|
import uzlib
|
||||||
|
import upip_utarfile as tarfile
|
||||||
try:
|
|
||||||
tarfile = upip_import("utarfile")
|
|
||||||
except ImportError:
|
|
||||||
tarfile = upip_import("tarfile")
|
|
||||||
try:
|
|
||||||
json = upip_import("ujson")
|
|
||||||
except ImportError:
|
|
||||||
json = upip_import("json")
|
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_MICROPYPATH = "~/.micropython/lib:/usr/lib/micropython"
|
DEFAULT_MICROPYPATH = "~/.micropython/lib:/usr/lib/micropython"
|
||||||
|
@ -168,17 +149,6 @@ def fatal(msg):
|
||||||
print(msg)
|
print(msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def gzdecompress(package_fname):
|
|
||||||
f = open(package_fname, "rb")
|
|
||||||
zipdata = f.read()
|
|
||||||
data = gzip.decompress(zipdata)
|
|
||||||
return data
|
|
||||||
|
|
||||||
def gzdecompress_(package_fname):
|
|
||||||
os.system("gzip -d -c %s > ungz" % package_fname)
|
|
||||||
with open("ungz", "rb") as f:
|
|
||||||
return f.read()
|
|
||||||
|
|
||||||
def install_pkg(pkg_spec, install_path):
|
def install_pkg(pkg_spec, install_path):
|
||||||
data = get_pkg_metadata(pkg_spec)
|
data = get_pkg_metadata(pkg_spec)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue