From 3fa090f49030b36eb1e4038280504ce3cc1e1de0 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 23 Jul 2022 17:54:51 -0700 Subject: black: break up long strings that black cannot fix --- lib/spack/spack/bootstrap.py | 10 +- lib/spack/spack/cmd/modules/__init__.py | 10 +- lib/spack/spack/cmd/style.py | 2 +- lib/spack/spack/test/cmd/spec.py | 5 +- lib/spack/spack/test/link_paths.py | 235 ++++++++++++++++++-------------- lib/spack/spack/test/url_parse.py | 5 +- 6 files changed, 160 insertions(+), 107 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py index 3313c475a2..8cd820f6c0 100644 --- a/lib/spack/spack/bootstrap.py +++ b/lib/spack/spack/bootstrap.py @@ -545,7 +545,10 @@ def ensure_module_importable_or_raise(module, abstract_spec=None): if b.try_import(module, abstract_spec): return - assert h, 'expected at least one exception to have been raised at this point: while bootstrapping {0}'.format(module) # noqa: E501 + assert h, ( + "expected at least one exception to have been raised at this point: " + "while bootstrapping {0}".format(module) + ) msg = 'cannot bootstrap the "{0}" Python module '.format(module) if abstract_spec: msg += 'from spec "{0}" '.format(abstract_spec) @@ -599,7 +602,10 @@ def ensure_executables_in_path_or_raise(executables, abstract_spec): cmd.add_default_envmod(env_mods) return cmd - assert h, 'expected at least one exception to have been raised at this point: while bootstrapping {0}'.format(executables_str) # noqa: E501 + assert h, ( + "expected at least one exception to have been raised at this point: " + "while bootstrapping {0}".format(executables_str) + ) msg = 'cannot bootstrap any of the {0} executables '.format(executables_str) if abstract_spec: msg += 'from spec "{0}" '.format(abstract_spec) diff --git a/lib/spack/spack/cmd/modules/__init__.py b/lib/spack/spack/cmd/modules/__init__.py index f2fd63aaa0..2ccbf4b2cf 100644 --- a/lib/spack/spack/cmd/modules/__init__.py +++ b/lib/spack/spack/cmd/modules/__init__.py @@ -377,9 +377,15 @@ def modules_cmd(parser, args, module_type, callbacks=callbacks): spec_fmt += '{compiler_flags}{variants}{arch=architecture}' msg += '\t' + s.cformat(spec_fmt) + '\n' tty.error(msg.format(query=args.constraint)) - tty.die('In this context exactly **one** match is needed: please specify your constraints better.') # NOQA: ignore=E501 + tty.die( + "In this context exactly **one** match is needed: " + "please specify your constraints better." + ) except NoSpecMatches: msg = "the constraint '{query}' matches no package." tty.error(msg.format(query=args.constraint)) - tty.die('In this context exactly **one** match is needed: please specify your constraints better.') # NOQA: ignore=E501 + tty.die( + "In this context exactly **one** match is needed: " + "please specify your constraints better." + ) diff --git a/lib/spack/spack/cmd/style.py b/lib/spack/spack/cmd/style.py index 252e9f7b1c..3d24228a54 100644 --- a/lib/spack/spack/cmd/style.py +++ b/lib/spack/spack/cmd/style.py @@ -384,7 +384,7 @@ def run_black(black_cmd, file_list, args): output = "\n".join( line for line in output.split("\n") - if not "DEPRECATION: Python 2 support will be removed" in line + if "DEPRECATION: Python 2 support will be removed" not in line ) rewrite_and_print_output(output, args, pat, replacement) diff --git a/lib/spack/spack/test/cmd/spec.py b/lib/spack/spack/test/cmd/spec.py index e406fabe26..1dfe20c780 100644 --- a/lib/spack/spack/test/cmd/spec.py +++ b/lib/spack/spack/test/cmd/spec.py @@ -101,7 +101,10 @@ def test_spec_parse_unquoted_flags_report(): with pytest.raises(spack.error.SpackError) as cm: spec('gcc cflags=-Os -pipe') cm = str(cm.value) - assert cm.startswith('trying to set variant "pipe" in package "gcc", but the package has no such variant [happened during concretization of gcc cflags="-Os" ~pipe]') # noqa: E501 + assert cm.startswith( + 'trying to set variant "pipe" in package "gcc", but the package has no such ' + 'variant [happened during concretization of gcc cflags="-Os" ~pipe]' + ) assert cm.endswith('(1) cflags=-Os -pipe => cflags="-Os -pipe"') diff --git a/lib/spack/spack/test/link_paths.py b/lib/spack/spack/test/link_paths.py index cafb646322..4e08a26fdf 100644 --- a/lib/spack/spack/test/link_paths.py +++ b/lib/spack/spack/test/link_paths.py @@ -11,10 +11,14 @@ import pytest import spack.paths from spack.compiler import _parse_non_system_link_dirs -is_windows = sys.platform == 'win32' +is_windows = sys.platform == "win32" +drive = "" if is_windows: - drive_m = re.search(r'[A-Za-z]:', spack.paths.test_path) - drive = drive_m.group() if drive_m else None + match = re.search(r"[A-Za-z]:", spack.paths.test_path) + if match: + drive = match.group() +root = drive + os.sep + #: directory with sample compiler data datadir = os.path.join(spack.paths.test_path, 'data', 'compiler_verbose_output') @@ -45,25 +49,35 @@ def check_link_paths(filename, paths): def test_icc16_link_paths(): - if is_windows: - check_link_paths('icc-16.0.3.txt', [ - drive + r'\usr\tce\packages\intel\intel-16.0.3\compilers_and_libraries_2016.3.210\linux\compiler\lib\intel64_lin', # noqa - drive + r'\usr\tce\packages\gcc\gcc-4.9.3\lib64\gcc\x86_64-unknown-linux-gnu\4.9.3', # noqa - drive + r'\usr\tce\packages\gcc\gcc-4.9.3\lib64']) - else: - check_link_paths('icc-16.0.3.txt', [ - '/usr/tce/packages/intel/intel-16.0.3/compilers_and_libraries_2016.3.210/linux/compiler/lib/intel64_lin', # noqa - '/usr/tce/packages/gcc/gcc-4.9.3/lib64/gcc/x86_64-unknown-linux-gnu/4.9.3', # noqa - '/usr/tce/packages/gcc/gcc-4.9.3/lib64']) + prefix = os.path.join(root, "usr", "tce", "packages") + check_link_paths( + 'icc-16.0.3.txt', [ + os.path.join( + prefix, + "intel", + "intel-16.0.3", + "compilers_and_libraries_2016.3.210", + "linux", + "compiler", + "lib", + "intel64_lin", + ), + os.path.join( + prefix, "gcc", "gcc-4.9.3", "lib64", "gcc", "x86_64-unknown-linux-gnu", "4.9.3" + ), + os.path.join(prefix, "gcc", "gcc-4.9.3", "lib64"), + ] + ) def test_pgi_link_paths(): - if is_windows: - check_link_paths('pgcc-16.3.txt', [ - drive + r'\usr\tce\packages\pgi\pgi-16.3\linux86-64\16.3\lib']) - else: - check_link_paths('pgcc-16.3.txt', [ - '/usr/tce/packages/pgi/pgi-16.3/linux86-64/16.3/lib']) + check_link_paths( + 'pgcc-16.3.txt', [ + os.path.join( + root, "usr", "tce", "packages", "pgi", "pgi-16.3", "linux86-64", "16.3", "lib" + ) + ] + ) def test_gcc7_link_paths(): @@ -75,65 +89,68 @@ def test_clang4_link_paths(): def test_xl_link_paths(): - if is_windows: - check_link_paths('xl-13.1.5.txt', [ - drive + r'\opt\ibm\xlsmp\4.1.5\lib', - drive + r'\opt\ibm\xlmass\8.1.5\lib', - drive + r'\opt\ibm\xlC\13.1.5\lib']) - else: - check_link_paths('xl-13.1.5.txt', [ - '/opt/ibm/xlsmp/4.1.5/lib', - '/opt/ibm/xlmass/8.1.5/lib', - '/opt/ibm/xlC/13.1.5/lib']) + check_link_paths( + 'xl-13.1.5.txt', [ + os.path.join(root, "opt", "ibm", "xlsmp", "4.1.5", "lib"), + os.path.join(root, "opt", "ibm", "xlmass", "8.1.5", "lib"), + os.path.join(root, "opt", "ibm", "xlC", "13.1.5", "lib"), + ] + ) def test_cce_link_paths(): - if is_windows: - check_link_paths('cce-8.6.5.txt', [ - drive + r'\opt\gcc\6.1.0\snos\lib64', - drive + r'\opt\cray\dmapp\default\lib64', - drive + r'\opt\cray\pe\mpt\7.7.0\gni\mpich-cray\8.6\lib', - drive + r'\opt\cray\pe\libsci\17.12.1\CRAY\8.6\x86_64\lib', - drive + r'\opt\cray\rca\2.2.16-6.0.5.0_15.34__g5e09e6d.ari\lib64', - drive + r'\opt\cray\pe\pmi\5.0.13\lib64', - drive + r'\opt\cray\xpmem\2.2.4-6.0.5.0_4.8__g35d5e73.ari\lib64', - drive + r'\opt\cray\dmapp\7.1.1-6.0.5.0_49.8__g1125556.ari\lib64', - drive + r'\opt\cray\ugni\6.0.14-6.0.5.0_16.9__g19583bb.ari\lib64', - drive + r'\opt\cray\udreg\2.3.2-6.0.5.0_13.12__ga14955a.ari\lib64', - drive + r'\opt\cray\alps\6.5.28-6.0.5.0_18.6__g13a91b6.ari\lib64', - drive + r'\opt\cray\pe\atp\2.1.1\libApp', - drive + r'\opt\cray\pe\cce\8.6.5\cce\x86_64\lib', - drive + r'\opt\cray\wlm_detect\1.3.2-6.0.5.0_3.1__g388ccd5.ari\lib64', - drive + r'\opt\gcc\6.1.0\snos\lib\gcc\x86_64-suse-linux\6.1.0', - drive + - r'\opt\cray\pe\cce\8.6.5\binutils\x86_64\x86_64-unknown-linux-gnu\lib']) - else: - check_link_paths('cce-8.6.5.txt', [ - '/opt/gcc/6.1.0/snos/lib64', - '/opt/cray/dmapp/default/lib64', - '/opt/cray/pe/mpt/7.7.0/gni/mpich-cray/8.6/lib', - '/opt/cray/pe/libsci/17.12.1/CRAY/8.6/x86_64/lib', - '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64', - '/opt/cray/pe/pmi/5.0.13/lib64', - '/opt/cray/xpmem/2.2.4-6.0.5.0_4.8__g35d5e73.ari/lib64', - '/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64', - '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64', - '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64', - '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64', - '/opt/cray/pe/atp/2.1.1/libApp', - '/opt/cray/pe/cce/8.6.5/cce/x86_64/lib', - '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64', - '/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0', - '/opt/cray/pe/cce/8.6.5/binutils/x86_64/x86_64-unknown-linux-gnu/lib']) + gcc = os.path.join(root, "opt", "gcc") + cray = os.path.join(root, "opt", "cray") + check_link_paths( + 'cce-8.6.5.txt', [ + os.path.join(gcc, "6.1.0", "snos", "lib64"), + os.path.join(cray, "dmapp", "default", "lib64"), + os.path.join(cray, "pe", "mpt", "7.7.0", "gni", "mpich-cray", "8.6", "lib"), + os.path.join(cray, "pe", "libsci", "17.12.1", "CRAY", "8.6", "x86_64", "lib"), + os.path.join(cray, "rca", "2.2.16-6.0.5.0_15.34__g5e09e6d.ari", "lib64"), + os.path.join(cray, "pe", "pmi", "5.0.13", "lib64"), + os.path.join(cray, "xpmem", "2.2.4-6.0.5.0_4.8__g35d5e73.ari", "lib64"), + os.path.join(cray, "dmapp", "7.1.1-6.0.5.0_49.8__g1125556.ari", "lib64"), + os.path.join(cray, "ugni", "6.0.14-6.0.5.0_16.9__g19583bb.ari", "lib64"), + os.path.join(cray, "udreg", "2.3.2-6.0.5.0_13.12__ga14955a.ari", "lib64"), + os.path.join(cray, "alps", "6.5.28-6.0.5.0_18.6__g13a91b6.ari", "lib64"), + os.path.join(cray, "pe", "atp", "2.1.1", "libApp"), + os.path.join(cray, "pe", "cce", "8.6.5", "cce", "x86_64", "lib"), + os.path.join(cray, "wlm_detect", "1.3.2-6.0.5.0_3.1__g388ccd5.ari", "lib64"), + os.path.join(gcc, "6.1.0", "snos", "lib", "gcc", "x86_64-suse-linux", "6.1.0"), + os.path.join( + cray, + "pe", + "cce", + "8.6.5", + "binutils", + "x86_64", + "x86_64-unknown-linux-gnu", + "lib" + ), + ] + ) def test_clang_apple_ld_link_paths(): - if is_windows: - check_link_paths('clang-9.0.0-apple-ld.txt', [ - drive + r'\Applications\Xcode.app\Contents\Developer\Platforms\MacOSX.platform\Developer\SDKs\MacOSX10.13.sdk\usr\lib']) # noqa - else: - check_link_paths('clang-9.0.0-apple-ld.txt', [ - '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib']) # noqa + check_link_paths( + 'clang-9.0.0-apple-ld.txt', [ + os.path.join( + root, + "Applications", + "Xcode.app", + "Contents", + "Developer", + "Platforms", + "MacOSX.platform", + "Developer", + "SDKs", + "MacOSX10.13.sdk", + "usr", + "lib", + ) + ] + ) def test_nag_mixed_gcc_gnu_ld_link_paths(): @@ -141,16 +158,24 @@ def test_nag_mixed_gcc_gnu_ld_link_paths(): # is used for the rpath detection. The reference compiler output is a # result of # '/path/to/gcc/bin/g++ -Wl,-v ./main.c'. - if is_windows: - check_link_paths('collect2-6.3.0-gnu-ld.txt', [ - drive + r'\scratch\local1\spack\opt\spack\gcc-6.3.0-haswell\gcc-6.5.0-4sdjgrs\lib\gcc\x86_64-pc-linux-gnu\6.5.0', # noqa - drive + r'\scratch\local1\spack\opt\spack\gcc-6.3.0-haswell\gcc-6.5.0-4sdjgrs\lib64', # noqa - drive + r'\scratch\local1\spack\opt\spack\gcc-6.3.0-haswell\gcc-6.5.0-4sdjgrs\lib']) # noqa - else: - check_link_paths('collect2-6.3.0-gnu-ld.txt', [ - '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib/gcc/x86_64-pc-linux-gnu/6.5.0', # noqa - '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib64', # noqa - '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib']) # noqa + prefix = os.path.join( + root, + "scratch", + "local1", + "spack", + "opt", + "spack", + "gcc-6.3.0-haswell", + "gcc-6.5.0-4sdjgrs", + ) + + check_link_paths( + 'collect2-6.3.0-gnu-ld.txt', [ + os.path.join(prefix, "lib", "gcc", "x86_64-pc-linux-gnu", "6.5.0"), + os.path.join(prefix, "lib64"), + os.path.join(prefix, "lib"), + ] + ) def test_nag_link_paths(): @@ -158,25 +183,35 @@ def test_nag_link_paths(): # and therefore 'fc' is used for the rpath detection). The reference # compiler output is a result of # 'nagfor -Wc=/path/to/gcc/bin/gcc -Wl,-v ./main.c'. - if is_windows: - check_link_paths('nag-6.2-gcc-6.5.0.txt', [ - drive + r'\scratch\local1\spack\opt\spack\gcc-6.3.0-haswell\gcc-6.5.0-4sdjgrs\lib\gcc\x86_64-pc-linux-gnu\6.5.0', # noqa - drive + r'\scratch\local1\spack\opt\spack\gcc-6.3.0-haswell\gcc-6.5.0-4sdjgrs\lib64', # noqa - drive + r'\scratch\local1\spack\opt\spack\gcc-6.3.0-haswell\gcc-6.5.0-4sdjgrs\lib']) # noqa - else: - check_link_paths('nag-6.2-gcc-6.5.0.txt', [ - '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib/gcc/x86_64-pc-linux-gnu/6.5.0', # noqa - '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib64', # noqa - '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib']) # noqa + prefix = os.path.join( + root, + "scratch", + "local1", + "spack", + "opt", + "spack", + "gcc-6.3.0-haswell", + "gcc-6.5.0-4sdjgrs", + ) + + check_link_paths( + 'nag-6.2-gcc-6.5.0.txt', [ + os.path.join(prefix, "lib", "gcc", "x86_64-pc-linux-gnu", "6.5.0"), + os.path.join(prefix, "lib64"), + os.path.join(prefix, "lib"), + ] + ) def test_obscure_parsing_rules(): + paths = [ + os.path.join(root, "first", "path"), + os.path.join(root, "second", "path"), + os.path.join(root, "third", "path"), + ] + + # TODO: add a comment explaining why this happens if is_windows: - check_link_paths('obscure-parsing-rules.txt', [ - drive + r'\first\path', - drive + r'\third\path']) - else: - check_link_paths('obscure-parsing-rules.txt', [ - '/first/path', - '/second/path', - '/third/path']) + paths.remove(os.path.join(root, "second", "path")) + + check_link_paths('obscure-parsing-rules.txt', paths) diff --git a/lib/spack/spack/test/url_parse.py b/lib/spack/spack/test/url_parse.py index 08d67cfb80..6175c5ad0f 100644 --- a/lib/spack/spack/test/url_parse.py +++ b/lib/spack/spack/test/url_parse.py @@ -77,7 +77,10 @@ from spack.version import Version ('haxe-2.08-osx', 'haxe-2.08'), # PyPI - wheel ('entrypoints-0.2.2-py2.py3-none-any.whl', 'entrypoints-0.2.2'), - ('numpy-1.12.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl', 'numpy-1.12.0'), # noqa + ( + 'numpy-1.12.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.' + 'macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl', 'numpy-1.12.0' + ), # PyPI - exe ('PyYAML-3.12.win-amd64-py3.5.exe', 'PyYAML-3.12'), # Combinations of multiple patterns - bin, release -- cgit v1.2.3-70-g09d2