spack/bin
Todd Gamblin 97980a8f94 prefer Python 3 to Python 2 for running Spack
The Python landscape is going to be changing in 2020, and Python 2 will
be end of life. Spack should *prefer* Python 3 to Python 2 by default,
but we still need to run on systems that only have Python2 available.

This is trickier than it sounds, as on some systems, the `python` command
is `python2`; on others it's `python3`, and RHEL8 doesn't even have the
`python` command.  Instead, it makes you choose `python3` or
`python2`. You can thus no longer make a simple shebang to handle all the
cases.

This commit makes the `spack` script bilingual.  It is still valid
Python, but its shebang is `#!/bin/sh`, and it has a tiny bit of shell
code at the beginning to pick the right python and execute itself with
what it finds.

This has a lot of advantages.  I think this will help ensure that Spack
works well in Python3 -- there are cases where we've missed things
because Python2 is still the default `python` on most systems.  Also,
with this change, you do not lose the ability to execute the `spack`
script directly with a python interpreter.  This is useful for forcing
your own version of python, running coverage tools, and running profiling
tools.  i.e., these will not break with this change:

```console
$ python2 $(which spack) <args>
$ coverage run $(which spack) <args>
$ pyinstrument $(which spack) <args>
```

These would not work if we split `spack` into a python file and a shell
script (see #11783).  So, this gives us the best of both worlds.  We get
to control our interpreter *and* remain a mostly pure python executable.
2019-09-29 09:32:04 -07:00
..
generate-gitlab-ci-yml.sh Fixes identified in ecp facilities hackathon fixes: 2019-09-13 22:57:15 -07:00
rebuild-index.sh release workflow: Add build scripts for jobs and means to upload pkgs 2019-02-21 15:37:35 -06:00
rebuild-package.sh Implement an optional compiler bootstrapping phase 2019-09-13 22:57:15 -07:00
sbang copyright: update license headers for 2013-2019 copyright. 2019-01-01 00:44:28 -08:00
spack prefer Python 3 to Python 2 for running Spack 2019-09-29 09:32:04 -07:00
spack-python copyright: update license headers for 2013-2019 copyright. 2019-01-01 00:44:28 -08:00