kopia lustrzana https://github.com/micropython/micropython-lib
upip: Don't parse MICROPYPATH, just use sys.path[1] as set by micropython.
Makes POSIX and baremetal behavior simpler and more consistent.pull/107/merge
rodzic
1ca07881e3
commit
47a6633a31
23
upip/upip.py
23
upip/upip.py
|
@ -6,8 +6,6 @@ import uzlib
|
||||||
import upip_utarfile as tarfile
|
import upip_utarfile as tarfile
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_MICROPYPATH = "~/.micropython/lib:/usr/lib/micropython"
|
|
||||||
|
|
||||||
debug = False
|
debug = False
|
||||||
install_path = None
|
install_path = None
|
||||||
cleanup_files = []
|
cleanup_files = []
|
||||||
|
@ -191,13 +189,9 @@ def install(to_install, install_path=None):
|
||||||
|
|
||||||
def get_install_path():
|
def get_install_path():
|
||||||
global install_path
|
global install_path
|
||||||
if install_path is None:
|
|
||||||
if hasattr(os, "getenv"):
|
|
||||||
install_path = os.getenv("MICROPYPATH")
|
|
||||||
if install_path is None:
|
if install_path is None:
|
||||||
# sys.path[0] is current module's path
|
# sys.path[0] is current module's path
|
||||||
install_path = sys.path[1]
|
install_path = sys.path[1]
|
||||||
install_path = install_path.split(":", 1)[0]
|
|
||||||
install_path = expandhome(install_path)
|
install_path = expandhome(install_path)
|
||||||
return install_path
|
return install_path
|
||||||
|
|
||||||
|
@ -213,11 +207,15 @@ def help():
|
||||||
upip - Simple PyPI package manager for MicroPython
|
upip - Simple PyPI package manager for MicroPython
|
||||||
Usage: micropython -m upip install [-p <path>] <package>... | -r <requirements.txt>
|
Usage: micropython -m upip install [-p <path>] <package>... | -r <requirements.txt>
|
||||||
|
|
||||||
If -p is not given, packages will be installed to first path component of
|
If <path> is not given, packages will be installed into sys.path[1]
|
||||||
MICROPYPATH, or to ~/.micropython/lib/ by default.
|
(can be set from MICROPYPATH environment variable, if current system
|
||||||
Note: only MicroPython packages (usually, micropython-*) are supported for
|
supports that).""")
|
||||||
installation, upip does not support arbitrary code in setup.py.""")
|
print("Current value of sys.path[1]:", sys.path[1])
|
||||||
sys.exit(1)
|
print("""\
|
||||||
|
|
||||||
|
Note: only MicroPython packages (usually, named micropython-*) are supported
|
||||||
|
for installation, upip does not support arbitrary code in setup.py.
|
||||||
|
""")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global debug
|
global debug
|
||||||
|
@ -226,6 +224,7 @@ def main():
|
||||||
|
|
||||||
if len(sys.argv) < 2 or sys.argv[1] == "-h" or sys.argv[1] == "--help":
|
if len(sys.argv) < 2 or sys.argv[1] == "-h" or sys.argv[1] == "--help":
|
||||||
help()
|
help()
|
||||||
|
return
|
||||||
|
|
||||||
if sys.argv[1] != "install":
|
if sys.argv[1] != "install":
|
||||||
fatal("Only 'install' command supported")
|
fatal("Only 'install' command supported")
|
||||||
|
@ -238,6 +237,7 @@ def main():
|
||||||
i += 1
|
i += 1
|
||||||
if opt == "-h" or opt == "--help":
|
if opt == "-h" or opt == "--help":
|
||||||
help()
|
help()
|
||||||
|
return
|
||||||
elif opt == "-p":
|
elif opt == "-p":
|
||||||
install_path = sys.argv[i]
|
install_path = sys.argv[i]
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -258,6 +258,7 @@ def main():
|
||||||
to_install.extend(sys.argv[i:])
|
to_install.extend(sys.argv[i:])
|
||||||
if not to_install:
|
if not to_install:
|
||||||
help()
|
help()
|
||||||
|
return
|
||||||
|
|
||||||
install(to_install)
|
install(to_install)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue