@@ -126,7 +126,7 @@ def replace_in_nsis_file(fname, data):
126
126
if line .startswith (start + ' ' ):
127
127
lines [idx ] = (
128
128
line [: len (start ) + 1 ]
129
- + ( '"%s"' % text )
129
+ + f'" { text } "'
130
130
+ '\n '
131
131
)
132
132
fd = open (fname , 'w' )
@@ -151,7 +151,7 @@ def replace_in_iss_file(fname, data):
151
151
if line .startswith (start + ' ' ):
152
152
lines [idx ] = (
153
153
line [: len (start ) + 1 ]
154
- + ( '"%s"' % text )
154
+ + f'" { text } "'
155
155
+ '\n '
156
156
)
157
157
fd = open (fname , 'w' )
@@ -176,7 +176,7 @@ def replace_in_7zip_file(fname, data):
176
176
if line .startswith (start + '=' ):
177
177
lines [idx ] = (
178
178
line [: len (start ) + 1 ]
179
- + ( '%s' % text )
179
+ + f' { text } '
180
180
+ '\n '
181
181
)
182
182
fd = open (fname , 'w' )
@@ -198,7 +198,7 @@ def build_nsis(srcname, dstname, data):
198
198
replace_in_nsis_file (dstname , data )
199
199
try :
200
200
retcode = subprocess .call (
201
- '"%s " -V2 "%s"' % ( NSIS_EXE , dstname ) ,
201
+ f'" { NSIS_EXE } " -V2 "{ dstname } "' ,
202
202
shell = True ,
203
203
stdout = sys .stderr ,
204
204
)
@@ -221,7 +221,7 @@ def build_iss(srcname, dstname, data):
221
221
replace_in_iss_file (dstname , data )
222
222
try :
223
223
retcode = subprocess .call (
224
- '"%s " "%s"' % ( ISCC_EXE , dstname ) ,
224
+ f'" { ISCC_EXE } " "{ dstname } "' ,
225
225
shell = True ,
226
226
stdout = sys .stderr ,
227
227
)
@@ -247,9 +247,9 @@ def build_7zip(srcname, dstname, data):
247
247
replace_in_7zip_file (dstname , data )
248
248
try :
249
249
# insted of a 7zip command line, we launch a script that does it
250
- # retcode = subprocess.call('"%s " "%s"' % (SEVENZIP_EXE, dstname ),
250
+ # retcode = subprocess.call(f'"{SEVENZIP_EXE} " "{dstname}"' ),
251
251
retcode = subprocess .call (
252
- '"%s " ' % ( dstname ) ,
252
+ f'" { dstname } " ' ,
253
253
shell = True ,
254
254
stdout = sys .stderr ,
255
255
)
@@ -326,7 +326,7 @@ def __init__(
326
326
self .python_name = Path (self .python_fname ).name [
327
327
:- 4
328
328
]
329
- self .distname = 'winUNKNOWN' #win%s' % self.python_name # PyPy ?
329
+ self .distname = 'winUNKNOWN' # f'win{ self.python_name}' # PyPy ?
330
330
#vlst = (
331
331
# re.match(r'winpython-([0-9\.]*)', self.distname)
332
332
# .groups()[0]
@@ -406,67 +406,46 @@ def get_tool_path_dir(relpath):
406
406
metadata ['url' ],
407
407
metadata ['description' ],
408
408
)
409
- tools += [
410
- '[%s](%s) | %s | %s'
411
- % (name , url , ver , desc )
412
- ]
409
+ tools += [f'[{ name } ]({ url } ) | { ver } | { desc } ' ]
413
410
# get all packages installed in the changelog, whatever the method
414
411
self .installed_packages = (
415
412
self .distribution .get_installed_packages (update = True )
416
413
)
417
414
418
415
packages = [
419
- '[%s](%s) | %s | %s'
420
- % (
421
- pack .name ,
422
- pack .url ,
423
- pack .version ,
424
- pack .description ,
425
- )
416
+ f'[{ pack .name } ]({ pack .url } ) | { pack .version } | { pack .description } '
426
417
for pack in sorted (
427
418
self .installed_packages ,
428
419
key = lambda p : p .name .lower (),
429
420
)
430
421
]
431
422
python_desc = 'Python programming language with standard library'
432
- return """## WinPython %s
423
+ tools_f = '\n ' .join (tools )
424
+ packages_f = '\n ' .join (packages )
425
+ return f"""## WinPython { self .winpyver2 + self .flavor }
433
426
434
- The following packages are included in WinPython-%sbit v%s%s .
427
+ The following packages are included in WinPython-{ self . winpy_arch } bit v { self . winpyver2 + self . flavor } { self . release_level } .
435
428
436
429
<details>
437
430
438
431
### Tools
439
432
440
433
Name | Version | Description
441
434
-----|---------|------------
442
- %s
435
+ { tools_f }
443
436
444
437
### Python packages
445
438
446
439
Name | Version | Description
447
440
-----|---------|------------
448
- [Python](http://www.python.org/) | %s | %s
449
- %s""" % (
450
- self .winpyver2 + self .flavor ,
451
- self .winpy_arch ,
452
- self .winpyver2 + self .flavor ,
453
- (' %s' % self .release_level ),
454
- '\n ' .join (tools ),
455
- self .python_fullversion ,
456
- python_desc ,
457
- '\n ' .join (packages ),
458
- ) + '\n \n </details>\n '
441
+ [Python](http://www.python.org/) | { self .python_fullversion } | { python_desc }
442
+ { packages_f } """ + '\n \n </details>\n '
459
443
460
444
# @property makes self.winpyver becomes a call to self.winpyver()
461
445
@property
462
446
def winpyver (self ):
463
447
"""Return WinPython version (with flavor and release level!)"""
464
- return '%s.%d%s%s' % (
465
- self .python_fullversion ,
466
- self .build_number ,
467
- self .flavor ,
468
- self .release_level ,
469
- )
448
+ return f'{ self .python_fullversion } .{ self .build_number } { self .flavor } { self .release_level } '
470
449
471
450
@property
472
451
def python_dir (self ):
@@ -476,7 +455,7 @@ def python_dir(self):
476
455
@property
477
456
def winpy_arch (self ):
478
457
"""Return WinPython architecture"""
479
- return '%d' % self .distribution .architecture
458
+ return f' { self .distribution .architecture } '
480
459
481
460
@property
482
461
def py_arch (self ):
@@ -552,8 +531,7 @@ def get_package_fname(self, pattern):
552
531
return str ((Path (path ) / fname ).resolve ())
553
532
else :
554
533
raise RuntimeError (
555
- 'Could not find required package matching %s'
556
- % pattern
534
+ f'Could not find required package matching { pattern } '
557
535
)
558
536
559
537
def create_batch_script (self , name , contents ,
@@ -601,7 +579,7 @@ def create_launcher(
601
579
fname = str (Path (self .winpydir ) / (Path (name ).stem + '.nsi' ))
602
580
603
581
data = [
604
- ('WINPYDIR' , '$EXEDIR\%s' % self .python_name ),
582
+ ('WINPYDIR' , f '$EXEDIR\{ self .python_name } ' ),
605
583
('WINPYVER' , self .winpyver ),
606
584
('COMMAND' , command ),
607
585
('PARAMETERS' , args ),
@@ -662,22 +640,12 @@ def create_installer(self):
662
640
('ARCH' , self .winpy_arch ),
663
641
(
664
642
'VERSION' ,
665
- '%s.%d%s'
666
- % (
667
- self .python_fullversion ,
668
- self .build_number ,
669
- self .flavor ,
670
- ),
643
+ f'{ self .python_fullversion } .{ self .build_number } { self .flavor } ' ,
671
644
),
672
645
(
673
646
'VERSION_INSTALL' ,
674
- '%s%d'
675
- % (
676
- self .python_fullversion .replace (
677
- '.' , ''
678
- ),
679
- self .build_number ,
680
- ),
647
+ f'{ self .python_fullversion .replace ("." , "" )} ' +
648
+ f'{ self .build_number } ' ,
681
649
),
682
650
('RELEASELEVEL' , self .release_level ),
683
651
)
@@ -694,22 +662,12 @@ def create_installer_inno(self):
694
662
('ARCH' , self .winpy_arch ),
695
663
(
696
664
'VERSION' ,
697
- '%s.%d%s'
698
- % (
699
- self .python_fullversion ,
700
- self .build_number ,
701
- self .flavor ,
702
- ),
665
+ f'{ self .python_fullversion } .{ self .build_number } { self .flavor } ' ,
703
666
),
704
667
(
705
668
'VERSION_INSTALL' ,
706
- '%s%d'
707
- % (
708
- self .python_fullversion .replace (
709
- '.' , ''
710
- ),
711
- self .build_number ,
712
- ),
669
+ f'{ self .python_fullversion .replace ("." , "" )} ' +
670
+ f'{ self .build_number } ' ,
713
671
),
714
672
('RELEASELEVEL' , self .release_level ),
715
673
)
@@ -726,22 +684,12 @@ def create_installer_7zip(self, installer_option=''):
726
684
('ARCH' , self .winpy_arch ),
727
685
(
728
686
'VERSION' ,
729
- '%s.%d%s'
730
- % (
731
- self .python_fullversion ,
732
- self .build_number ,
733
- self .flavor ,
734
- ),
687
+ f'{ self .python_fullversion } .{ self .build_number } { self .flavor } ' ,
735
688
),
736
689
(
737
690
'VERSION_INSTALL' ,
738
- '%s%d'
739
- % (
740
- self .python_fullversion .replace (
741
- '.' , ''
742
- ),
743
- self .build_number ,
744
- ),
691
+ f'{ self .python_fullversion .replace ("." , "" )} ' +
692
+ f'{ self .build_number } ' ,
745
693
),
746
694
('RELEASELEVEL' , self .release_level ),
747
695
)
@@ -1974,24 +1922,17 @@ def _run_complement_batch_scripts(
1974
1922
self , this_batch = "run_complement.bat"
1975
1923
):
1976
1924
""" tools\..\r un_complement.bat for final complements"""
1977
- print ('now %s in tooldirs\..' % this_batch )
1925
+ print (f 'now { this_batch } in tooldirs\..' )
1978
1926
for post_complement in list (
1979
1927
set ([str (Path (s ).parent ) for s in self ._toolsdirs ])
1980
1928
):
1981
1929
filepath = str (Path (post_complement ) / this_batch )
1982
1930
if Path (filepath ).is_file ():
1983
- print (
1984
- 'launch "%s" for "%s"'
1985
- % (filepath , self .winpydir )
1986
- )
1987
- self ._print (
1988
- 'launch "%s" for "%s" !'
1989
- % (filepath , self .winpydir )
1990
- )
1931
+ print (f'launch "{ filepath } " for "{ self .winpydir } "' )
1932
+ self ._print (f'launch "{ filepath } " for "{ self .winpydir } " !' )
1991
1933
try :
1992
1934
retcode = subprocess .call (
1993
- '"%s" "%s"'
1994
- % (filepath , self .winpydir ),
1935
+ f'"{ filepath } " "{ self .winpydir } "' ,
1995
1936
shell = True ,
1996
1937
stdout = sys .stderr ,
1997
1938
)
@@ -2046,10 +1987,7 @@ def make(
2046
1987
self .winpydir = str (Path (self .target ) / self .distname ) # PyPy to delete
2047
1988
else :
2048
1989
self .winpydir = str (Path (self .target ) / my_winpydir ) # Create/re-create the WinPython base directory
2049
- self ._print (
2050
- "Creating WinPython %s base directory"
2051
- % my_winpydir
2052
- )
1990
+ self ._print (f"Creating WinPython { my_winpydir } base directory" )
2053
1991
if (
2054
1992
Path (self .winpydir ).is_dir ()
2055
1993
and remove_existing
@@ -2111,8 +2049,8 @@ def make(
2111
2049
actions = ["install" , "--upgrade" , "--pre" , req ]
2112
2050
if self .install_options is not None :
2113
2051
actions += self .install_options
2114
- print ("piping %s" % ' ' .join (actions ))
2115
- self ._print ("piping %s" % ' ' .join (actions ))
2052
+ print (f "piping { ' ' .join (actions )} " )
2053
+ self ._print (f "piping { ' ' .join (actions )} " )
2116
2054
self .distribution .do_pip_action (actions )
2117
2055
self .distribution .patch_standard_packages (
2118
2056
req
@@ -2132,10 +2070,8 @@ def make(
2132
2070
actions = ["install" , "-r" , req ]
2133
2071
if self .install_options is not None :
2134
2072
actions += self .install_options
2135
- print ("piping %s" % ' ' .join (actions ))
2136
- self ._print (
2137
- "piping %s" % ' ' .join (actions )
2138
- )
2073
+ print (f"piping { ' ' .join (actions )} " )
2074
+ self ._print (f"piping { ' ' .join (actions )} " )
2139
2075
self .distribution .do_pip_action (actions )
2140
2076
# actions=["install","-r", req, "--no-index",
2141
2077
# "--trusted-host=None"]+ links,
@@ -2150,10 +2086,7 @@ def make(
2150
2086
self ._print ("Writing package index" )
2151
2087
# winpyver2 = need the version without build part
2152
2088
# but with self.distribution.architecture
2153
- self .winpyver2 = '%s.%s' % (
2154
- self .python_fullversion ,
2155
- self .build_number ,
2156
- )
2089
+ self .winpyver2 = f'{ self .python_fullversion } .{ self .build_number } '
2157
2090
fname = str (Path (self .winpydir ).parent / (
2158
2091
f'WinPython{ self .flavor } -' +
2159
2092
f'{ self .distribution .architecture } bit-' +
@@ -2248,8 +2181,8 @@ def make_all(
2248
2181
), "The *basedir* directory must be specified"
2249
2182
assert architecture in (32 , 64 )
2250
2183
utils .print_box (
2251
- "Making WinPython %dbits at %s" % ( architecture ,
2252
- str ( Path (basedir ) / ('bu' + flavor ))) )
2184
+ f "Making WinPython { architecture } bits" +
2185
+ f" at { Path (basedir ) / ('bu' + flavor )} " )
2253
2186
2254
2187
# Create Build director, where Winpython will be constructed
2255
2188
builddir = str (Path (basedir ) / ('bu' + flavor ) )
@@ -2273,15 +2206,15 @@ def make_all(
2273
2206
docsdirs = transform_in_list (docsdirs , 'docsdirs=' )
2274
2207
print ('docsdirs output' , docsdirs )
2275
2208
2276
- # install_options = ['--no-index', '--pre', '--find-links=%s' % wheeldir]
2209
+ # install_options = ['--no-index', '--pre', f '--find-links={ wheeldir)' ]
2277
2210
install_options = transform_in_list (
2278
2211
install_options , 'install_options'
2279
2212
)
2280
2213
2281
2214
find_links = transform_in_list (find_links , 'find_links' )
2282
2215
2283
2216
find_list = [
2284
- '--find-links=%s' % l
2217
+ f '--find-links={ l } '
2285
2218
for l in find_links + [wheeldir ]
2286
2219
]
2287
2220
dist = WinPythonDistribution (
@@ -2312,23 +2245,23 @@ def make_all(
2312
2245
if not python_target_release == None :
2313
2246
my_winpydir = (
2314
2247
'WPy'
2315
- + ( '%s' % architecture )
2248
+ + f' { architecture } '
2316
2249
+ '-'
2317
2250
+ python_target_release
2318
2251
+ ''
2319
- + ( '%s' % build_number )
2252
+ + f' { build_number } '
2320
2253
) + release_level
2321
2254
# + flavor
2322
2255
else :
2323
2256
my_winpydir = (
2324
2257
'WPy'
2325
- + ( '%s' % architecture )
2258
+ + f' { architecture } '
2326
2259
+ '-'
2327
2260
+ pyver .replace ('.' , '' )
2328
2261
+ ''
2329
2262
+ my_x
2330
2263
+ ''
2331
- + ( '%s' % build_number )
2264
+ + f' { build_number } '
2332
2265
) + release_level
2333
2266
# + flavor
2334
2267
0 commit comments