Skip to content

Commit 47a6633

Browse files
committed
upip: Don't parse MICROPYPATH, just use sys.path[1] as set by micropython.
Makes POSIX and baremetal behavior simpler and more consistent.
1 parent 1ca0788 commit 47a6633

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

upip/upip.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import upip_utarfile as tarfile
77

88

9-
DEFAULT_MICROPYPATH = "~/.micropython/lib:/usr/lib/micropython"
10-
119
debug = False
1210
install_path = None
1311
cleanup_files = []
@@ -192,12 +190,8 @@ def install(to_install, install_path=None):
192190
def get_install_path():
193191
global install_path
194192
if install_path is None:
195-
if hasattr(os, "getenv"):
196-
install_path = os.getenv("MICROPYPATH")
197-
if install_path is None:
198-
# sys.path[0] is current module's path
199-
install_path = sys.path[1]
200-
install_path = install_path.split(":", 1)[0]
193+
# sys.path[0] is current module's path
194+
install_path = sys.path[1]
201195
install_path = expandhome(install_path)
202196
return install_path
203197

@@ -213,11 +207,15 @@ def help():
213207
upip - Simple PyPI package manager for MicroPython
214208
Usage: micropython -m upip install [-p <path>] <package>... | -r <requirements.txt>
215209
216-
If -p is not given, packages will be installed to first path component of
217-
MICROPYPATH, or to ~/.micropython/lib/ by default.
218-
Note: only MicroPython packages (usually, micropython-*) are supported for
219-
installation, upip does not support arbitrary code in setup.py.""")
220-
sys.exit(1)
210+
If <path> is not given, packages will be installed into sys.path[1]
211+
(can be set from MICROPYPATH environment variable, if current system
212+
supports that).""")
213+
print("Current value of sys.path[1]:", sys.path[1])
214+
print("""\
215+
216+
Note: only MicroPython packages (usually, named micropython-*) are supported
217+
for installation, upip does not support arbitrary code in setup.py.
218+
""")
221219

222220
def main():
223221
global debug
@@ -226,6 +224,7 @@ def main():
226224

227225
if len(sys.argv) < 2 or sys.argv[1] == "-h" or sys.argv[1] == "--help":
228226
help()
227+
return
229228

230229
if sys.argv[1] != "install":
231230
fatal("Only 'install' command supported")
@@ -238,6 +237,7 @@ def main():
238237
i += 1
239238
if opt == "-h" or opt == "--help":
240239
help()
240+
return
241241
elif opt == "-p":
242242
install_path = sys.argv[i]
243243
i += 1
@@ -258,6 +258,7 @@ def main():
258258
to_install.extend(sys.argv[i:])
259259
if not to_install:
260260
help()
261+
return
261262

262263
install(to_install)
263264

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy