6
6
import upip_utarfile as tarfile
7
7
8
8
9
- DEFAULT_MICROPYPATH = "~/.micropython/lib:/usr/lib/micropython"
10
-
11
9
debug = False
12
10
install_path = None
13
11
cleanup_files = []
@@ -192,12 +190,8 @@ def install(to_install, install_path=None):
192
190
def get_install_path ():
193
191
global install_path
194
192
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 ]
201
195
install_path = expandhome (install_path )
202
196
return install_path
203
197
@@ -213,11 +207,15 @@ def help():
213
207
upip - Simple PyPI package manager for MicroPython
214
208
Usage: micropython -m upip install [-p <path>] <package>... | -r <requirements.txt>
215
209
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
+ """ )
221
219
222
220
def main ():
223
221
global debug
@@ -226,6 +224,7 @@ def main():
226
224
227
225
if len (sys .argv ) < 2 or sys .argv [1 ] == "-h" or sys .argv [1 ] == "--help" :
228
226
help ()
227
+ return
229
228
230
229
if sys .argv [1 ] != "install" :
231
230
fatal ("Only 'install' command supported" )
@@ -238,6 +237,7 @@ def main():
238
237
i += 1
239
238
if opt == "-h" or opt == "--help" :
240
239
help ()
240
+ return
241
241
elif opt == "-p" :
242
242
install_path = sys .argv [i ]
243
243
i += 1
@@ -258,6 +258,7 @@ def main():
258
258
to_install .extend (sys .argv [i :])
259
259
if not to_install :
260
260
help ()
261
+ return
261
262
262
263
install (to_install )
263
264
0 commit comments