Repository: spack/spack

Issue:
`spack style -t isort` fails on Scientific Linux 7 with system Python3 3.6.8 
### Steps to reproduce

```console
$ spack clean -ab
$ spack bootstrap now --dev
$ spack style -b HEAD~10 -r -t isort
```

### Error message

```console
$ spack --debug --stacktrace style -b HEAD~10 -r -t isort
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.466603] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/config.yaml
lib/spack/spack/cmd/__init__.py:121 ==> [2023-11-15-14:59:18.535243] Imported style from built-in commands
lib/spack/spack/cmd/__init__.py:121 ==> [2023-11-15-14:59:18.536468] Imported style from built-in commands
lib/spack/spack/database.py:634 ==> [2023-11-15-14:59:18.545158] DATABASE LOCK TIMEOUT: 60s
lib/spack/spack/store.py:181 ==> [2023-11-15-14:59:18.545539] PACKAGE LOCK TIMEOUT: No timeout
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.546175] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/bootstrap.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.566848] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/repos.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.571488] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/repos.yaml
lib/spack/spack/bootstrap/config.py:125 ==> [2023-11-15-14:59:18.576401] [BOOTSTRAP CONFIG SCOPE] name=_builtin
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.577373] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/bootstrap.yaml
lib/spack/spack/bootstrap/config.py:138 ==> [2023-11-15-14:59:18.594174] [BOOTSTRAP CONFIG SCOPE] name=defaults, path=/home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults
lib/spack/spack/bootstrap/config.py:139 ==> [2023-11-15-14:59:18.594447] [BOOTSTRAP CONFIG SCOPE] name=defaults/linux, path=/home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/linux
lib/spack/spack/bootstrap/config.py:138 ==> [2023-11-15-14:59:18.594704] [BOOTSTRAP CONFIG SCOPE] name=bootstrap, path=/home/greenc/.spack/bootstrap/config
lib/spack/spack/bootstrap/config.py:139 ==> [2023-11-15-14:59:18.594937] [BOOTSTRAP CONFIG SCOPE] name=bootstrap/linux, path=/home/greenc/.spack/bootstrap/config/linux
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.597161] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/config.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.654357] Reading config from file /home/greenc/.spack/bootstrap/config/linux/config.yaml
lib/spack/spack/database.py:634 ==> [2023-11-15-14:59:18.682237] DATABASE LOCK TIMEOUT: 60s
lib/spack/spack/store.py:181 ==> [2023-11-15-14:59:18.682559] PACKAGE LOCK TIMEOUT: No timeout
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.683527] Reading config from file /home/greenc/.spack/bootstrap/config/linux/compilers.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.921523] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.922749] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.925889] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.932932] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.944710] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.947825] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.950971] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:18.957861] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.003778] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.006586] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.008009] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.017220] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.026808] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.029693] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.034397] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.039858] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.080530] '/usr/bin/bison' '--version'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.084821] '/usr/bin/gawk' '--version'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.106596] '/products/git/v2_40_1/Linux64bit+3.10-2.17/bin/git' '--version'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.110236] '/usr/bin/cmake' '--version'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.119435] '/usr/bin/git' '--version'
spack/config.py:989 ==> [2023-11-15-14:59:19.304629] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/packages.yaml
spack/config.py:989 ==> [2023-11-15-14:59:19.387771] Reading config from file /home/greenc/.spack/bootstrap/config/packages.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.521082] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/bootstrap.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.583931] Reading config from file /home/greenc/.spack/bootstrap/environments/python3.6-x86_64-7d8fd/spack.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.605444] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/config.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.659148] Reading config from file /home/greenc/.spack/bootstrap/config/linux/config.yaml
lib/spack/spack/environment/environment.py:211 ==> [2023-11-15-14:59:19.687672] Using environment '/home/greenc/.spack/bootstrap/environments/python3.6-x86_64-7d8fd'
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.690317] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/concretizer.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.709532] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/bootstrap.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.725815] Reading config from file /home/greenc/.spack/bootstrap/config/linux/bootstrap.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.746503] Reading config from file /home/greenc/.spack/bootstrap/environments/python3.6-x86_64-7d8fd/spack.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.767393] Reading config from file /home/greenc/work/cet-is/sources/Spack/spack/run/etc/spack/defaults/config.yaml
lib/spack/spack/config.py:989 ==> [2023-11-15-14:59:19.820845] Reading config from file /home/greenc/.spack/bootstrap/config/linux/config.yaml
lib/spack/spack/environment/environment.py:235 ==> [2023-11-15-14:59:19.848527] Deactivated environment '/home/greenc/.spack/bootstrap/environments/python3.6-x86_64-7d8fd'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.850391] '/products/git/v2_40_1/Linux64bit+3.10-2.17/bin/git' 'rev-parse' '--quiet' '--verify' '--revs-only' 'HEAD~10'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.864368] '/products/git/v2_40_1/Linux64bit+3.10-2.17/bin/git' 'diff' '--name-only' '--diff-filter=ACMR' '25eca56909b0e51ebc7a347214016af9bcb3430a...'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.890011] '/products/git/v2_40_1/Linux64bit+3.10-2.17/bin/git' 'diff' '--name-only' '--diff-filter=ACMR' '--cached'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.914532] '/products/git/v2_40_1/Linux64bit+3.10-2.17/bin/git' 'diff' '--name-only' '--diff-filter=ACMR'
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:19.946543] '/products/git/v2_40_1/Linux64bit+3.10-2.17/bin/git' 'ls-files' '--exclude-standard' '--other'
lib/spack/spack/cmd/style.py:219 ==> [2023-11-15-14:59:20.238831] Running style checks on spack
  selected: isort
lib/spack/spack/cmd/style.py:225 ==> [2023-11-15-14:59:20.239843] Modified files
  var/spack/repos/builtin/packages/bison/package.py
  var/spack/repos/builtin/packages/cp2k/package.py
  var/spack/repos/builtin/packages/esmf/package.py
  var/spack/repos/builtin/packages/hpctoolkit/package.py
  var/spack/repos/builtin/packages/libevent/package.py
  var/spack/repos/builtin/packages/mrtrix3/package.py
  var/spack/repos/builtin/packages/mumps/package.py
  var/spack/repos/builtin/packages/paraview/package.py
  var/spack/repos/builtin/packages/xsdk/package.py
lib/spack/spack/cmd/style.py:231 ==> [2023-11-15-14:59:20.240683] Running isort checks
lib/spack/spack/util/executable.py:219 ==> [2023-11-15-14:59:20.244906] '/home/greenc/.spack/bootstrap/environments/python3.6-x86_64-7d8fd/view/bin/isort' '--rm' 'spack' '--rm' 'spack.pkgkit' '--rm' 'spack.package_defs' '-a' 'from spack.package import *' '--settings-path' '/home/greenc/work/cet-is/sources/Spack/spack/run/pyproject.toml' '--check' '--diff' 'var/spack/repos/builtin/packages/bison/package.py' 'var/spack/repos/builtin/packages/cp2k/package.py' 'var/spack/repos/builtin/packages/esmf/package.py' 'var/spack/repos/builtin/packages/hpctoolkit/package.py' 'var/spack/repos/builtin/packages/libevent/package.py' 'var/spack/repos/builtin/packages/mrtrix3/package.py' 'var/spack/repos/builtin/packages/mumps/package.py' 'var/spack/repos/builtin/packages/paraview/package.py' 'var/spack/repos/builtin/packages/xsdk/package.py'
usage: isort [-h] [-a ADD_IMPORTS] [-ac] [-af] [-b KNOWN_STANDARD_LIBRARY]
             [-c] [-ca] [-cs] [-d] [-df] [-ds] [-dt] [-e]
             [-f KNOWN_FUTURE_LIBRARY] [-fas] [-fass] [-ff FROM_FIRST]
             [-fgw [FORCE_GRID_WRAP]] [-fss] [-i INDENT] [-j JOBS] [-k]
             [-l LINE_LENGTH] [-lai LINES_AFTER_IMPORTS]
             [-lbt LINES_BETWEEN_TYPES] [-le LINE_ENDING] [-ls]
             [-m {0,1,2,3,4,5,6,7}] [-nis] [-nlb NO_LINES_BEFORE]
             [-ns NOT_SKIP] [-o KNOWN_THIRD_PARTY] [-ot]
             [-p KNOWN_FIRST_PARTY] [-q] [-r] [-rm REMOVE_IMPORTS] [-rr] [-rc]
             [-s SKIP] [-sd DEFAULT_SECTION] [-sg SKIP_GLOB] [-sl]
             [-sp SETTINGS_PATH] [-t FORCE_TO_TOP] [-tc] [-up] [-v] [-vb]
             [--virtual-env VIRTUAL_ENV] [--conda-env CONDA_ENV] [-vn]
             [-w LINE_LENGTH] [-wl WRAP_LENGTH] [-ws] [-y] [--unsafe]
             [--case-sensitive] [--filter-files]
             [files [files ...]]
isort: error: unrecognized arguments: --rm --rm spack.pkgkit --rm spack.package_defs var/spack/repos/builtin/packages/bison/package.py var/spack/repos/builtin/packages/cp2k/package.py var/spack/repos/builtin/packages/esmf/package.py var/spack/repos/builtin/packages/hpctoolkit/package.py var/spack/repos/builtin/packages/libevent/package.py var/spack/repos/builtin/packages/mrtrix3/package.py var/spack/repos/builtin/packages/mumps/package.py var/spack/repos/builtin/packages/paraview/package.py var/spack/repos/builtin/packages/xsdk/package.py
  isort found errors
lib/spack/spack/cmd/style.py:427 ==> [2023-11-15-14:59:20.621007] Error: spack style found errors
```

