1818search paths for header files and shared libraries. It's known to work on
1919Linux with GCC and clang.
2020
21- Please keep this script compatible with Python 2.7, and 3.4 to 3.7.
22-
2321(c) 2013-2017 Christian Heimes <christian@python.org>
2422"""
25- from __future__ import print_function
26-
2723import argparse
28- from datetime import datetime
2924import logging
3025import os
31- try :
32- from urllib .request import urlopen
33- from urllib .error import HTTPError
34- except ImportError :
35- from urllib2 import urlopen , HTTPError
3626import re
3727import shutil
3828import subprocess
3929import sys
4030import tarfile
41-
31+ from datetime import datetime
32+ from urllib .error import HTTPError
33+ from urllib .request import urlopen
4234
4335log = logging .getLogger ("multissl" )
4436
9587 nargs = '+' ,
9688 default = (),
9789 help = (
98- "OpenSSL versions, defaults to '{}' (ancient: '{}') if no "
90+ f"OpenSSL versions, defaults to '{ OPENSSL_RECENT_VERSIONS } ' "
91+ f"(ancient: '{ OPENSSL_OLD_VERSIONS } ') if no "
9992 "OpenSSL and LibreSSL versions are given."
100- ). format ( OPENSSL_RECENT_VERSIONS , OPENSSL_OLD_VERSIONS )
93+ )
10194)
10295parser .add_argument (
10396 '--libressl' ,
10497 nargs = '+' ,
10598 default = (),
10699 help = (
107- "LibreSSL versions, defaults to '{}' (ancient: '{}') if no "
100+ f"LibreSSL versions, defaults to '{ LIBRESSL_RECENT_VERSIONS } ' "
101+ f"(ancient: '{ LIBRESSL_OLD_VERSIONS } ') if no "
108102 "OpenSSL and LibreSSL versions are given."
109- ). format ( LIBRESSL_RECENT_VERSIONS , LIBRESSL_OLD_VERSIONS )
103+ )
110104)
111105parser .add_argument (
112106 '--aws-lc' ,
116110 nargs = '+' ,
117111 default = (),
118112 help = (
119- "AWS-LC versions, defaults to '{}' if no crypto library versions are given."
120- ).format (AWSLC_RECENT_VERSIONS )
113+ f"AWS-LC versions, defaults to '{ AWSLC_RECENT_VERSIONS } ' "
114+ f"if no crypto library versions are given."
115+ )
121116)
122117parser .add_argument (
123118 '--tests' ,
171166)
172167
173168
174- class AbstractBuilder ( object ) :
169+ class AbstractBuilder :
175170 library = None
176171 url_templates = None
177172 src_template = None
@@ -206,7 +201,7 @@ def __init__(self, version, args):
206201 self .system = args .system
207202
208203 def __str__ (self ):
209- return "<{0 .__class__.__name__} for {0 .version}>" . format ( self )
204+ return f "<{ self .__class__ .__name__ } for { self .version } >"
210205
211206 def __eq__ (self , other ):
212207 if not isinstance (other , AbstractBuilder ):
@@ -261,11 +256,11 @@ def has_src(self):
261256 return os .path .isfile (self .src_file )
262257
263258 def _subprocess_call (self , cmd , env = None , ** kwargs ):
264- log .debug ("Call '{}'" . format ( " " .join (cmd )) )
259+ log .debug (f "Call '{ ' ' .join (cmd )} '" )
265260 return subprocess .check_call (cmd , env = env , ** kwargs )
266261
267262 def _subprocess_output (self , cmd , env = None , ** kwargs ):
268- log .debug ("Call '{}'" . format ( " " .join (cmd )) )
263+ log .debug (f "Call '{ ' ' .join (cmd )} '" )
269264 if env is None :
270265 env = os .environ .copy ()
271266 env ["LD_LIBRARY_PATH" ] = self .lib_dir
@@ -280,21 +275,21 @@ def _download_src(self):
280275 data = None
281276 for url_template in self .url_templates :
282277 url = url_template .format (v = self .version , s = self .short_version )
283- log .info ("Downloading from {}" . format ( url ) )
278+ log .info (f "Downloading from { url } " )
284279 try :
285280 req = urlopen (url )
286281 # KISS, read all, write all
287282 data = req .read ()
288283 except HTTPError as e :
289284 log .error (
290- "Download from {} has from failed: {}" . format ( url , e )
285+ f "Download from { url } has from failed: { e } "
291286 )
292287 else :
293- log .info ("Successfully downloaded from {}" . format ( url ) )
288+ log .info (f "Successfully downloaded from { url } " )
294289 break
295290 if data is None :
296291 raise ValueError ("All download URLs have failed" )
297- log .info ("Storing {}" . format ( self .src_file ) )
292+ log .info (f "Storing { self .src_file } " )
298293 with open (self .src_file , "wb" ) as f :
299294 f .write (data )
300295
@@ -316,19 +311,19 @@ def _unpack_src(self):
316311 elif not member .name .startswith (base ):
317312 raise ValueError (member .name , base )
318313 member .name = member .name [len (base ):].lstrip ('/' )
319- log .info ("Unpacking files to {}" . format ( self .build_dir ) )
314+ log .info (f "Unpacking files to { self .build_dir } " )
320315 tf .extractall (self .build_dir , members , filter = 'data' )
321316
322317 def _build_src (self , config_args = ()):
323318 """Now build openssl"""
324- log .info ("Running build in {}" . format ( self .build_dir ) )
319+ log .info (f "Running build in { self .build_dir } " )
325320 cwd = self .build_dir
326321 if self .args .tsan :
327322 config_args += ("-fsanitize=thread" ,)
328323 cmd = [
329324 "./config" , * config_args ,
330325 "shared" , "--debug" ,
331- "--prefix={}" . format ( self .install_dir )
326+ f "--prefix={ self .install_dir } "
332327 ]
333328 # cmd.extend(["no-deprecated", "--api=1.1.0"])
334329 env = os .environ .copy ()
@@ -361,19 +356,19 @@ def install(self):
361356 if not self .has_src :
362357 self ._download_src ()
363358 else :
364- log .debug ("Already has src {}" . format ( self .src_file ) )
359+ log .debug (f "Already has src { self .src_file } " )
365360 self ._unpack_src ()
366361 self ._build_src ()
367362 self ._make_install ()
368363 else :
369- log .info ("Already has installation {}" . format ( self .install_dir ) )
364+ log .info (f "Already has installation { self .install_dir } " )
370365 # validate installation
371366 version = self .openssl_version
372367 if self .version not in version :
373368 raise ValueError (version )
374369
375370 def recompile_pymods (self ):
376- log .warning ("Using build from {}" . format ( self .build_dir ) )
371+ log .warning (f "Using build from { self .build_dir } " )
377372 # force a rebuild of all modules that use OpenSSL APIs
378373 for fname in self .module_files :
379374 os .utime (fname , None )
@@ -385,8 +380,8 @@ def recompile_pymods(self):
385380
386381 # overwrite header and library search paths
387382 env = os .environ .copy ()
388- env ["CPPFLAGS" ] = "-I{}" . format ( self .include_dir )
389- env ["LDFLAGS" ] = "-L{}" . format ( self .lib_dir )
383+ env ["CPPFLAGS" ] = f "-I{ self .include_dir } "
384+ env ["LDFLAGS" ] = f "-L{ self .lib_dir } "
390385 # set rpath
391386 env ["LD_RUN_PATH" ] = self .lib_dir
392387
@@ -411,8 +406,6 @@ def run_python_tests(self, tests, network=True):
411406 os .path .join (PYTHONROOT , 'Lib/test/ssltests.py' ),
412407 '-j0'
413408 ]
414- elif sys .version_info < (3 , 3 ):
415- cmd = [sys .executable , '-m' , 'test.regrtest' ]
416409 else :
417410 cmd = [sys .executable , '-m' , 'test' , '-j0' ]
418411 if network :
@@ -493,22 +486,22 @@ class BuildAWSLC(AbstractBuilder):
493486
494487 def _build_src (self , config_args = ()):
495488 cwd = self .build_dir
496- log .info ("Running build in {}" . format ( cwd ) )
489+ log .info (f "Running build in { cwd } " )
497490 env = os .environ .copy ()
498491 env ["LD_RUN_PATH" ] = self .lib_dir # set rpath
499492 if self .system :
500493 env ['SYSTEM' ] = self .system
501494 cmd = [
502495 "cmake" ,
503496 "-DCMAKE_BUILD_TYPE=RelWithDebInfo" ,
504- "-DCMAKE_PREFIX_PATH={}" . format ( self .install_dir ) ,
505- "-DCMAKE_INSTALL_PREFIX={}" . format ( self .install_dir ) ,
497+ f "-DCMAKE_PREFIX_PATH={ self .install_dir } " ,
498+ f "-DCMAKE_INSTALL_PREFIX={ self .install_dir } " ,
506499 "-DBUILD_SHARED_LIBS=ON" ,
507500 "-DBUILD_TESTING=OFF" ,
508501 "-DFIPS=OFF" ,
509502 ]
510503 self ._subprocess_call (cmd , cwd = cwd , env = env )
511- self ._subprocess_call (["make" , "-j{}" . format ( self .jobs ) ], cwd = cwd , env = env )
504+ self ._subprocess_call (["make" , f "-j{ self .jobs } " ], cwd = cwd , env = env )
512505
513506
514507def configure_make ():
@@ -577,13 +570,10 @@ def main():
577570 )
578571 except Exception as e :
579572 log .exception ("%s failed" , build )
580- print ("{ } failed: {}" . format ( build , e ) , file = sys .stderr )
573+ print (f" { build } failed: { e } " , file = sys .stderr )
581574 sys .exit (2 )
582575
583- log .info ("\n {} finished in {}" .format (
584- args .steps .capitalize (),
585- datetime .now () - start
586- ))
576+ log .info (f"\n { args .steps .capitalize ()} finished in { datetime .now () - start } " )
587577 print ('Python: ' , sys .version )
588578 if args .steps == 'tests' :
589579 if args .tests :
@@ -593,7 +583,7 @@ def main():
593583
594584 print ('OpenSSL / LibreSSL / AWS-LC versions:' )
595585 for build in builds :
596- print (" * {0 .library} {0 .version}" . format ( build ) )
586+ print (f " * { build .library } { build .version } " )
597587
598588
599589if __name__ == "__main__" :
0 commit comments