Repository: spack/spack

Issue:
sqlite package breaks spack external find with python 2.7
### Steps to reproduce

on macOS with python 2.7, run:

```
spack external find
```



### Error message

```
Traceback (most recent call last):
  File "spack/bin/spack", line 98, in <module>
    sys.exit(spack.main.main())
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/lib/spack/spack/main.py", line 882, in main
    return _main(argv)
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/lib/spack/spack/main.py", line 865, in _main
    return _invoke_command(command, parser, args, unknown)
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/lib/spack/spack/main.py", line 535, in _invoke_command
    return_val = command(parser, args)
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/lib/spack/spack/cmd/external.py", line 101, in external
    action[args.external_command](args)
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/lib/spack/spack/cmd/external.py", line 75, in external_find
    detected_packages = spack.detection.by_executable(packages_to_check)
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/lib/spack/spack/detection/path.py", line 103, in by_executable
    pkg.determine_spec_details(prefix, exes_in_prefix)
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/lib/spack/spack/package.py", line 211, in determine_spec_details
    variants = cls.determine_variants(exes, version_str)
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/var/spack/repos/builtin/packages/sqlite/package.py", line 116, in determine_variants
    rc_fts5 = call(exe, query_fts(5))
  File "/Users/harrison37/Work/2021_12_spack_hackathon/radiuss-spack-testing/scripts/spack/var/spack/repos/builtin/packages/sqlite/package.py", line 95, in call
    sqlite_stdin.write(query + '\n')
TypeError: NamedTemporaryFile() got an unexpected keyword argument 'buffering'
```

`NamedTemporaryFile()` in  `sqllite` pgk, is using the `buffering` kwarg, which is python 3 only

https://github.com/spack/spack/blob/3d1b9e4dbc31d1cf7d162de5189e858d7d5870f3/var/spack/repos/builtin/packages/sqlite/package.py#L94

### Information on your system

```
spack/bin/spack debug report
* **Spack:** 0.17.0-446-3d1b9e4dbc
* **Python:** 2.7.16
* **Platform:** darwin-mojave-skylake
* **Concretizer:** clingo
[harrison37@elder scripts 
```

### 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:
Duplicate of #27499 

Resolving patch:
diff --git a/lib/spack/spack/detection/path.py b/lib/spack/spack/detection/path.py
--- a/lib/spack/spack/detection/path.py
+++ b/lib/spack/spack/detection/path.py
@@ -9,6 +9,7 @@
 import os
 import os.path
 import re
+import warnings
 
 import llnl.util.filesystem
 import llnl.util.tty
@@ -99,9 +100,14 @@ def by_executable(packages_to_check, path_hints=None):
             # for one prefix, but without additional details (e.g. about the
             # naming scheme which differentiates them), the spec won't be
             # usable.
-            specs = _convert_to_iterable(
-                pkg.determine_spec_details(prefix, exes_in_prefix)
-            )
+            try:
+                specs = _convert_to_iterable(
+                    pkg.determine_spec_details(prefix, exes_in_prefix)
+                )
+            except Exception as e:
+                specs = []
+                msg = 'error detecting "{0}" from prefix {1} [{2}]'
+                warnings.warn(msg.format(pkg.name, prefix, str(e)))
 
             if not specs:
                 llnl.util.tty.debug(


Test patch: