From 64899879b001d08efd5b62b97daa85d5c825c1ee Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 17 May 2026 13:02:51 +0200 Subject: reformat everything for fun --- project/boost/archive.py | 5 +- project/boost/build.py | 148 ++++++++++++++++++++++++++++++++-------------- project/boost/download.py | 51 ++++++++++------ project/boost/version.py | 1 - 4 files changed, 141 insertions(+), 64 deletions(-) (limited to 'project/boost') diff --git a/project/boost/archive.py b/project/boost/archive.py index e15e457..ee46728 100644 --- a/project/boost/archive.py +++ b/project/boost/archive.py @@ -75,8 +75,9 @@ class TemporaryStorage(ArchiveStorage): @contextmanager def write_archive(self, version, contents): - tmp = temp_file(prefix=f'boost_{version}_', - suffix=version.archive_ext, dir=self._dir) + tmp = temp_file( + prefix=f'boost_{version}_', suffix=version.archive_ext, dir=self._dir + ) with tmp as archive_path: with open(archive_path, mode='wb') as fd: fd.write(contents) diff --git a/project/boost/build.py b/project/boost/build.py index 8ef993c..a15388b 100644 --- a/project/boost/build.py +++ b/project/boost/build.py @@ -41,18 +41,30 @@ from project.toolset import Toolset, ToolsetVersion from project.utils import normalize_path, setup_logging import project.version - DEFAULT_PLATFORMS = (Platform.AUTO,) -DEFAULT_CONFIGURATIONS = (Configuration.DEBUG, Configuration.RELEASE,) +DEFAULT_CONFIGURATIONS = ( + Configuration.DEBUG, + Configuration.RELEASE, +) DEFAULT_TOOLSET_VERSION = ToolsetVersion.default() B2_QUIET = ['warnings=off', '-d0'] B2_VERBOSE = ['warnings=all', '-d2', '--debug-configuration'] class BuildParameters: - def __init__(self, boost_dir, libraries, build_dir=None, platforms=None, - configurations=None, link=None, runtime_link=None, - toolset_version=None, verbose=False, b2_args=None): + def __init__( + self, + boost_dir, + libraries, + build_dir=None, + platforms=None, + configurations=None, + link=None, + runtime_link=None, + toolset_version=None, + verbose=False, + b2_args=None, + ): boost_dir = normalize_path(boost_dir) libraries = libraries or [] @@ -99,7 +111,9 @@ class BuildParameters: yield self.build_dir return - with tempfile.TemporaryDirectory(dir=os.path.dirname(self.boost_dir)) as build_dir: + with tempfile.TemporaryDirectory( + dir=os.path.dirname(self.boost_dir) + ) as build_dir: logging.info('Build directory: %s', build_dir) try: yield build_dir @@ -139,59 +153,107 @@ def _parse_args(argv=None): sys.exit(0) parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter + ) - parser.add_argument('--help-toolsets', action='store_true', - help='show detailed info about supported toolsets') + parser.add_argument( + '--help-toolsets', + action='store_true', + help='show detailed info about supported toolsets', + ) project.version.add_to_arg_parser(parser) - parser.add_argument('-v', '--verbose', action='store_true', - help='verbose b2 invocation (quiet by default)') - - parser.add_argument('--toolset', metavar='TOOLSET', dest='toolset_version', - type=ToolsetVersion.parse, default=DEFAULT_TOOLSET_VERSION, - help=f'toolset to use ({ToolsetVersion.usage()})') + parser.add_argument( + '-v', + '--verbose', + action='store_true', + help='verbose b2 invocation (quiet by default)', + ) + + parser.add_argument( + '--toolset', + metavar='TOOLSET', + dest='toolset_version', + type=ToolsetVersion.parse, + default=DEFAULT_TOOLSET_VERSION, + help=f'toolset to use ({ToolsetVersion.usage()})', + ) platform_options = '/'.join(map(str, Platform.all())) configuration_options = '/'.join(map(str, Configuration.all())) # These are used to put the built libraries into proper installation # directory subdirectories (to avoid name clashes). - parser.add_argument('--platform', metavar='PLATFORM', dest='platforms', - nargs='*', type=Platform.parse, default=[], - help=f'target platform ({platform_options})') - parser.add_argument('--configuration', metavar='CONFIGURATION', dest='configurations', - nargs='*', type=Configuration.parse, default=[], - help=f'target configuration ({configuration_options})') + parser.add_argument( + '--platform', + metavar='PLATFORM', + dest='platforms', + nargs='*', + type=Platform.parse, + default=[], + help=f'target platform ({platform_options})', + ) + parser.add_argument( + '--configuration', + metavar='CONFIGURATION', + dest='configurations', + nargs='*', + type=Configuration.parse, + default=[], + help=f'target configuration ({configuration_options})', + ) linkage_options = '/'.join(map(str, Linkage.all())) # This is needed because the default behaviour on Linux and Windows is # different: static & dynamic libs are built on Linux, but only static libs # are built on Windows by default. - parser.add_argument('--link', metavar='LINKAGE', - type=Linkage.parse, default=Linkage.default_link(), - help=f'how the libraries are linked ({linkage_options})') + parser.add_argument( + '--link', + metavar='LINKAGE', + type=Linkage.parse, + default=Linkage.default_link(), + help=f'how the libraries are linked ({linkage_options})', + ) # This is used to omit runtime-link=static I'd have to otherwise use a lot, # plus the script validates the link= and runtime-link= combinations. - parser.add_argument('--runtime-link', metavar='LINKAGE', - type=Linkage.parse, default=Linkage.default_runtime_link(), - help=f'how the libraries link to the runtime ({linkage_options})') - - parser.add_argument('--build', metavar='DIR', dest='build_dir', - type=normalize_path, - help='Boost build directory (temporary directory unless specified)') - - parser.add_argument('--b2-arg', metavar='ARG', dest='b2_args', - action='extend', nargs='*', - help='additional b2 arguments, to be passed verbatim') - - parser.add_argument('boost_dir', metavar='BOOST_DIR', - type=normalize_path, - help='root Boost directory') - parser.add_argument('libraries', metavar='LIBRARIES', - action='extend', nargs='*', - help='libraries to build (all libraries by default)') + parser.add_argument( + '--runtime-link', + metavar='LINKAGE', + type=Linkage.parse, + default=Linkage.default_runtime_link(), + help=f'how the libraries link to the runtime ({linkage_options})', + ) + + parser.add_argument( + '--build', + metavar='DIR', + dest='build_dir', + type=normalize_path, + help='Boost build directory (temporary directory unless specified)', + ) + + parser.add_argument( + '--b2-arg', + metavar='ARG', + dest='b2_args', + action='extend', + nargs='*', + help='additional b2 arguments, to be passed verbatim', + ) + + parser.add_argument( + 'boost_dir', + metavar='BOOST_DIR', + type=normalize_path, + help='root Boost directory', + ) + parser.add_argument( + 'libraries', + metavar='LIBRARIES', + action='extend', + nargs='*', + help='libraries to build (all libraries by default)', + ) return parser.parse_args(argv) diff --git a/project/boost/download.py b/project/boost/download.py index aee80dc..5ee5e96 100644 --- a/project/boost/download.py +++ b/project/boost/download.py @@ -32,8 +32,9 @@ import project.version class Download: - def __init__(self, version, unpack_dir=None, cache_dir=None, - dest_path=None, no_retry=False): + def __init__( + self, version, unpack_dir=None, cache_dir=None, dest_path=None, no_retry=False + ): if unpack_dir is None: if cache_dir is None: unpack_dir = '.' @@ -125,25 +126,39 @@ def _parse_args(argv=None): argv = sys.argv[1:] parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter + ) project.version.add_to_arg_parser(parser) - parser.add_argument('--unpack', metavar='DIR', dest='unpack_dir', - type=normalize_path, - help='directory to unpack the archive to') - parser.add_argument('--cache', metavar='DIR', dest='cache_dir', - type=normalize_path, - help='download directory (temporary file unless specified)') - parser.add_argument('--no-retry', action='store_true', - help=argparse.SUPPRESS) - parser.add_argument('version', metavar='VERSION', - type=Version.from_string, - help='Boost version (in the MAJOR.MINOR.PATCH format)') - parser.add_argument('dest_path', metavar='DIR', nargs='?', - type=normalize_path, - help='rename the boost directory to DIR') + parser.add_argument( + '--unpack', + metavar='DIR', + dest='unpack_dir', + type=normalize_path, + help='directory to unpack the archive to', + ) + parser.add_argument( + '--cache', + metavar='DIR', + dest='cache_dir', + type=normalize_path, + help='download directory (temporary file unless specified)', + ) + parser.add_argument('--no-retry', action='store_true', help=argparse.SUPPRESS) + parser.add_argument( + 'version', + metavar='VERSION', + type=Version.from_string, + help='Boost version (in the MAJOR.MINOR.PATCH format)', + ) + parser.add_argument( + 'dest_path', + metavar='DIR', + nargs='?', + type=normalize_path, + help='rename the boost directory to DIR', + ) return parser.parse_args(argv) diff --git a/project/boost/version.py b/project/boost/version.py index e49a81f..134c62a 100644 --- a/project/boost/version.py +++ b/project/boost/version.py @@ -8,7 +8,6 @@ from functools import total_ordering import os.path import re - _Version = namedtuple('_Version', ['major', 'minor', 'patch']) -- cgit v1.3