[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-04-13 00:00:18 +00:00
parent 72ad6dc953
commit f4cd1ba0d6
813 changed files with 66015 additions and 58839 deletions

View file

@ -2,8 +2,10 @@
Implements the Distutils 'bdist' command (create a built [binary]
distribution)."""
from __future__ import annotations
import os
from distutils.core import Command
from distutils.errors import *
from distutils.util import get_platform
@ -15,68 +17,93 @@ def show_formats():
from distutils.fancy_getopt import FancyGetopt
formats = []
for format in bdist.format_commands:
formats.append(("formats=" + format, None,
bdist.format_command[format][1]))
formats.append((
'formats=' + format, None,
bdist.format_command[format][1],
))
pretty_printer = FancyGetopt(formats)
pretty_printer.print_help("List of available distribution formats:")
pretty_printer.print_help('List of available distribution formats:')
class bdist(Command):
description = "create a built (binary) distribution"
description = 'create a built (binary) distribution'
user_options = [('bdist-base=', 'b',
"temporary directory for creating built distributions"),
('plat-name=', 'p',
"platform name to embed in generated filenames "
"(default: %s)" % get_platform()),
('formats=', None,
"formats for distribution (comma-separated list)"),
('dist-dir=', 'd',
"directory to put final built distributions in "
"[default: dist]"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('owner=', 'u',
"Owner name used when creating a tar file"
" [default: current user]"),
('group=', 'g',
"Group name used when creating a tar file"
" [default: current group]"),
]
user_options = [
(
'bdist-base=', 'b',
'temporary directory for creating built distributions',
),
(
'plat-name=', 'p',
'platform name to embed in generated filenames '
'(default: %s)' % get_platform(),
),
(
'formats=', None,
'formats for distribution (comma-separated list)',
),
(
'dist-dir=', 'd',
'directory to put final built distributions in '
'[default: dist]',
),
(
'skip-build', None,
'skip rebuilding everything (for testing/debugging)',
),
(
'owner=', 'u',
'Owner name used when creating a tar file'
' [default: current user]',
),
(
'group=', 'g',
'Group name used when creating a tar file'
' [default: current group]',
),
]
boolean_options = ['skip-build']
help_options = [
('help-formats', None,
"lists available distribution formats", show_formats),
]
(
'help-formats', None,
'lists available distribution formats', show_formats,
),
]
# The following commands do not take a format option from bdist
no_format_option = ('bdist_rpm',)
# This won't do in reality: will need to distinguish RPM-ish Linux,
# Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
default_format = {'posix': 'gztar',
'nt': 'zip'}
default_format = {
'posix': 'gztar',
'nt': 'zip',
}
# Establish the preferred order (for the --help-formats option).
format_commands = ['rpm', 'gztar', 'bztar', 'xztar', 'ztar', 'tar',
'wininst', 'zip', 'msi']
format_commands = [
'rpm', 'gztar', 'bztar', 'xztar', 'ztar', 'tar',
'wininst', 'zip', 'msi',
]
# And the real information.
format_command = {'rpm': ('bdist_rpm', "RPM distribution"),
'gztar': ('bdist_dumb', "gzip'ed tar file"),
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
'xztar': ('bdist_dumb', "xz'ed tar file"),
'ztar': ('bdist_dumb', "compressed tar file"),
'tar': ('bdist_dumb', "tar file"),
'wininst': ('bdist_wininst',
"Windows executable installer"),
'zip': ('bdist_dumb', "ZIP file"),
'msi': ('bdist_msi', "Microsoft Installer")
}
format_command = {
'rpm': ('bdist_rpm', 'RPM distribution'),
'gztar': ('bdist_dumb', "gzip'ed tar file"),
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
'xztar': ('bdist_dumb', "xz'ed tar file"),
'ztar': ('bdist_dumb', 'compressed tar file'),
'tar': ('bdist_dumb', 'tar file'),
'wininst': (
'bdist_wininst',
'Windows executable installer',
),
'zip': ('bdist_dumb', 'ZIP file'),
'msi': ('bdist_msi', 'Microsoft Installer'),
}
def initialize_options(self):
self.bdist_base = None
@ -100,8 +127,10 @@ class bdist(Command):
# "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.)
if self.bdist_base is None:
build_base = self.get_finalized_command('build').build_base
self.bdist_base = os.path.join(build_base,
'bdist.' + self.plat_name)
self.bdist_base = os.path.join(
build_base,
'bdist.' + self.plat_name,
)
self.ensure_string_list('formats')
if self.formats is None:
@ -109,11 +138,12 @@ class bdist(Command):
self.formats = [self.default_format[os.name]]
except KeyError:
raise DistutilsPlatformError(
"don't know how to create built distributions "
"on platform %s" % os.name)
"don't know how to create built distributions "
'on platform %s' % os.name,
)
if self.dist_dir is None:
self.dist_dir = "dist"
self.dist_dir = 'dist'
def run(self):
# Figure out which sub-commands we need to run.
@ -138,6 +168,6 @@ class bdist(Command):
# If we're going to need to run this command again, tell it to
# keep its temporary files around so subsequent runs go faster.
if cmd_name in commands[i+1:]:
if cmd_name in commands[i + 1:]:
sub_cmd.keep_temp = 1
self.run_command(cmd_name)