@@ -26,14 +26,12 @@ class Package:
2626 def __init__ (self , fname , suggested_summary = None ):
2727 self .fname = fname
2828 self .description = piptree .sum_up (suggested_summary ) if suggested_summary else ""
29- self .name = None
30- self .version = None
29+ self .name , self .version = None , None
3130 if fname .endswith ((".zip" , ".tar.gz" , ".whl" )):
3231 bname = Path (self .fname ).name #wheel style name like "sqlite_bro-1.0.0..."
3332 infos = utils .get_source_package_infos (bname ) # get name, version
34- if infos is not None :
35- self .name , self .version = infos
36- self .name = utils .normalize (self .name )
33+ if infos :
34+ self .name , self .version = utils .normalize (infos [0 ]), infos [1 ]
3735 self .url = f"https://pypi.org/project/{ self .name } "
3836 self .files = []
3937
@@ -67,14 +65,7 @@ def remove_directory(self, path):
6765 except WindowsError :
6866 self .to_be_removed .append (path )
6967
70- def copy_files (
71- self ,
72- package ,
73- targetdir ,
74- srcdir ,
75- dstdir ,
76- create_bat_files = False ,
77- ):
68+ def copy_files (self , package , targetdir , srcdir , dstdir , create_bat_files = False ):
7869 """Add copy task"""
7970 srcdir = str (Path (targetdir ) / srcdir )
8071 if not Path (srcdir ).is_dir ():
@@ -148,29 +139,16 @@ def find_package(self, name):
148139 if utils .normalize (pack .name ) == utils .normalize (name ):
149140 return pack
150141
151- def patch_all_shebang (
152- self ,
153- to_movable = True ,
154- max_exe_size = 999999 ,
155- targetdir = "" ,
156- ):
142+ def patch_all_shebang (self , to_movable = True , max_exe_size = 999999 , targetdir = "" ):
157143 """make all python launchers relatives"""
158144 import glob
159145
160146 for ffname in glob .glob (r"%s\Scripts\*.exe" % self .target ):
161147 size = os .path .getsize (ffname )
162148 if size <= max_exe_size :
163- utils .patch_shebang_line (
164- ffname ,
165- to_movable = to_movable ,
166- targetdir = targetdir ,
167- )
149+ utils .patch_shebang_line (ffname , to_movable = to_movable , targetdir = targetdir )
168150 for ffname in glob .glob (r"%s\Scripts\*.py" % self .target ):
169- utils .patch_shebang_line_py (
170- ffname ,
171- to_movable = to_movable ,
172- targetdir = targetdir ,
173- )
151+ utils .patch_shebang_line_py (ffname , to_movable = to_movable , targetdir = targetdir )
174152
175153 def install (self , package , install_options = None ):
176154 """Install package in distribution"""
@@ -187,27 +165,12 @@ def do_pip_action(self, actions=None, install_options=None):
187165 my_actions = actions or []
188166 executing = str (Path (self .target ).parent / "scripts" / "env.bat" )
189167 if Path (executing ).is_file ():
190- complement = [
191- r"&&" ,
192- "cd" ,
193- "/D" ,
194- self .target ,
195- r"&&" ,
196- utils .get_python_executable (self .target ),
197- # Before PyPy: osp.join(self.target, 'python.exe')
198- ]
199- complement += ["-m" , "pip" ]
168+ complement = [r"&&" , "cd" , "/D" , self .target , r"&&" , utils .get_python_executable (self .target )]
200169 else :
201170 executing = utils .get_python_executable (self .target )
202- # Before PyPy: osp.join(self.target, 'python.exe')
203- complement = ["-m" , "pip" ]
171+ complement = ["-m" , "pip" ]
204172 try :
205- fname = utils .do_script (
206- this_script = None ,
207- python_exe = executing ,
208- verbose = self .verbose ,
209- install_options = complement + my_actions + my_list ,
210- )
173+ fname = utils .do_script (this_script = None , python_exe = executing , verbose = self .verbose , install_options = complement + my_actions + my_list )
211174 except RuntimeError :
212175 if not self .verbose :
213176 print ("Failed!" )
@@ -306,31 +269,14 @@ def create_pybat(
306269
307270 def handle_specific_packages (self , package ):
308271 """Packages requiring additional configuration"""
309- if package .name .lower () in (
310- "pyqt4" ,
311- "pyqt5" ,
312- "pyside2" ,
313- ):
272+ if package .name .lower () in ("pyqt4" , "pyqt5" , "pyside2" ):
314273 # Qt configuration file (where to find Qt)
315274 name = "qt.conf"
316275 contents = """[Paths]
317276Prefix = .
318277Binaries = ."""
319- self .create_file (
320- package ,
321- name ,
322- str (Path ("Lib" ) / "site-packages" / package .name ),
323- contents ,
324- )
325- self .create_file (
326- package ,
327- name ,
328- "." ,
329- contents .replace (
330- "." ,
331- f"./Lib/site-packages/{ package .name } " ,
332- ),
333- )
278+ self .create_file (package , name , str (Path ("Lib" ) / "site-packages" / package .name ), contents )
279+ self .create_file (package , name , "." , contents .replace ("." , f"./Lib/site-packages/{ package .name } " ))
334280 # pyuic script
335281 if package .name .lower () == "pyqt5" :
336282 # see http://code.activestate.com/lists/python-list/666469/
@@ -344,27 +290,15 @@ def handle_specific_packages(self, package):
344290 # PyPy adaption: python.exe or pypy3.exe
345291 my_exec = Path (utils .get_python_executable (self .target )).name
346292 tmp_string = tmp_string .replace ("python.exe" , my_exec )
347-
348- self .create_file (
349- package ,
350- f"pyuic{ package .name [- 1 ]} .bat" ,
351- "Scripts" ,
352- tmp_string .replace ("package.name" , package .name ),
353- )
293+ self .create_file (package , f"pyuic{ package .name [- 1 ]} .bat" , "Scripts" , tmp_string .replace ("package.name" , package .name ))
354294 # Adding missing __init__.py files (fixes Issue 8)
355295 uic_path = str (Path ("Lib" ) / "site-packages" / package .name / "uic" )
356296 for dirname in ("Loader" , "port_v2" , "port_v3" ):
357- self .create_file (
358- package ,
359- "__init__.py" ,
360- str (Path (uic_path ) / dirname ),
361- "" ,
362- )
297+ self .create_file (package , "__init__.py" , str (Path (uic_path ) / dirname ), "" )
363298
364299 def _print (self , package , action ):
365- """Print package-related action text (e.g. 'Installing')
366- indicating progress"""
367- text = " " .join ([action , package .name , package .version ])
300+ """Print package-related action text (e.g. 'Installing')"""
301+ text = f"{ action } { package .name } { package .version } "
368302 if self .verbose :
369303 utils .print_box (text )
370304 else :
@@ -572,7 +506,7 @@ def main(test=False):
572506 title = f"** Package: { l [0 ]} **"
573507 print ("\n " + "*" * len (title ), f"\n { title } " , "\n " + "*" * len (title ) )
574508 for key , value in pip .raw [l [0 ]].items ():
575- rawtext = json .dumps (value , indent = 2 , ensure_ascii = False )
509+ rawtext = json .dumps (value , indent = 2 , ensure_ascii = False )
576510 lines = [l for l in rawtext .split (r"\n" ) if len (l .strip ()) > 2 ]
577511 if key .lower () != 'description' or args .verbose == True :
578512 print (f"{ key } : " , "\n " .join (lines ).replace ('"' , "" ))
0 commit comments