@@ -155,20 +155,22 @@ def is_compatible_with(self, distribution):
155155 iscomp = iscomp and self .pyversion == distribution .version
156156 return iscomp
157157
158- def extract_optional_infos (self , update = False ):
158+ def extract_optional_infos (self , update = False , suggested_summary = None ):
159159 """Extract package optional infos (description, url)
160160 from the package database"""
161161 metadata = get_package_metadata ("packages.ini" , self .name , True , update = update )
162162 for key , value in list (metadata .items ()):
163163 setattr (self , key , value )
164+ if suggested_summary and suggested_summary != "" :
165+ setattr (self , 'description' ,suggested_summary )
164166
165167
166168class Package (BasePackage ):
167- def __init__ (self , fname , update = False ):
169+ def __init__ (self , fname , update = False , suggested_summary = None ):
168170 BasePackage .__init__ (self , fname )
169171 self .files = []
170172 self .extract_infos ()
171- self .extract_optional_infos (update = update )
173+ self .extract_optional_infos (update = update , suggested_summary = suggested_summary )
172174
173175 def extract_infos (self ):
174176 """Extract package infos (name, version, architecture)
@@ -245,6 +247,7 @@ def __init__(self, target=None, verbose=False, indent=False):
245247 self .target = target
246248 self .verbose = verbose
247249 self .indent = indent
250+ self .pip = None
248251
249252 # if no target path given, take the current python interpreter one
250253 if self .target is None :
@@ -340,33 +343,33 @@ def get_installed_packages(self, update=False):
340343
341344 # Include package installed via pip (not via WPPM)
342345 wppm = []
343- try :
346+ try : # we try to use also 'pip inspect' via piptree (work for pip>= 22.2)
344347 if str (Path (sys .executable ).parent ) == self .target :
345- # win pip 22.2, we can use pip inspect API
346- pip = piptree .pipdata ()
347- pip_list = pip .pip_list ()
348+ self .pip = piptree .pipdata ()
348349 else :
349- # indirect way: we use pip list (for now)
350- cmdx = [
351- utils .get_python_executable (self .target ), # PyPy !
352- "-m" ,
353- "pip" ,
354- "list" ,
355- ]
356- pip_list_raw = utils .exec_run_cmd (cmdx ).splitlines ()
357- # pip list gives 2 lines of titles to ignore
358- pip_list = [l .split () for l in pip_list_raw [2 :]]
359- # there are only Packages installed with pip now
360- # create pip package list
361- wppm = [
362- Package (
363- f"{ i [0 ].replace ('-' , '_' ).lower ()} -{ i [1 ]} -py2.py3-none-any.whl" ,
364- update = update ,
365- )
366- for i in pip_list
367- ]
350+ self .pip = piptree .pipdata (Target = utils .get_python_executable (self .target ))
351+ pip_list = self .pip .pip_list ()
368352 except :
369- pass
353+ # if failure back to pip list (will use packages.ini for names)
354+ cmdx = [
355+ utils .get_python_executable (self .target ), # PyPy !
356+ "-m" ,
357+ "pip" ,
358+ "list" ,
359+ ]
360+ pip_list_raw = utils .exec_run_cmd (cmdx ).splitlines ()
361+ # pip list gives 2 lines of titles to ignore
362+ pip_list = [l .split () for l in pip_list_raw [2 :]]
363+
364+ # create pip package list
365+ wppm = [
366+ Package (
367+ f"{ i [0 ].replace ('-' , '_' ).lower ()} -{ i [1 ]} -py3-none-any.whl" ,
368+ update = update ,
369+ suggested_summary = self .pip .summary (i [0 ]) if self .pip else None
370+ )
371+ for i in pip_list
372+ ]
370373 return sorted (wppm , key = lambda tup : tup .name .lower ())
371374
372375 def find_package (self , name ):
@@ -842,8 +845,8 @@ def main(test=False):
842845 args = parser .parse_args ()
843846 targetpython = None
844847 if args .target and not args .target == sys .prefix :
845- targetpython = args .target if args .target [- 4 :] == '.exe' else args .target + r'\ python.exe'
846- # print(targetpython)
848+ targetpython = args .target if args .target [- 4 :] == '.exe' else str ( Path ( args .target ) / ' python.exe')
849+ # print(targetpython.resolve() to check )
847850 if args .install and args .uninstall :
848851 raise RuntimeError ("Incompatible arguments: --install and --uninstall" )
849852 if args .registerWinPython and args .unregisterWinPython :
0 commit comments