Skip to content

Commit 9c34051

Browse files
committed
WL#15151: Increase to 88 characters per line
Python PEP-8 establishes a limit for all lines to 79 characters. This worklog is to increase this limit to a more sensible length. Increasing the limit to 88 produces significantly shorter files but keeps the readability at the same time. Change-Id: I0b0ad5a6ac3b890ab9fc12d7ae804c55e8573e99
1 parent ffdec09 commit 9c34051

File tree

99 files changed

+1563
-4322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1563
-4322
lines changed

cpydist/__init__.py

Lines changed: 37 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@
4747

4848
from setuptools.command.build_ext import build_ext
4949

50-
from .utils import (
51-
ARCH,
52-
ARCH_64BIT,
53-
mysql_c_api_info,
54-
write_info_bin,
55-
write_info_src,
56-
)
50+
from .utils import ARCH, ARCH_64BIT, mysql_c_api_info, write_info_bin, write_info_src
5751

5852
# Load version information
5953
VERSION = [999, 0, 0, "a", 0]
@@ -177,31 +171,25 @@ def finalize_options(self):
177171
"MYSQL_CAPI"
178172
)
179173
cmd_build_ext.with_openssl_include_dir = (
180-
self.with_openssl_include_dir
181-
or os.environ.get("OPENSSL_INCLUDE_DIR")
174+
self.with_openssl_include_dir or os.environ.get("OPENSSL_INCLUDE_DIR")
182175
)
183176
cmd_build_ext.with_openssl_lib_dir = (
184177
self.with_openssl_lib_dir or os.environ.get("OPENSSL_LIB_DIR")
185178
)
186179
cmd_build_ext.with_protobuf_include_dir = (
187-
self.with_protobuf_include_dir
188-
or os.environ.get("PROTOBUF_INCLUDE_DIR")
180+
self.with_protobuf_include_dir or os.environ.get("PROTOBUF_INCLUDE_DIR")
189181
)
190182
cmd_build_ext.with_protobuf_lib_dir = (
191183
self.with_protobuf_lib_dir or os.environ.get("PROTOBUF_LIB_DIR")
192184
)
193-
cmd_build_ext.with_protoc = self.with_protoc or os.environ.get(
194-
"PROTOC"
195-
)
196-
cmd_build_ext.extra_compile_args = (
197-
self.extra_compile_args or os.environ.get("EXTRA_COMPILE_ARGS")
185+
cmd_build_ext.with_protoc = self.with_protoc or os.environ.get("PROTOC")
186+
cmd_build_ext.extra_compile_args = self.extra_compile_args or os.environ.get(
187+
"EXTRA_COMPILE_ARGS"
198188
)
199189
cmd_build_ext.extra_link_args = self.extra_link_args or os.environ.get(
200190
"EXTRA_LINK_ARGS"
201191
)
202-
cmd_build_ext.skip_vendor = self.skip_vendor or os.environ.get(
203-
"SKIP_VENDOR"
204-
)
192+
cmd_build_ext.skip_vendor = self.skip_vendor or os.environ.get("SKIP_VENDOR")
205193
if not cmd_build_ext.skip_vendor:
206194
self._copy_vendor_libraries()
207195

@@ -233,9 +221,7 @@ def remove_temp(self):
233221

234222
def _get_openssl_libs(self):
235223
libssl = glob(os.path.join(self.with_openssl_lib_dir, "libssl.*.*.*"))
236-
libcrypto = glob(
237-
os.path.join(self.with_openssl_lib_dir, "libcrypto.*.*.*")
238-
)
224+
libcrypto = glob(os.path.join(self.with_openssl_lib_dir, "libcrypto.*.*.*"))
239225
if not libssl or not libcrypto:
240226
self.log.error(
241227
"Unable to find OpenSSL libraries in '%s'",
@@ -251,9 +237,7 @@ def _copy_vendor_libraries(self):
251237
# Bundle OpenSSL libs
252238
if self.with_openssl_lib_dir:
253239
libssl, libcrypto = self._get_openssl_libs()
254-
vendor_libs.append(
255-
(self.with_openssl_lib_dir, [libssl, libcrypto])
256-
)
240+
vendor_libs.append((self.with_openssl_lib_dir, [libssl, libcrypto]))
257241

258242
# Plugins
259243
bundle_plugin_libs = False
@@ -309,22 +293,16 @@ def _copy_vendor_libraries(self):
309293
else:
310294
openssl_libs = ["libssl-1_1.dll", "libcrypto-1_1.dll"]
311295
if self.with_openssl_lib_dir:
312-
openssl_libs_path = os.path.abspath(
313-
self.with_openssl_lib_dir
314-
)
296+
openssl_libs_path = os.path.abspath(self.with_openssl_lib_dir)
315297
if os.path.basename(openssl_libs_path) == "lib":
316298
openssl_libs_path = os.path.split(openssl_libs_path)[0]
317299
if os.path.exists(openssl_libs_path) and os.path.exists(
318300
os.path.join(openssl_libs_path, "bin")
319301
):
320-
openssl_libs_path = os.path.join(
321-
openssl_libs_path, "bin"
322-
)
302+
openssl_libs_path = os.path.join(openssl_libs_path, "bin")
323303
self.log.info("# openssl_libs_path: %s", openssl_libs_path)
324304
else:
325-
openssl_libs_path = os.path.join(
326-
self.with_mysql_capi, "bin"
327-
)
305+
openssl_libs_path = os.path.join(self.with_mysql_capi, "bin")
328306
vendor_libs.append((openssl_libs_path, openssl_libs))
329307

330308
if not vendor_libs:
@@ -358,27 +336,20 @@ def _copy_vendor_libraries(self):
358336
if os.name == "nt":
359337
self.distribution.package_data = {"mysql": ["vendor/plugin/*"]}
360338
site_packages_files = [
361-
os.path.join(openssl_libs_path, lib_n)
362-
for lib_n in openssl_libs
339+
os.path.join(openssl_libs_path, lib_n) for lib_n in openssl_libs
363340
]
364341
site_packages_files.append(
365342
os.path.join(self.with_mysql_capi, "lib", "libmysql.dll")
366343
)
367344
self.distribution.data_files = [
368345
("lib\\site-packages\\", site_packages_files)
369346
]
370-
self.log.debug(
371-
"# site_packages_files: %s", self.distribution.data_files
372-
)
347+
self.log.debug("# site_packages_files: %s", self.distribution.data_files)
373348
elif bundle_plugin_libs:
374349
# Bundle SASL libs
375-
sasl_libs_path = os.path.join(
376-
self.with_mysql_capi, "lib", "private"
377-
)
350+
sasl_libs_path = os.path.join(self.with_mysql_capi, "lib", "private")
378351
if not os.path.exists(sasl_libs_path):
379-
self.log.info(
380-
"sasl2 llibraries not found at %s", sasl_libs_path
381-
)
352+
self.log.info("sasl2 llibraries not found at %s", sasl_libs_path)
382353
sasl_libs = []
383354
sasl_plugin_libs_w = [
384355
"libsasl2.*.*",
@@ -408,9 +379,7 @@ def _copy_vendor_libraries(self):
408379
if not os.path.exists(src):
409380
self.log.warn("Library not found: %s", src)
410381
continue
411-
dst = os.path.join(
412-
os.getcwd(), self.vendor_folder, "private"
413-
)
382+
dst = os.path.join(os.getcwd(), self.vendor_folder, "private")
414383
self.log.info("copying %s -> %s", src, dst)
415384
shutil.copy(src, dst)
416385

@@ -420,9 +389,7 @@ def _copy_vendor_libraries(self):
420389
self.with_mysql_capi, "lib", "private", "sasl2"
421390
)
422391
if not os.path.exists(sasl2_libs_path):
423-
self.log.info(
424-
"sasl2 llibraries not found at %s", sasl2_libs_path
425-
)
392+
self.log.info("sasl2 llibraries not found at %s", sasl2_libs_path)
426393
sasl2_libs_w = [
427394
"libanonymous.*",
428395
"libcrammd5.*.*",
@@ -449,9 +416,7 @@ def _copy_vendor_libraries(self):
449416

450417
sasl2_scram_libs = []
451418
for sasl2_lib in sasl2_libs_w:
452-
lib_path_entries = glob(
453-
os.path.join(sasl2_libs_path, sasl2_lib)
454-
)
419+
lib_path_entries = glob(os.path.join(sasl2_libs_path, sasl2_lib))
455420
for lib_path_entry in lib_path_entries:
456421
sasl2_scram_libs.append(os.path.basename(lib_path_entry))
457422

@@ -522,9 +487,7 @@ def _finalize_mysql_capi(self):
522487
# Add libmysqlclient libraries to be copied
523488
if "link_dirs" in self._mysql_info:
524489
libs += glob(
525-
os.path.join(
526-
self._mysql_info["link_dirs"][0], "libmysqlclient*"
527-
)
490+
os.path.join(self._mysql_info["link_dirs"][0], "libmysqlclient*")
528491
)
529492

530493
for lib in libs:
@@ -549,9 +512,7 @@ def _finalize_protobuf(self):
549512
)
550513

551514
if not self.with_protobuf_lib_dir:
552-
self.with_protobuf_lib_dir = os.environ.get(
553-
"MYSQLXPB_PROTOBUF_LIB_DIR"
554-
)
515+
self.with_protobuf_lib_dir = os.environ.get("MYSQLXPB_PROTOBUF_LIB_DIR")
555516

556517
if not self.with_protoc:
557518
self.with_protoc = os.environ.get("MYSQLXPB_PROTOC")
@@ -569,9 +530,7 @@ def _finalize_protobuf(self):
569530
sys.exit(1)
570531

571532
if self.with_protobuf_lib_dir:
572-
self.log.info(
573-
"Protobuf library directory: %s", self.with_protobuf_lib_dir
574-
)
533+
self.log.info("Protobuf library directory: %s", self.with_protobuf_lib_dir)
575534
if not os.path.isdir(self.with_protobuf_lib_dir):
576535
self.log.error("Protobuf library dir should be a directory")
577536
sys.exit(1)
@@ -596,9 +555,7 @@ def _finalize_protobuf(self):
596555
libs = glob(os.path.join(self.with_protobuf_lib_dir, "libprotobuf*"))
597556
for lib in libs:
598557
if os.path.isfile(lib):
599-
self.log.info(
600-
"copying %s -> %s", lib, self._build_protobuf_lib_dir
601-
)
558+
self.log.info("copying %s -> %s", lib, self._build_protobuf_lib_dir)
602559
shutil.copy2(lib, self._build_protobuf_lib_dir)
603560

604561
# Remove all but static libraries to force static linking
@@ -609,9 +566,7 @@ def _finalize_protobuf(self):
609566
)
610567
for lib in os.listdir(self._build_protobuf_lib_dir):
611568
lib_path = os.path.join(self._build_protobuf_lib_dir, lib)
612-
if os.path.isfile(lib_path) and not lib.endswith(
613-
(".a", ".dylib")
614-
):
569+
if os.path.isfile(lib_path) and not lib.endswith((".a", ".dylib")):
615570
os.unlink(os.path.join(self._build_protobuf_lib_dir, lib))
616571

617572
def _run_protoc(self):
@@ -635,12 +590,8 @@ def finalize_options(self):
635590

636591
self.log.info("Python architecture: %s", ARCH)
637592

638-
self._build_mysql_lib_dir = os.path.join(
639-
self.build_temp, "capi", "lib"
640-
)
641-
self._build_protobuf_lib_dir = os.path.join(
642-
self.build_temp, "protobuf", "lib"
643-
)
593+
self._build_mysql_lib_dir = os.path.join(self.build_temp, "capi", "lib")
594+
self._build_protobuf_lib_dir = os.path.join(self.build_temp, "protobuf", "lib")
644595
if self.with_mysql_capi:
645596
self._mysql_info = mysql_c_api_info(self.with_mysql_capi)
646597
self._finalize_mysql_capi()
@@ -665,9 +616,7 @@ def run(self):
665616
# Add Protobuf include and library dirs
666617
if ext.name == "_mysqlxpb":
667618
if not self.with_mysqlxpb_cext:
668-
self.log.warning(
669-
"The '_mysqlxpb' C extension will not be built"
670-
)
619+
self.log.warning("The '_mysqlxpb' C extension will not be built")
671620
disabled.append(ext)
672621
continue
673622
if platform.system() == "Darwin":
@@ -680,9 +629,7 @@ def run(self):
680629
fp.write("\n")
681630
ext.include_dirs.append(self.with_protobuf_include_dir)
682631
ext.library_dirs.append(self._build_protobuf_lib_dir)
683-
ext.libraries.append(
684-
"libprotobuf" if os.name == "nt" else "protobuf"
685-
)
632+
ext.libraries.append("libprotobuf" if os.name == "nt" else "protobuf")
686633
# Add -std=c++11 needed for Protobuf 3.6.1
687634
ext.extra_compile_args.append("-std=c++11")
688635
self._run_protoc()
@@ -695,17 +642,13 @@ def run(self):
695642
continue
696643
# Add extra compile args
697644
if self.extra_compile_args:
698-
ext.extra_compile_args.extend(
699-
self.extra_compile_args.split()
700-
)
645+
ext.extra_compile_args.extend(self.extra_compile_args.split())
701646
# Add extra link args
702647
if self.extra_link_args:
703648
ext.extra_link_args.extend(self.extra_link_args.split())
704649
# Add -rpath if the platform is Linux
705650
if platform.system() == "Linux" and not self.skip_vendor:
706-
ext.extra_link_args.extend(
707-
["-Wl,-rpath,$ORIGIN/mysql/vendor"]
708-
)
651+
ext.extra_link_args.extend(["-Wl,-rpath,$ORIGIN/mysql/vendor"])
709652
# Add include dirs
710653
if self.with_openssl_include_dir:
711654
ext.include_dirs.append(self.with_openssl_include_dir)
@@ -726,11 +669,11 @@ def run(self):
726669

727670
if os.name != "nt":
728671
cmd_gcc_ver = ["gcc", "-v"]
729-
self.log.info("Executing: {0}" "".format(" ".join(cmd_gcc_ver)))
672+
self.log.info("Executing: {0}".format(" ".join(cmd_gcc_ver)))
730673
proc = Popen(cmd_gcc_ver, stdout=PIPE, universal_newlines=True)
731674
self.log.info(proc.communicate())
732675
cmd_gpp_ver = ["g++", "-v"]
733-
self.log.info("Executing: {0}" "".format(" ".join(cmd_gcc_ver)))
676+
self.log.info("Executing: {0}".format(" ".join(cmd_gcc_ver)))
734677
proc = Popen(cmd_gpp_ver, stdout=PIPE, universal_newlines=True)
735678
self.log.info(proc.communicate())
736679

@@ -752,12 +695,8 @@ def run(self):
752695
"@loader_path/mysql/vendor/{0}".format(libssl),
753696
build_ext.get_ext_fullpath(self, "_mysql_connector"),
754697
]
755-
self.log.info(
756-
"Executing: {0}" "".format(" ".join(cmd_libssl))
757-
)
758-
proc = Popen(
759-
cmd_libssl, stdout=PIPE, universal_newlines=True
760-
)
698+
self.log.info("Executing: {0}".format(" ".join(cmd_libssl)))
699+
proc = Popen(cmd_libssl, stdout=PIPE, universal_newlines=True)
761700
stdout, _ = proc.communicate()
762701
cmd_libcrypto = [
763702
"install_name_tool",
@@ -766,12 +705,8 @@ def run(self):
766705
"@loader_path/mysql/vendor/{0}".format(libcrypto),
767706
build_ext.get_ext_fullpath(self, "_mysql_connector"),
768707
]
769-
self.log.info(
770-
"Executing: {0}" "".format(" ".join(cmd_libcrypto))
771-
)
772-
proc = Popen(
773-
cmd_libcrypto, stdout=PIPE, universal_newlines=True
774-
)
708+
self.log.info("Executing: {0}".format(" ".join(cmd_libcrypto)))
709+
proc = Popen(cmd_libcrypto, stdout=PIPE, universal_newlines=True)
775710
stdout, _ = proc.communicate()
776711

777712
# Generate docs/INFO_BIN
@@ -806,9 +741,7 @@ def initialize_options(self):
806741
def finalize_options(self):
807742
"""Finalize the options."""
808743
install_lib.finalize_options(self)
809-
self.set_undefined_options(
810-
"install", ("byte_code_only", "byte_code_only")
811-
)
744+
self.set_undefined_options("install", ("byte_code_only", "byte_code_only"))
812745
self.set_undefined_options("build", ("build_base", "build_dir"))
813746

814747
def run(self):

cpydist/bdist.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ def finalize_options(self):
8080
def _get_fullname():
8181
label = "-{}".format(self.label) if self.label else ""
8282
python_version = (
83-
"-py{}".format(get_python_version())
84-
if self.byte_code_only
85-
else ""
83+
"-py{}".format(get_python_version()) if self.byte_code_only else ""
8684
)
8785
return "{name}{label}-{version}{edition}{pyver}".format(
8886
name=self.distribution.get_name(),
@@ -132,18 +130,14 @@ def run(self):
132130

133131
dist_name = self.distribution.get_fullname()
134132
self.dist_target = os.path.join(self.dist_dir, dist_name)
135-
self.log.info(
136-
"Distribution will be available as '%s'", self.dist_target
137-
)
133+
self.log.info("Distribution will be available as '%s'", self.dist_target)
138134

139135
# build command: just to get the build_base
140136
cmdbuild = self.get_finalized_command("build")
141137
self.build_base = cmdbuild.build_base
142138

143139
# install command
144-
install = self.reinitialize_command(
145-
"install_lib", reinit_subcommands=1
146-
)
140+
install = self.reinitialize_command("install_lib", reinit_subcommands=1)
147141
install.compile = False
148142
install.warn_dir = 0
149143
install.install_dir = self.bdist_dir
@@ -188,9 +182,7 @@ def run(self):
188182
if dst is None:
189183
dest_name, _ = copy_file(src, self.dist_target)
190184
else:
191-
dest_name, _ = copy_file(
192-
src, os.path.join(self.dist_target, dst)
193-
)
185+
dest_name, _ = copy_file(src, os.path.join(self.dist_target, dst))
194186

195187
add_docs(os.path.join(self.dist_target, "docs"))
196188

0 commit comments

Comments
 (0)