Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Nov 1, 2023
1 parent 60f7984 commit 533d268
Show file tree
Hide file tree
Showing 20 changed files with 120 additions and 156 deletions.
11 changes: 6 additions & 5 deletions conda_build/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,17 +655,18 @@ def debug(
]
if len(matched_outputs) > 1:
raise ValueError(
"Specified --output-id matches more than one output ({}). Please refine your output id so that only "
"a single output is found.".format(matched_outputs)
f"Specified --output-id matches more than one output ({matched_outputs}). "
"Please refine your output id so that only a single output is found."
)
elif not matched_outputs:
raise ValueError(
f"Specified --output-id did not match any outputs. Available outputs are: {outputs} Please check it and try again"
f"Specified --output-id did not match any outputs. Available outputs are: {outputs} "
"Please check it and try again"
)
if len(matched_outputs) > 1 and not path_is_build_dir:
raise ValueError(
"More than one output found for this recipe ({}). Please use the --output-id argument to filter down "
"to a single output.".format(outputs)
f"More than one output found for this recipe ({outputs}). "
"Please use the --output-id argument to filter down to a single output."
)
else:
matched_outputs = outputs
Expand Down
24 changes: 14 additions & 10 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,12 @@ def regex_files_py(
match_records[file] = {"type": type, "submatches": []}
# else:
# if match_records[file]['absolute_offset'] != absolute_offset:
# print("Dropping match.pos() of {}, neq {}".format(absolute_offset, match_records[file]['absolute_offset']))
# print(
# "Dropping match.pos() of {}, neq {}".format(
# absolute_offset,
# match_records[file]['absolute_offset'],
# )
# )
g_index = len(match.groups())
if g_index == 0:
# Complete match.
Expand Down Expand Up @@ -639,8 +644,9 @@ def have_regex_files(
return match_records
import copy

match_records_rg, match_records_re = copy.deepcopy(match_records), copy.deepcopy(
match_records
match_records_rg, match_records_re = (
copy.deepcopy(match_records),
copy.deepcopy(match_records),
)
if not isinstance(regex_re, (bytes, bytearray)):
regex_re = regex_re.encode("utf-8")
Expand Down Expand Up @@ -2257,7 +2263,9 @@ def _write_sh_activation_text(file_handle, m):
if value:
if not done_necessary_env:
# file_handle.write(
# 'export CCACHE_SLOPPINESS="pch_defines,time_macros${CCACHE_SLOPPINESS+,$CCACHE_SLOPPINESS}"\n')
# 'export CCACHE_SLOPPINESS="pch_defines,time_macros'
# '${CCACHE_SLOPPINESS+,$CCACHE_SLOPPINESS}"\n'
# )
# file_handle.write('export CCACHE_CPP2=true\n')
done_necessary_env = True
if method == "symlinks":
Expand All @@ -2266,16 +2274,12 @@ def _write_sh_activation_text(file_handle, m):
file_handle.write(f"pushd {dirname_ccache_ln_bin}\n")
file_handle.write('if [ -n "$CC" ]; then\n')
file_handle.write(
" [ -f {ccache} ] && [ ! -f $(basename $CC) ] && ln -s {ccache} $(basename $CC) || true\n".format(
ccache=ccache
)
f" [ -f {ccache} ] && [ ! -f $(basename $CC) ] && ln -s {ccache} $(basename $CC) || true\n"
)
file_handle.write("fi\n")
file_handle.write('if [ -n "$CXX" ]; then\n')
file_handle.write(
" [ -f {ccache} ] && [ ! -f $(basename $CXX) ] && ln -s {ccache} $(basename $CXX) || true\n".format(
ccache=ccache
)
f" [ -f {ccache} ] && [ ! -f $(basename $CXX) ] && ln -s {ccache} $(basename $CXX) || true\n"
)
file_handle.write("fi\n")
file_handle.write("popd\n")
Expand Down
2 changes: 1 addition & 1 deletion conda_build/cli/main_develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def parse_args(args):
Install a Python package in 'development mode'.
This works by creating a conda.pth file in site-packages."""
This works by creating a conda.pth file in site-packages.""",
# TODO: Use setup.py to determine any entry-points to install.
)

Expand Down
3 changes: 1 addition & 2 deletions conda_build/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def __init__(
self.packages.append(pkg)
if not self.packages:
raise RuntimeError(
"failed to parse packages from exception:"
" {}".format(str(conda_exception))
f"failed to parse packages from exception: {conda_exception}"
)

def __str__(self):
Expand Down
3 changes: 2 additions & 1 deletion conda_build/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ def update_index(
if dirname in utils.DEFAULT_SUBDIRS:
if warn:
log.warn(
"The update_index function has changed to index all subdirs at once. You're pointing it at a single subdir. "
"The update_index function has changed to index all subdirs at once. "
"You're pointing it at a single subdir. "
"Please update your code to point it at the channel root, rather than a subdir."
)
return update_index(
Expand Down
14 changes: 2 additions & 12 deletions conda_build/jinja_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,8 @@ def __init__(
__call__
) = (
__getitem__
) = (
__lt__
) = (
__le__
) = (
__gt__
) = (
__ge__
) = (
__complex__
) = __pow__ = __rpow__ = lambda self, *args, **kwargs: self._return_undefined(
self._undefined_name
) = __lt__ = __le__ = __gt__ = __ge__ = __complex__ = __pow__ = __rpow__ = (
lambda self, *args, **kwargs: self._return_undefined(self._undefined_name)
)

# Accessing an attribute of an Undefined variable
Expand Down
3 changes: 2 additions & 1 deletion conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,8 @@ def get_depends_top_and_out(self, typ):
meta_requirements = ensure_list(self.get_value("requirements/" + typ, []))[:]
req_names = {req.split()[0] for req in meta_requirements if req}
extra_reqs = []
# this is for the edge case of requirements for top-level being also partially defined in a similarly named output
# this is for the edge case of requirements for top-level being
# partially defined in a similarly named output
if not self.is_output:
matching_output = [
out
Expand Down
6 changes: 1 addition & 5 deletions conda_build/noarch_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ def transform(m, files, prefix):
"""\
@echo off
"%PREFIX%\\python.exe" "%SOURCE_DIR%\\link.py"
""".replace(
"\n", "\r\n"
).encode(
"utf-8"
)
""".replace("\n", "\r\n").encode("utf-8")
)

d = populate_files(m, files, prefix)
Expand Down
56 changes: 25 additions & 31 deletions conda_build/os_utils/liefldd.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,14 @@ def inspect_linkages_lief(
"""
if binary.format == lief.EXE_FORMATS.PE:
import random
path_fixed = os.path.dirname(path_fixed) + os.sep + \
''.join(random.choice((str.upper, str.lower))(c) for c in os.path.basename(path_fixed))
path_fixed = (
os.path.dirname(path_fixed)
+ os.sep
+ ''.join(
random.choice((str.upper, str.lower))(c)
for c in os.path.basename(path_fixed)
)
)
if random.getrandbits(1):
path_fixed = path_fixed.replace(os.sep + 'lib' + os.sep, os.sep + 'Lib' + os.sep)
else:
Expand Down Expand Up @@ -650,16 +656,11 @@ def get_linkages(
)
if debug and result_pyldd and set(result_lief) != set(result_pyldd):
print(
"WARNING: Disagreement in get_linkages(filename={}, resolve_filenames={}, recurse={}, sysroot={}, envroot={}, arch={}):\n lief: {}\npyldd: {}\n (using lief)".format(
filename,
resolve_filenames,
recurse,
sysroot,
envroot,
arch,
result_lief,
result_pyldd,
)
f"WARNING: Disagreement in get_linkages({filename=}, "
f"{resolve_filenames=}, {recurse=}, {sysroot=}, {envroot=}, {arch=}):\n"
f" lief: {result_lief}\n"
f"pyldd: {result_pyldd}\n"
" (using lief)"
)
return result_lief

Expand Down Expand Up @@ -689,7 +690,7 @@ def is_archive(file):


def get_static_lib_exports(file):
# file = '/Users/rdonnelly/conda/main-augmented-tmp/osx-64_14354bd0cd1882bc620336d9a69ae5b9/lib/python2.7/config/libpython2.7.a'
# file = '/Users/rdonnelly/conda/main-augmented-tmp/osx-64_14354bd0cd1882bc620336d9a69ae5b9/lib/python2.7/config/libpython2.7.a' # noqa: E501
# References:
# https://github.com/bminor/binutils-gdb/tree/master/bfd/archive.c
# https://en.wikipedia.org/wiki/Ar_(Unix)
Expand Down Expand Up @@ -737,7 +738,8 @@ def _parse_ar_hdr(content, index):
typ = "NORMAL"
if b"/" in name:
name = name[: name.find(b"/")]
# if debug_static_archives: print("index={}, name={}, ending={}, size={}, type={}".format(index, name, ending, size, typ))
# if debug_static_archives:
# print(f"index={index}, name={name}, ending={ending}, size={size}, type={typ}")
index += header_sz + name_len
return index, name, name_len, size, typ

Expand Down Expand Up @@ -813,9 +815,7 @@ def _parse_ar_hdr(content, index):
(size_string_table,) = struct.unpack(
"<" + toc_integers_fmt,
content[
index
+ toc_integers_sz
+ (nsymbols * ranlib_struct_sz) : index
index + toc_integers_sz + (nsymbols * ranlib_struct_sz) : index
+ 4
+ 4
+ (nsymbols * ranlib_struct_sz)
Expand All @@ -827,8 +827,7 @@ def _parse_ar_hdr(content, index):
ran_off, ran_strx = struct.unpack(
"<" + ranlib_struct_field_fmt + ranlib_struct_field_fmt,
content[
ranlib_index
+ (i * ranlib_struct_sz) : ranlib_index
ranlib_index + (i * ranlib_struct_sz) : ranlib_index
+ ((i + 1) * ranlib_struct_sz)
],
)
Expand All @@ -845,8 +844,7 @@ def _parse_ar_hdr(content, index):
)
)
string_table = content[
ranlib_index
+ (nsymbols * ranlib_struct_sz) : ranlib_index
ranlib_index + (nsymbols * ranlib_struct_sz) : ranlib_index
+ (nsymbols * ranlib_struct_sz)
+ size_string_table
]
Expand Down Expand Up @@ -958,7 +956,7 @@ def get_static_lib_exports_dumpbin(filename):
> 020 00000000 UNDEF notype () External | malloc
> vs
> 004 00000010 SECT1 notype () External | _ZN3gnu11autosprintfC1EPKcz
"""
""" # noqa: E501
dumpbin_exe = find_executable("dumpbin")
if not dumpbin_exe:
"""
Expand Down Expand Up @@ -1077,19 +1075,15 @@ def get_exports(filename, arch="native", enable_static=False):
print(f"errors: {error_count} (-{len(diff1)}, +{len(diff2)})")
if debug_static_archives:
print(
"WARNING :: Disagreement regarding static lib exports in {} between nm (nsyms={}) and lielfldd (nsyms={}):".format(
filename, len(exports), len(exports2)
)
"WARNING :: Disagreement regarding static lib exports in "
f"{filename} between nm (nsyms={len(exports)}) and "
"lielfldd (nsyms={len(exports2)}):"
)
print(
"** nm.diff(liefldd) [MISSING SYMBOLS] **\n{}".format(
"\n".join(diff1)
)
"\n".join(("** nm.diff(liefldd) [MISSING SYMBOLS] **", *diff1))
)
print(
"** liefldd.diff(nm) [ EXTRA SYMBOLS] **\n{}".format(
"\n".join(diff2)
)
"\n".join(("** liefldd.diff(nm) [ EXTRA SYMBOLS] **", *diff2))
)

if not result:
Expand Down
10 changes: 3 additions & 7 deletions conda_build/os_utils/pyldd.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,13 +708,9 @@ def __init__(self, file):
get_logger(__name__).warning(f"file.tell()={loc} != ehsize={self.ehsize}")

def __str__(self):
return "bitness {}, endian {}, version {}, type {}, machine {}, entry {}".format( # noqa
self.bitness,
self.endian,
self.version,
self.type,
hex(self.machine),
hex(self.entry),
return (
f"bitness {self.bitness}, endian {self.endian}, version {self.version}, "
f"type {self.type}, machine {hex(self.machine)}, entry {hex(self.entry)}"
)


Expand Down
10 changes: 8 additions & 2 deletions conda_build/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ def conda_subcommands():
)
yield conda.plugins.CondaSubcommand(
name="develop",
summary="Install a Python package in 'development mode'. Similar to `pip install --editable`.",
summary=(
"Install a Python package in 'development mode'. "
"Similar to `pip install --editable`."
),
action=develop,
)
yield conda.plugins.CondaSubcommand(
name="index",
summary="Update package index metadata files. Pending deprecation, use https://github.com/conda/conda-index instead.",
summary=(
"Update package index metadata files. Pending deprecation, "
"use https://github.com/conda/conda-index instead."
),
action=index,
)
yield conda.plugins.CondaSubcommand(
Expand Down
9 changes: 8 additions & 1 deletion conda_build/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,14 @@ def check_binary(binary, expected=None):
print("trying {}".format(binary))
# import pdb; pdb.set_trace()
try:
txt = check_output([sys.executable, '-c', 'from ctypes import cdll; cdll.LoadLibrary("' + binary + '")'], timeout=2)
txt = check_output(
[
sys.executable,
'-c',
'from ctypes import cdll; cdll.LoadLibrary("' + binary + '")'
],
timeout=2,
)
# mydll = cdll.LoadLibrary(binary)
except Exception as e:
print(e)
Expand Down
10 changes: 3 additions & 7 deletions conda_build/skeletons/cran.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"""
Tools for converting Cran packages to conda recipes.
"""


import argparse
import copy
import hashlib
Expand Down Expand Up @@ -198,7 +196,7 @@
popd
fi
fi
"""
""" # noqa: E501

CRAN_BUILD_SH_BINARY = """\
#!/bin/bash
Expand Down Expand Up @@ -1299,10 +1297,8 @@ def skeletonize(
)
if not is_github_url:
available_details["archive_keys"] = (
"{url_key}{sel}"
" {cranurl}\n"
" {hash_entry}{sel}".format(**available_details)
)
"{url_key}{sel} {cranurl}\n {hash_entry}{sel}"
).format(**available_details)

# Extract the DESCRIPTION data from the source
if cran_package is None:
Expand Down
5 changes: 3 additions & 2 deletions conda_build/skeletons/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,9 @@ def remap_license(rpm_license):
}
l_rpm_license = rpm_license.lower()
if l_rpm_license in mapping:
license, family = mapping[l_rpm_license], guess_license_family(
mapping[l_rpm_license]
license, family = (
mapping[l_rpm_license],
guess_license_family(mapping[l_rpm_license]),
)
else:
license, family = rpm_license, guess_license_family(rpm_license)
Expand Down
5 changes: 2 additions & 3 deletions conda_build/tarcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ def correct_subdir(self):
self.config.host_subdir,
"noarch",
self.config.target_subdir,
], (
"Inconsistent subdir in package - index.json expecting {},"
" got {}".format(self.config.host_subdir, info["subdir"])
], "Inconsistent subdir in package - index.json expecting {}, got {}".format(
self.config.host_subdir, info["subdir"]
)


Expand Down
3 changes: 2 additions & 1 deletion conda_build/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def validate_spec(src, spec):
" zip_key entry {} in group {} is a duplicate, keys can only occur "
"in one group".format(k, zg)
# include error if key has already been seen, otherwise add to unique keys
if k in unique else unique.add(k)
if k in unique
else unique.add(k)
for zg in zip_keys
for k in zg
)
Expand Down
Loading

0 comments on commit 533d268

Please sign in to comment.