### Information on your system

* **Spack:** 0.22.0.dev0 (2f24aeb7f690a7cc73996479b0028a273e91d9df)
* **Python:** 3.6.8
* **Platform:** linux-scientific7-skylake_avx512
* **Concretizer:** clingo


### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have searched the issues of this repo and believe this is not a duplicate
- [X] I have run the failing commands in debug mode and reported the output


Discussion:
This seems due to https://github.com/PyCQA/isort/issues/1363 so we should probably:
1. Bump the minimum required version of `isort` if possible, or
2. Use a slightly different set of flags for isort < 5  :sweat: 

@haampie @adamjstewart :point_up: This is one example of how removing Python 3.6 made it unwieldy to check/fix issues related to bootstrapping dev-dependencies for old Python versions[^1]. Nothing insurmountable, but I cannot simply try:
```console
$ spack install isort@5 ^python@3.6
```

[^1]: Whether we should do that for dev-dependencies is another subject that I'd like to discuss going to v0.22

Resolving patch:
diff --git a/lib/spack/spack/bootstrap/environment.py b/lib/spack/spack/bootstrap/environment.py
--- a/lib/spack/spack/bootstrap/environment.py
+++ b/lib/spack/spack/bootstrap/environment.py
@@ -161,7 +161,7 @@ def _write_spack_yaml_file(self) -> None:
 
 def isort_root_spec() -> str:
     """Return the root spec used to bootstrap isort"""
-    return _root_spec("py-isort@4.3.5:")
+    return _root_spec("py-isort@5")
 
 
 def mypy_root_spec() -> str:
diff --git a/var/spack/repos/builtin/packages/py-isort/package.py b/var/spack/repos/builtin/packages/py-isort/package.py
--- a/var/spack/repos/builtin/packages/py-isort/package.py
+++ b/var/spack/repos/builtin/packages/py-isort/package.py
@@ -13,16 +13,33 @@ class PyIsort(PythonPackage):
     pypi = "isort/isort-4.2.15.tar.gz"
 
     version("5.12.0", sha256="8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504")
+    version("5.11.5", sha256="6be1f76a507cb2ecf16c7cf14a37e41609ca082330be4e3436a18ef74add55db")
     version("5.10.1", sha256="e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951")
     version("5.9.3", sha256="9c2ea1e62d871267b78307fe511c0838ba0da28698c5732d54e2790bf3ba9899")
     version("5.9.1", sha256="83510593e07e433b77bd5bff0f6f607dbafa06d1a89022616f02d8b699cfcd56")
-    version("4.3.20", sha256="c40744b6bc5162bbb39c1257fe298b7a393861d50978b565f3ccd9cb9de0182a")
-    version("4.2.15", sha256="79f46172d3a4e2e53e7016e663cc7a8b538bec525c36675fcfd2767df30b3983")
+    version(
+        "4.3.20",
+        sha256="c40744b6bc5162bbb39c1257fe298b7a393861d50978b565f3ccd9cb9de0182a",
+        deprecated=True,
+    )
+    version(
+        "4.2.15",
+        sha256="79f46172d3a4e2e53e7016e663cc7a8b538bec525c36675fcfd2767df30b3983",
+        deprecated=True,
+    )
 
     variant("colors", default=False, description="Install colorama for --color support")
 
-    depends_on("python@3.8:", when="@5.12:", type=("build", "run"))
-    depends_on("python@3.6.1:3", when="@5:5.10", type=("build", "run"))
+    with default_args(type=("build", "run")):
+        depends_on("python@3.8:", when="@5.12:")
+        depends_on("python@3.7:", when="@5.11")
+        # This needs to be @3.6 since for bootstrapping the current Spack interpreter is
+        # identified by major.minor (and the new versioning identifies it as @=3.6)
+        depends_on("python@3.6:3", when="@5.10")
+        depends_on("python@3.6:3", when="@5.9")
+
+    conflicts("python@3.6.0", when="@5:")
+
     depends_on("py-setuptools", when="@:4", type=("build", "run"))
     depends_on("py-poetry-core@1:", when="@5:", type="build")
     depends_on("py-colorama@0.4.3:", when="+colors @5.12:", type=("build", "run"))


Test patch: