diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-23 18:10:36 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-23 18:10:36 +0200 |
| commit | db93568d9f8423c4fe6399562f13fa54f7c96494 (patch) | |
| tree | e5543032f89706d0afb3a3c9f777ba1aa14e2620 /project/boost | |
| parent | workflows/aur: inherit secrets (diff) | |
| download | cmake-common-db93568d9f8423c4fe6399562f13fa54f7c96494.tar.gz cmake-common-db93568d9f8423c4fe6399562f13fa54f7c96494.zip | |
use default settings for Black
Diffstat (limited to 'project/boost')
| -rw-r--r-- | project/boost/archive.py | 14 | ||||
| -rw-r--r-- | project/boost/build.py | 124 | ||||
| -rw-r--r-- | project/boost/directory.py | 18 | ||||
| -rw-r--r-- | project/boost/download.py | 44 | ||||
| -rw-r--r-- | project/boost/version.py | 16 |
5 files changed, 108 insertions, 108 deletions
diff --git a/project/boost/archive.py b/project/boost/archive.py index 921e04f..526257c 100644 --- a/project/boost/archive.py +++ b/project/boost/archive.py @@ -25,8 +25,8 @@ class Archive: def unpack(self, dest_dir): path = os.path.join(dest_dir, self.dir_name) if os.path.exists(path): - raise RuntimeError(f'Boost directory already exists: {path}') - logging.info('Unpacking Boost to: %s', path) + raise RuntimeError(f"Boost directory already exists: {path}") + logging.info("Unpacking Boost to: %s", path) shutil.unpack_archive(self.path, dest_dir) return BoostDir(path) @@ -58,10 +58,10 @@ class PermanentStorage(ArchiveStorage): @contextmanager def write_archive(self, version, contents): path = self._archive_path(version) - logging.info('Writing Boost archive: %s', path) + logging.info("Writing Boost archive: %s", path) if os.path.exists(path): - raise RuntimeError(f'cannot download Boost, file already exists: {path}') - with open(path, mode='w+b') as dest: + raise RuntimeError(f"cannot download Boost, file already exists: {path}") + with open(path, mode="w+b") as dest: dest.write(contents) yield path @@ -76,9 +76,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 + prefix=f"boost_{version}_", suffix=version.archive_ext, dir=self._dir ) with tmp as archive_path: - with open(archive_path, mode='wb') as fd: + with open(archive_path, mode="wb") as fd: fd.write(contents) yield archive_path diff --git a/project/boost/build.py b/project/boost/build.py index 6f0726c..a501c11 100644 --- a/project/boost/build.py +++ b/project/boost/build.py @@ -3,7 +3,7 @@ # For details, see https://github.com/egor-tensin/cmake-common. # Distributed under the MIT License. -R'''Build Boost. +R"""Build Boost. The main utility of this script is setting the correct --prefix parameter value to avoid name clashes. @@ -24,7 +24,7 @@ By default, only builds: * Debug & Release configurations, * static libraries, * statically linked to the runtime. -''' +""" import argparse from contextlib import contextmanager @@ -47,8 +47,8 @@ DEFAULT_CONFIGURATIONS = ( Configuration.RELEASE, ) DEFAULT_TOOLSET_VERSION = ToolsetVersion.default() -B2_QUIET = ['warnings=off', '-d0'] -B2_VERBOSE = ['warnings=all', '-d2', '--debug-configuration'] +B2_QUIET = ["warnings=off", "-d0"] +B2_VERBOSE = ["warnings=all", "-d2", "--debug-configuration"] class BuildParameters: @@ -94,7 +94,7 @@ class BuildParameters: @staticmethod def from_cmd_args(args): args = vars(args) - args.pop('help_toolsets', None) + args.pop("help_toolsets", None) return BuildParameters(**args) def enum_b2_args(self): @@ -107,18 +107,18 @@ class BuildParameters: @contextmanager def _create_build_dir(self): if self.build_dir is not None: - logging.info('Build directory: %s', self.build_dir) + logging.info("Build directory: %s", self.build_dir) yield self.build_dir return with tempfile.TemporaryDirectory( dir=os.path.dirname(self.boost_dir) ) as build_dir: - logging.info('Build directory: %s', build_dir) + logging.info("Build directory: %s", build_dir) try: yield build_dir finally: - logging.info('Removing build directory: %s', build_dir) + logging.info("Removing build directory: %s", build_dir) return @contextmanager @@ -126,16 +126,16 @@ class BuildParameters: toolset = Toolset.make(self.toolset_version, platform) link, runtime_link = Linkage.validate_linkage(self.link, self.runtime_link) with toolset.b2_args() as result: - result.append(f'--build-dir={build_dir}') - result.append('--layout=system') + result.append(f"--build-dir={build_dir}") + result.append("--layout=system") result += platform.b2_args(configuration) result += configuration.b2_args() result += link.b2_args_link() result += runtime_link.b2_args_runtime_link() result += self.b2_args if self.libraries: - result += [f'--with-{lib}' for lib in self.libraries] - result += ['install'] + result += [f"--with-{lib}" for lib in self.libraries] + result += ["install"] yield result @@ -148,7 +148,7 @@ def _parse_args(argv=None): if argv is None: argv = sys.argv[1:] - if '--help-toolsets' in argv: + if "--help-toolsets" in argv: sys.stdout.write(ToolsetVersion.help_toolsets()) sys.exit(0) @@ -157,102 +157,102 @@ def _parse_args(argv=None): ) parser.add_argument( - '--help-toolsets', - action='store_true', - help='show detailed info about supported toolsets', + "--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)', + "-v", + "--verbose", + action="store_true", + help="verbose b2 invocation (quiet by default)", ) parser.add_argument( - '--toolset', - metavar='TOOLSET', - dest='toolset_version', + "--toolset", + metavar="TOOLSET", + dest="toolset_version", type=ToolsetVersion.parse, default=DEFAULT_TOOLSET_VERSION, - help=f'toolset to use ({ToolsetVersion.usage()})', + help=f"toolset to use ({ToolsetVersion.usage()})", ) - platform_options = '/'.join(map(str, Platform.all())) - configuration_options = '/'.join(map(str, Configuration.all())) + 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='*', + "--platform", + metavar="PLATFORM", + dest="platforms", + nargs="*", type=Platform.parse, default=[], - help=f'target platform ({platform_options})', + help=f"target platform ({platform_options})", ) parser.add_argument( - '--configuration', - metavar='CONFIGURATION', - dest='configurations', - nargs='*', + "--configuration", + metavar="CONFIGURATION", + dest="configurations", + nargs="*", type=Configuration.parse, default=[], - help=f'target configuration ({configuration_options})', + help=f"target configuration ({configuration_options})", ) - linkage_options = '/'.join(map(str, Linkage.all())) + 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', + "--link", + metavar="LINKAGE", type=Linkage.parse, default=Linkage.default_link(), - help=f'how the libraries are linked ({linkage_options})', + 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', + "--runtime-link", + metavar="LINKAGE", type=Linkage.parse, default=Linkage.default_runtime_link(), - help=f'how the libraries link to the runtime ({linkage_options})', + help=f"how the libraries link to the runtime ({linkage_options})", ) parser.add_argument( - '--build', - metavar='DIR', - dest='build_dir', + "--build", + metavar="DIR", + dest="build_dir", type=normalize_path, - help='Boost build directory (temporary directory unless specified)', + 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', + "--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', + "boost_dir", + metavar="BOOST_DIR", type=normalize_path, - help='root Boost directory', + help="root Boost directory", ) parser.add_argument( - 'libraries', - metavar='LIBRARIES', - action='extend', - nargs='*', - help='libraries to build (all libraries by default)', + "libraries", + metavar="LIBRARIES", + action="extend", + nargs="*", + help="libraries to build (all libraries by default)", ) return parser.parse_args(argv) @@ -264,5 +264,5 @@ def _main(argv=None): build(BuildParameters.from_cmd_args(args)) -if __name__ == '__main__': +if __name__ == "__main__": _main() diff --git a/project/boost/directory.py b/project/boost/directory.py index 62090dc..fc05f68 100644 --- a/project/boost/directory.py +++ b/project/boost/directory.py @@ -27,7 +27,7 @@ class BoostDir: def _bootstrap_if_required(self, params): if os.path.isfile(self._b2_path()): - logging.info('Not going to bootstrap, b2 is already there') + logging.info("Not going to bootstrap, b2 is already there") return self.bootstrap(params) @@ -41,14 +41,14 @@ class BoostDir: @staticmethod def _bootstrap_path(): - return os.path.join('.', BoostDir._bootstrap_name()) + return os.path.join(".", BoostDir._bootstrap_name()) @staticmethod def _bootstrap_name(): - ext = '.sh' + ext = ".sh" if on_windows(): - ext = '.bat' - return f'bootstrap{ext}' + ext = ".bat" + return f"bootstrap{ext}" @staticmethod def _bootstrap_args(toolset_version): @@ -59,11 +59,11 @@ class BoostDir: @staticmethod def _b2_path(): - return os.path.join('.', BoostDir._b2_name()) + return os.path.join(".", BoostDir._b2_name()) @staticmethod def _b2_name(): - ext = '' + ext = "" if on_windows(): - ext = '.exe' - return f'b2{ext}' + ext = ".exe" + return f"b2{ext}" diff --git a/project/boost/download.py b/project/boost/download.py index a10e9e6..52710af 100644 --- a/project/boost/download.py +++ b/project/boost/download.py @@ -3,7 +3,7 @@ # For details, see https://github.com/egor-tensin/cmake-common. # Distributed under the MIT License. -R'''Download & bootstrap Boost. +R"""Download & bootstrap Boost. This script downloads and unpacks a Boost distribution archive. Its main utility is that it's cross-platform & supports different Boost versions out of @@ -16,7 +16,7 @@ Usage examples: $ boost-download --unpack ~/workspace/third-party/ 1.65.0 ... -''' +""" import argparse from contextlib import contextmanager @@ -37,7 +37,7 @@ class Download: ): if unpack_dir is None: if cache_dir is None: - unpack_dir = '.' + unpack_dir = "." else: unpack_dir = cache_dir @@ -75,7 +75,7 @@ class Download: return Download._download_url(url) def _try_url(self, url): - logging.info('Trying URL: %s', url) + logging.info("Trying URL: %s", url) try: if self.no_retry: return self._download_url(url) @@ -107,7 +107,7 @@ class Download: def download_if_necessary(self): path = self.storage.get_archive(self.version) if path is not None: - logging.info('Using existing Boost archive: %s', path) + logging.info("Using existing Boost archive: %s", path) yield path return with self._download_from_cdn() as path: @@ -132,32 +132,32 @@ def _parse_args(argv=None): project.version.add_to_arg_parser(parser) parser.add_argument( - '--unpack', - metavar='DIR', - dest='unpack_dir', + "--unpack", + metavar="DIR", + dest="unpack_dir", type=normalize_path, - help='directory to unpack the archive to', + help="directory to unpack the archive to", ) parser.add_argument( - '--cache', - metavar='DIR', - dest='cache_dir', + "--cache", + metavar="DIR", + dest="cache_dir", type=normalize_path, - help='download directory (temporary file unless specified)', + help="download directory (temporary file unless specified)", ) - parser.add_argument('--no-retry', action='store_true', help=argparse.SUPPRESS) + parser.add_argument("--no-retry", action="store_true", help=argparse.SUPPRESS) parser.add_argument( - 'version', - metavar='VERSION', + "version", + metavar="VERSION", type=Version.from_string, - help='Boost version (in the MAJOR.MINOR.PATCH format)', + help="Boost version (in the MAJOR.MINOR.PATCH format)", ) parser.add_argument( - 'dest_path', - metavar='DIR', - nargs='?', + "dest_path", + metavar="DIR", + nargs="?", type=normalize_path, - help='rename the boost directory to DIR', + help="rename the boost directory to DIR", ) return parser.parse_args(argv) @@ -169,5 +169,5 @@ def _main(argv=None): download(Download.from_args(args)) -if __name__ == '__main__': +if __name__ == "__main__": _main() diff --git a/project/boost/version.py b/project/boost/version.py index d58f462..58bfb56 100644 --- a/project/boost/version.py +++ b/project/boost/version.py @@ -8,7 +8,7 @@ from functools import total_ordering import os.path import re -_Version = namedtuple('_Version', ['major', 'minor', 'patch']) +_Version = namedtuple("_Version", ["major", "minor", "patch"]) @total_ordering @@ -36,31 +36,31 @@ class Version: @staticmethod def from_string(s): - result = re.match(r'^(\d+)\.(\d+)\.(\d+)$', s) + result = re.match(r"^(\d+)\.(\d+)\.(\d+)$", s) if result is None: - raise ValueError(f'invalid Boost version: {s}') + raise ValueError(f"invalid Boost version: {s}") major = int(result.group(1)) minor = int(result.group(2)) patch = int(result.group(3)) return Version(major, minor, patch) def __str__(self): - return f'{self.major}.{self.minor}.{self.patch}' + return f"{self.major}.{self.minor}.{self.patch}" @property def archive_ext(self): - return '.tar.gz' + return ".tar.gz" def dir_path(self, parent_dir): return os.path.join(parent_dir, self.dir_name) @property def dir_name(self): - return f'boost_{self.major}_{self.minor}_{self.patch}' + return f"boost_{self.major}_{self.minor}_{self.patch}" @property def archive_name(self): - return f'{self.dir_name}{self.archive_ext}' + return f"{self.dir_name}{self.archive_ext}" def get_download_url(self): - return f'https://archives.boost.io/release/{self}/source/{self.archive_name}' + return f"https://archives.boost.io/release/{self}/source/{self.archive_name}" |
