@@ -184,7 +184,7 @@ def patch_standard_packages(self, package_name="", to_movable=True):
184
184
# create movable launchers for previous package installations
185
185
self .patch_all_shebang (to_movable = to_movable )
186
186
if package_name .lower () in ("" , "spyder" ):
187
- # spyder don't goes on internet without I ask
187
+ # spyder don't goes on internet without you ask
188
188
utils .patch_sourcefile (
189
189
Path (self .target ) / "lib" / "site-packages" / "spyder" / "config" / "main.py" ,
190
190
"'check_updates_on_startup': True," ,
@@ -266,27 +266,24 @@ def main(test=False):
266
266
description = "WinPython Package Manager: handle a WinPython Distribution and its packages" ,
267
267
formatter_class = RawTextHelpFormatter ,
268
268
)
269
- parser .add_argument ("fname" , metavar = "package or lockfile" , nargs = "? " , default = "" , type = str , help = "optional package name or package wheel " )
269
+ parser .add_argument ("fname" , metavar = "package(s) or lockfile" , nargs = "* " , default = [ "" ] , type = str , help = "optional package names, wheels, or lockfile " )
270
270
parser .add_argument ("-v" , "--verbose" , action = "store_true" , help = "show more details on packages and actions" )
271
271
parser .add_argument ( "--register" , dest = "registerWinPython" , action = "store_true" , help = registerWinPythonHelp )
272
- # parser.add_argument( "--register_forall", action="store_true", help="Register distribution for all users")
273
272
parser .add_argument ("--unregister" , dest = "unregisterWinPython" , action = "store_true" , help = unregisterWinPythonHelp )
274
- # parser.add_argument( "--unregister_forall", action="store_true", help="un-Register distribution for all users")
275
273
parser .add_argument ("--fix" , action = "store_true" , help = "make WinPython fix" )
276
274
parser .add_argument ("--movable" , action = "store_true" , help = "make WinPython movable" )
277
275
parser .add_argument ("-ws" , dest = "wheelsource" , default = None , type = str , help = "wheels location, '.' = WheelHouse): wppm pylock.toml -ws source_of_wheels, wppm -ls -ws ." )
278
276
parser .add_argument ("-wd" , dest = "wheeldrain" , default = None , type = str , help = "wheels destination: wppm pylock.toml -wd destination_of_wheels" )
279
277
parser .add_argument ("-ls" , "--list" , action = "store_true" , help = "list installed packages matching [optional] expression: wppm -ls, wppm -ls pand" )
280
278
parser .add_argument ("-lsa" , dest = "all" , action = "store_true" ,help = f"list details of packages matching [optional] expression: wppm -lsa pandas -l1" )
281
- parser .add_argument ("-md" , dest = "markdown" , action = "store_true" ,help = f"markdown summary if the installation" )
279
+ parser .add_argument ("-md" , dest = "markdown" , action = "store_true" ,help = f"markdown summary of the installation" )
282
280
parser .add_argument ("-p" ,dest = "pipdown" ,action = "store_true" ,help = "show Package dependencies of the given package[option], [.]=all: wppm -p pandas[.]" )
283
281
parser .add_argument ("-r" , dest = "pipup" , action = "store_true" , help = f"show Reverse wppmdependancies of the given package[option]: wppm -r pytest[test]" )
284
282
parser .add_argument ("-l" , dest = "levels" , type = int , default = 2 , help = "show 'LEVELS' levels of dependencies (with -p, -r), default is 2: wppm -p pandas -l1" )
285
283
parser .add_argument ("-t" , dest = "target" , default = sys .prefix , help = f'path to target Python distribution (default: "{ sys .prefix } ")' )
286
284
parser .add_argument ("-i" , "--install" , action = "store_true" , help = "install a given package wheel or pylock file (use pip for more features)" )
287
285
parser .add_argument ("-u" , "--uninstall" , action = "store_true" , help = "uninstall package (use pip for more features)" )
288
286
289
-
290
287
args = parser .parse_args ()
291
288
targetpython = None
292
289
if args .target and args .target != sys .prefix :
@@ -301,35 +298,40 @@ def main(test=False):
301
298
raise RuntimeError ("Incompatible arguments: --install and --uninstall" )
302
299
if args .pipdown :
303
300
pip = piptree .PipData (targetpython , args .wheelsource )
304
- pack , extra , * other = (args .fname + "[" ).replace ("]" , "[" ).split ("[" )
305
- print (pip .down (pack , extra , args .levels , verbose = args .verbose ))
301
+ for args_fname in args .fname :
302
+ pack , extra , * other = (args_fname + "[" ).replace ("]" , "[" ).split ("[" )
303
+ print (pip .down (pack , extra , args .levels , verbose = args .verbose ))
306
304
sys .exit ()
307
305
elif args .pipup :
308
306
pip = piptree .PipData (targetpython , args .wheelsource )
309
- pack , extra , * other = (args .fname + "[" ).replace ("]" , "[" ).split ("[" )
310
- print (pip .up (pack , extra , args .levels , verbose = args .verbose ))
307
+ for args_fname in args .fname :
308
+ pack , extra , * other = (args_fname + "[" ).replace ("]" , "[" ).split ("[" )
309
+ print (pip .up (pack , extra , args .levels , verbose = args .verbose ))
311
310
sys .exit ()
312
311
elif args .list :
313
312
pip = piptree .PipData (targetpython , args .wheelsource )
314
- todo = [l for l in pip .pip_list (full = True ) if bool (re .search (args .fname , l [0 ]))]
313
+ todo = []
314
+ for args_fname in args .fname :
315
+ todo += [l for l in pip .pip_list (full = True ) if bool (re .search (args_fname , l [0 ]))]
316
+ todo = sorted (set (todo )) #, key=lambda p: (p[0].lower(), p[2])
315
317
titles = [['Package' , 'Version' , 'Summary' ], ['_' * max (x , 6 ) for x in utils .columns_width (todo )]]
316
318
listed = utils .formatted_list (titles + todo , max_width = 70 )
317
319
for p in listed :
318
320
print (* p )
319
321
sys .exit ()
320
322
elif args .all :
321
323
pip = piptree .PipData (targetpython , args .wheelsource )
322
- todo = [ l for l in pip . pip_list ( full = True ) if bool ( re . search ( args .fname , l [ 0 ]))]
323
- for l in todo :
324
- # print(pip.distro[l[0]])
325
- title = f"** Package: { l [0 ]} **"
326
- print ("\n " + "*" * len (title ), f"\n { title } " , "\n " + "*" * len (title ))
327
- for key , value in pip .raw [l [0 ]].items ():
328
- rawtext = json .dumps (value , indent = 2 , ensure_ascii = False )
329
- lines = [l for l in rawtext .split (r"\n" ) if len (l .strip ()) > 2 ]
330
- if key .lower () != 'description' or args .verbose :
331
- print (f"{ key } : " , "\n " .join (lines ).replace ('"' , "" ))
332
- sys .exit ()
324
+ for args_fname in args .fname :
325
+ todo = [ l for l in pip . pip_list ( full = True ) if bool ( re . search ( args_fname , l [ 0 ]))]
326
+ for l in sorted ( set ( todo )):
327
+ title = f"** Package: { l [0 ]} **"
328
+ print ("\n " + "*" * len (title ), f"\n { title } " , "\n " + "*" * len (title ))
329
+ for key , value in pip .raw [l [0 ]].items ():
330
+ rawtext = json .dumps (value , indent = 2 , ensure_ascii = False )
331
+ lines = [l for l in rawtext .split (r"\n" ) if len (l .strip ()) > 2 ]
332
+ if key .lower () != 'description' or args .verbose :
333
+ print (f"{ key } : " , "\n " .join (lines ).replace ('"' , "" ))
334
+ sys .exit ()
333
335
if args .registerWinPython :
334
336
print (registerWinPythonHelp )
335
337
if utils .is_python_distribution (args .target ):
@@ -373,26 +375,27 @@ def main(test=False):
373
375
else :
374
376
print (default )
375
377
sys .exit ()
376
- if not args .install and not args .uninstall and args .fname .endswith (".toml" ):
378
+ if not args .install and not args .uninstall and args .fname [ 0 ] .endswith (".toml" ):
377
379
args .install = True # for Drag & Drop of .toml (and not wheel)
378
- if args .fname == "" or (not args .install and not args .uninstall ):
380
+ if args .fname [ 0 ] == "" or (not args .install and not args .uninstall ):
379
381
parser .print_help ()
380
382
sys .exit ()
381
383
else :
382
384
try :
383
- filename = Path (args .fname ).name
384
- install_from_wheelhouse = ["--no-index" , "--trusted-host=None" , f"--find-links={ dist .wheelhouse / 'included.wheels' } " ]
385
- if filename .split ('.' )[0 ] == "pylock" and filename .split ('.' )[- 1 ] == 'toml' :
386
- print (' a lock file !' , args .fname , dist .target )
387
- wh .get_pylock_wheels (dist .wheelhouse , Path (args .fname ), args .wheelsource , args .wheeldrain )
388
- sys .exit ()
389
- if args .uninstall :
390
- package = dist .find_package (args .fname )
391
- dist .uninstall (package )
392
- elif args .install :
393
- package = Package (args .fname )
394
- if args .install :
395
- dist .install (package , install_options = install_from_wheelhouse )
385
+ for args_fname in args .fname :
386
+ filename = Path (args_fname ).name
387
+ install_from_wheelhouse = ["--no-index" , "--trusted-host=None" , f"--find-links={ dist .wheelhouse / 'included.wheels' } " ]
388
+ if filename .split ('.' )[0 ] == "pylock" and filename .split ('.' )[- 1 ] == 'toml' :
389
+ print (' a lock file !' , args_fname , dist .target )
390
+ wh .get_pylock_wheels (dist .wheelhouse , Path (args_fname ), args .wheelsource , args .wheeldrain )
391
+ sys .exit ()
392
+ if args .uninstall :
393
+ package = dist .find_package (args_fname )
394
+ dist .uninstall (package )
395
+ elif args .install :
396
+ package = Package (args_fname )
397
+ if args .install :
398
+ dist .install (package , install_options = install_from_wheelhouse )
396
399
except NotImplementedError :
397
400
raise RuntimeError ("Package is not (yet) supported by WPPM" )
398
401
else :
0 commit comments