internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spack/spack

Issue:
gcc 7.2.0 version is not detected correctly on Ubuntu 16.04
`spack compiler find` does not pick the GCC7.2.0 version correctly:
```
- compiler:
    environment: {}
    extra_rpaths: []
    flags: {}
    modules: []
    operating_system: ubuntu16.04
    paths:
      cc: /usr/bin/gcc-7
      cxx: /usr/bin/g++-7
      f77: null
      fc: null
    spec: gcc@7
    target: x86_64
```
however
```
$ gcc-7 --version
gcc-7 (Ubuntu 7.2.0-1ubuntu1~16.04) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

Spack picked up gcc 5 and 6 perfectly fine though:
```
- compiler:
    environment: {}
    extra_rpaths: []
    flags: {}
    modules: []
    operating_system: ubuntu16.04
    paths:
      cc: /usr/bin/gcc-6
      cxx: /usr/bin/g++-6
      f77: /usr/bin/gfortran-6
      fc: /usr/bin/gfortran-6
    spec: gcc@6.3.0
    target: x86_64
- compiler:
    environment: {}
    extra_rpaths: []
    flags: {}
    modules: []
    operating_system: ubuntu16.04
    paths:
      cc: /usr/bin/gcc-5
      cxx: /usr/bin/g++-5
      f77: /usr/bin/gfortran-5
      fc: /usr/bin/gfortran-5
    spec: gcc@5.4.1
    target: x86_64g
```


Discussion:
Same issue on fedora 27

```
$ gcc --version
gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ spack compiler find
==> Added 2 new compilers to /home/balay/.spack/linux/compilers.yaml
    gcc@7  clang@4.0.1
==> Compilers are defined in the following files:
    /home/balay/.spack/linux/compilers.yaml
```

This affects code of type:

```
depends_on('plasma',when='@0.3.0-rc1 %gcc@7.0:')
```

I should try gcc@7:
That's because the default implementation for compilers calls `$compiler -dumpversion`. This is indeed `7` on with GCC 7.2.0.
Ah, there is now `-dumpfullversion` for GCC 7. I'll work on a patch.

Resolving patch:
diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py
--- a/lib/spack/spack/compilers/gcc.py
+++ b/lib/spack/spack/compilers/gcc.py
@@ -97,7 +97,10 @@ def default_version(cls, cc):
         if spack.compilers.clang.Clang.default_version(cc) != 'unknown':
             return 'unknown'
 
-        return super(Gcc, cls).default_version(cc)
+        version = super(Gcc, cls).default_version(cc)
+        if version in ['7']:
+            version = get_compiler_version(cc, '-dumpfullversion')
+        return version
 
     @classmethod
     def fc_version(cls, fc):


Test patch:
Repository: spack/spack

Issue:
bdftopcf not building due to missing xproto dep
when building on CentOS cluster :
spack install bdftopcf

fail

  >> 80    checking for BDFTOPCF... configure: error: Package requirements (xfont) were not met:
     81    
     82    Package 'xproto', required by 'xfont', not found



Discussion:
Hmm, I'm seeing `xproto` in the dependency tree, so something is off with being able to find it.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/bdftopcf/package.py b/var/spack/repos/builtin/packages/bdftopcf/package.py
--- a/var/spack/repos/builtin/packages/bdftopcf/package.py
+++ b/var/spack/repos/builtin/packages/bdftopcf/package.py
@@ -41,4 +41,6 @@ class Bdftopcf(AutotoolsPackage):
     depends_on('libxfont')
 
     depends_on('pkg-config@0.9.0:', type='build')
+    depends_on('xproto', type='build')
+    depends_on('fontsproto', type='build')
     depends_on('util-macros', type='build')


Test patch:
Repository: spack/spack

Issue:
spack fetch --dependencies attempts to download 'buildable: False'
`spack fetch --dependencies`  attempts to download 'buildable: False' packages - and then aborts when things are not found.

Ideally it should not attempt to download such stuff.

or provide an option to continue with downloading other packages [on error with current package]


Discussion:
package.py
  ```
hdf5:
    modules:
      hdf5@1.10.0.3%intel@18.0.0.128+hl+fortran arch=cray-CNL-mic_knl: cray-hdf5-parallel/1.10.0.3
    buildable: False
```

```
balay@thetalogin5:~/spack> spack fetch --dependencies xsdk
==> Using cached archive: /gpfs/mira-home/balay/spack/var/spack/cache/xsdk/xsdk-0.3.0-rc1.tar.gz
==> Using cached archive: /gpfs/mira-home/balay/spack/var/spack/cache/alquimia/alquimia-xsdk-0.3.0.tar.gz
==> Warning: Fetching from mirror without a checksum!
  This package is normally checked out from a version control system, but it has been archived on a spack mirror.  This means we cannot know a checksum for the tarball in advance. Be sure that your connection to this mirror is secure!
==> Using cached archive: /gpfs/mira-home/balay/spack/var/spack/cache/cmake/cmake-3.5.2.tar.gz
==> Warning: There is no checksum on file to fetch hdf5@1.10.0.3 safely.
==>   Fetch anyway? [y/N] y
==> Fetching with no checksum.
  Add a checksum or use --no-checksum to skip this check.
==> Fetching https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.0.3/src/hdf5-1.10.0.3.tar.gz

curl: (22) The requested URL returned error: 404 Not Found
==> Fetching from https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.0.3/src/hdf5-1.10.0.3.tar.gz failed.
==> Can not find version 1.10.0.3 in url_list
==> Error: All fetchers failed for hdf5-1.10.0.3-e3fhnr5otsva35cmpfa4w6dcjk6o6w4h
balay@thetalogin5:~/spack> 

```

Resolving patch:
diff --git a/lib/spack/spack/cmd/fetch.py b/lib/spack/spack/cmd/fetch.py
--- a/lib/spack/spack/cmd/fetch.py
+++ b/lib/spack/spack/cmd/fetch.py
@@ -40,7 +40,7 @@ def setup_parser(subparser):
         help="do not check packages against checksum")
     subparser.add_argument(
         '-m', '--missing', action='store_true',
-        help="also fetch all missing dependencies")
+        help="fetch only missing (not yet installed) dependencies")
     subparser.add_argument(
         '-D', '--dependencies', action='store_true',
         help="also fetch all dependencies")
@@ -61,8 +61,15 @@ def fetch(parser, args):
         if args.missing or args.dependencies:
             for s in spec.traverse():
                 package = spack.repo.get(s)
+
+                # Skip already-installed packages with --missing
                 if args.missing and package.installed:
                     continue
+
+                # Do not attempt to fetch externals (they're local)
+                if package.spec.external:
+                    continue
+
                 package.do_fetch()
 
         package = spack.repo.get(spec)


Test patch:
Repository: spack/spack

Issue:
petsc: fix pkgconfig error - with incorrect library link order that c…
…an break mfem examples with static build

cc: @keitat


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/petsc/package.py b/var/spack/repos/builtin/packages/petsc/package.py
--- a/var/spack/repos/builtin/packages/petsc/package.py
+++ b/var/spack/repos/builtin/packages/petsc/package.py
@@ -42,6 +42,7 @@ class Petsc(Package):
     version('develop', git='https://bitbucket.org/petsc/petsc.git', tag='master')
     version('xsdk-0.2.0', git='https://bitbucket.org/petsc/petsc.git', tag='xsdk-0.2.0')
 
+    version('3.8.2', '00666e1c4cbfa8dd6eebf91ff8180f79')
     version('3.8.1', '3ed75c1147800fc156fe1f1e515a68a7')
     version('3.8.0', '02680f1f78a0d4c5a9de80a366793eb8')
     version('3.7.7', 'c2cfb76677d32839810c4cf51a2f9cf5')


Test patch:
Repository: spack/spack

Issue:
incorrect use of multi-line statement in directives.py
There are a couple places in lib/spack/spack/directives.py that
(incorrectly) try to concatenate string literals across multiple
lines, but the first line is not escaped or inside a scope.  As a
result, python treats the statement as a single line, and half of the
error message goes missing.

For example, in directives.py:

523     # Check if the path is relative
524     if os.path.isabs(destination):
525         message = 'The destination keyword of a resource directive '
526         'can\'t be an absolute path.\n'
527         message += "\tdestination : '{dest}\n'".format(dest=destination)
528         raise RuntimeError(message)

536     if test_path not in normalized_destination:
537         message = "The destination folder of a resource must fall "
538         "within the main package stage directory.\n"
539         message += "\tdestination : '{dest}'\n".format(dest=destination)
540         raise RuntimeError(message)

A simple way to trigger the problem is to set destination="/tmp" (an
illegal value) in package.py for package lua and then try to install it.

$ ./spack install lua  
==> Error: The destination keyword of a resource directive  destination : '/tmp
'

A simple fix is to put the two string literals inside a scope (or else
escape the first line).

  message = ('The destination keyword of a resource directive '
      'can\'t be an absolute path.\n')

Btw, the close quote for '{dest}' is misplaced in line 527, it should
come before \n, as in line 539.

--Mark




Discussion:

Resolving patch:
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -522,8 +522,8 @@ def _execute_resource(pkg):
 
         # Check if the path is relative
         if os.path.isabs(destination):
-            message = 'The destination keyword of a resource directive '
-            'can\'t be an absolute path.\n'
+            message = ('The destination keyword of a resource directive '
+                       'can\'t be an absolute path.\n')
             message += "\tdestination : '{dest}\n'".format(dest=destination)
             raise RuntimeError(message)
 
@@ -534,8 +534,8 @@ def _execute_resource(pkg):
         )  # Normalized absolute path
 
         if test_path not in normalized_destination:
-            message = "The destination folder of a resource must fall "
-            "within the main package stage directory.\n"
+            message = ("The destination folder of a resource must fall "
+                       "within the main package stage directory.\n")
             message += "\tdestination : '{dest}'\n".format(dest=destination)
             raise RuntimeError(message)
 


Test patch:
Repository: spack/spack

Issue:
new warnings about the contents of the archive
Looks like Spack started to falsely report warnings about the tarbals. Happens for `openmpi`, `boost`, `xz`, `hwloc`, `expat` and maybe others.

### Expected Result

no warnigs

### Actual Result

```
==> Installing openmpi
==> Fetching http://www.open-mpi.org/software/ompi/v3.0/downloads/openmpi-3.0.0.tar.bz2
######################################################################## 100.0%
==> Warning: The contents of
  the archive
   look like HTML.
  The checksum will likely be bad.  If it is, you can use
  'spack clean <package>' to remove the bad archive, then
  fix your internet gateway issue and install again.
==> Staging archive: /spack/var/spack/stage/openmpi-3.0.0-qj2jvimfe4js4w5od2xkctlwln7kisja/openmpi-3.0.0.tar.bz2
==> Created stage in /spack/var/spack/stage/openmpi-3.0.0-qj2jvimfe4js4w5od2xkctlwln7kisja
==> No patches needed for openmpi
==> Building openmpi [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed openmpi
  Fetch: 3.37s.  Build: 19m 0.53s.  Total: 19m 3.91s.
```

### Steps to reproduce the issue

```console
$ spack install openmpi
```

### Information on your system

macOS 10.13.1 


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -276,7 +276,8 @@ def fetch(self):
         # Check if we somehow got an HTML file rather than the archive we
         # asked for.  We only look at the last content type, to handle
         # redirects properly.
-        content_types = re.findall(r'Content-Type:[^\r\n]+', headers)
+        content_types = re.findall(r'Content-Type:[^\r\n]+', headers,
+                                   flags=re.IGNORECASE)
         if content_types and 'text/html' in content_types[-1]:
             tty.warn("The contents of ",
                      (self.archive_file if self.archive_file is not None


Test patch:
Repository: spack/spack

Issue:
OpenBlas doesn't need f77 it needs fc
==> Installing openblas
==> Using cached archive: /home/ben/Work/spack/var/spack/cache/openblas/openblas-0.2.20.tar.gz
==> Already staged openblas-0.2.20-6rryp2gmzgl2vn36b4vfosfyi4ddkgcc in /home/ben/Work/spack/var/spack/stage/openblas-0.2.20-6rryp2gmzgl2vn36b4vfosfyi4ddkgcc
==> Already patched openblas
==> Building openblas [MakefilePackage]
==> Executing phase: 'edit'
==> Error: InstallError: OpenBLAS requires both C and Fortran compilers!
InstallError: InstallError: OpenBLAS requires both C and Fortran compilers!

/home/ben/Work/spack/var/spack/repos/builtin/packages/openblas/package.py:95, in check_compilers:
     4             # require both.
     5             if self.compiler.f77 is None:
     6                 raise InstallError(
  >> 7                     'OpenBLAS requires both C and Fortran compilers!'
     8                 )
     9             # Add support for OpenMP
     10            if (self.spec.satisfies('threads=openmp') and

See build log for details:
  /home/ben/Work/spack/var/spack/stage/openblas-0.2.20-6rryp2gmzgl2vn36b4vfosfyi4ddkgcc/OpenBLAS-0.2.20/spack-build.out

Changing /home/ben/Work/spack/var/spack/repos/builtin/packages/openblas/package.py from self.compiler.f77 to self.compiler.fc fixed the problem.


Discussion:
@davydden : Is `f77 or fc` sufficient for OpenBLAS?
I think it’s a bug indeed: openblas needs FC not F77.
https://github.com/xianyi/OpenBLAS/wiki/Installation-Guide


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py
--- a/var/spack/repos/builtin/packages/openblas/package.py
+++ b/var/spack/repos/builtin/packages/openblas/package.py
@@ -98,10 +98,11 @@ def check_compilers(self):
         # As of 06/2016 there is no mechanism to specify that packages which
         # depends on Blas/Lapack need C or/and Fortran symbols. For now
         # require both.
-        if self.compiler.f77 is None:
+        if self.compiler.fc is None:
             raise InstallError(
                 'OpenBLAS requires both C and Fortran compilers!'
             )
+
         # Add support for OpenMP
         if (self.spec.satisfies('threads=openmp') and
             self.spec.satisfies('%clang')):
@@ -116,7 +117,7 @@ def check_compilers(self):
 
     @property
     def make_defs(self):
-        # Configure fails to pick up fortran from FC=/abs/path/to/f77, but
+        # Configure fails to pick up fortran from FC=/abs/path/to/fc, but
         # works fine with FC=/abs/path/to/gfortran.
         # When mixing compilers make sure that
         # $SPACK_ROOT/lib/spack/env/<compiler> have symlinks with reasonable
@@ -124,7 +125,7 @@ def make_defs(self):
 
         make_defs = [
             'CC={0}'.format(spack_cc),
-            'FC={0}'.format(spack_f77),
+            'FC={0}'.format(spack_fc),
             'MAKE_NO_J=1'
         ]
 


Test patch:
Repository: spack/spack

Issue:
QT not found when building octave+qt
QT library cannot be found when building `octave` with `+qt`, which leads to unavailability of GUI in Octave.

### Expected Result

QT library is found during `configue` of Octave then it is built with qt-based GUI support.

### Actual Result

`configure` reports QT is not found, thus it proceeds to build octave without GUI support.

### Steps to reproduce the issue

```console
$ spack install --keep-stage octave+qt+gnuplot@4.2.1 %gcc@5.4.0 ^openblas threads=openmp
$ grep 'QT\|GUI' spack-build.out
configure: defining OCTGUI_DLL_DEFS to be 
checking Qt version 5... checking for QT... no
checking Qt version 4... checking for QT... no
configure: WARNING: Qt libraries not found; disabling Qt GUI
  Build Octave Qt GUI:                no
configure: WARNING: Qt libraries not found; disabling Qt GUI
```
[spack-build.txt](https://github.com/spack/spack/files/1484716/spack-build.txt)


### Information on your system

I am using on CentOS 7.3 without qt-relative customization on `packages.yaml`.


Discussion:
I found NO settings like `--with-qt-includedir` or `--with-qt-libdir` in Octave's `configure` file. It determines Qt's location by `pkg-config` and by somehow fails to find Qt installed by Spack. Any suggestion on handling this issue?

[configure.txt](https://github.com/spack/spack/files/1484746/configure.txt)
[octave-package.py.txt](https://github.com/spack/spack/files/1484747/octave-package.py.txt)


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/octave/package.py b/var/spack/repos/builtin/packages/octave/package.py
--- a/var/spack/repos/builtin/packages/octave/package.py
+++ b/var/spack/repos/builtin/packages/octave/package.py
@@ -99,7 +99,7 @@ class Octave(AutotoolsPackage):
     depends_on('qhull',        when='+qhull')
     depends_on('qrupdate',     when='+qrupdate')
     # depends_on('qscintilla',  when='+qscintilla) # TODO: add package
-    depends_on('qt',           when='+qt')
+    depends_on('qt+opengl',    when='+qt')
     depends_on('suite-sparse', when='+suitesparse')
     depends_on('zlib',         when='+zlib')
 


Test patch:
Repository: spack/spack

Issue:
Package Syntax Error: Error Message
### Expected Result

Spack build recipes in a `package.py` might accidentally contain python syntax errors. This happens quickly when dealing with experimental branches or external repositories.

When trying to install such a wrongly formatted package *or even just a package that depends on it* the `spack install` error message should tell the user *which* file contains the syntax error

### Actual Result

Instead, `spack install` only returns:
```bash
spack install packageName
==> Error: invalid syntax (package.py, line 42)
```

Note: this also affects commands such as `spack spec packageName`.

### Steps to reproduce the issue

Apply the following diff to produce a failing `tar` package:
```diff
--- a/var/spack/repos/builtin/packages/tar/package.py
+++ b/var/spack/repos/builtin/packages/tar/package.py
@@ -38,5 +38,5 @@ class Tar(AutotoolsPackage):
     patch('tar-pgi.patch',    when='@1.29')
     patch('config-pgi.patch', when='@:1.29')
     patch('se-selinux.patch', when='@:1.29')
-    patch('argp-pgi.patch',   when='@:1.29')
+    patch('argp-pgi.patch',   when='@:1.29'
     patch('gnutar-configure-xattrs.patch', when='@1.28')
```

Now try to install tar:
```console
$ spack install tar
==> Error: invalid syntax (package.py, line 42)
```

huh! *which* `package.py` is ment? The one in `builtin`? The one of my second repo?

It get's even more complicated when installing a package that *depends* on `tar` but itself has correct syntax:

```console
$ spack install gettext
==> Error: invalid syntax (package.py, line 42)
```

Now one would recusively walk through all dependencies to find the failing file.

### Information on your system

A standard Debian 9.2 "stretch" and spack `develop` as of 77bfda4da6f30f06762d749e0d83854d3a34dc6d .


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/repository.py b/lib/spack/spack/repository.py
--- a/lib/spack/spack/repository.py
+++ b/lib/spack/spack/repository.py
@@ -987,7 +987,14 @@ def _get_pkg_module(self, pkg_name):
             # e.g., spack.pkg.builtin.mpich
             fullname = "%s.%s" % (self.full_namespace, pkg_name)
 
-            module = imp.load_source(fullname, file_path)
+            try:
+                module = imp.load_source(fullname, file_path)
+            except SyntaxError as e:
+                # SyntaxError strips the path from the filename so we need to
+                # manually construct the error message in order to give the
+                # user the correct package.py where the syntax error is located
+                raise SyntaxError('invalid syntax in {0:}, line {1:}'
+                                  ''.format(file_path, e.lineno))
             module.__package__ = self.full_namespace
             module.__loader__ = self
             self._modules[pkg_name] = module


Test patch:
Repository: spack/spack

Issue:
spack install should do "--restage" by default
It has happened to me many times already that a package fails to build simply because the old source code is already staged (from a previous either failed or interrupted build). This happens due to the fact that many packages can't be configured twice, they simply fail to build the second time. It's extremely annoying when I run "spack install", go home, and then discover that it failed a few minutes after I left my office.

I think that "--restage" should be the default behavior, and there should be an option "--no-restage" or "--keep-stage" or something to reuse the old stage.


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -71,8 +71,8 @@ def setup_parser(subparser):
         '--keep-stage', action='store_true',
         help="don't remove the build stage if installation succeeds")
     subparser.add_argument(
-        '--restage', action='store_true',
-        help="if a partial install is detected, delete prior state")
+        '--dont-restage', action='store_true',
+        help="if a partial install is detected, don't delete prior state")
     subparser.add_argument(
         '--use-cache', action='store_true', dest='use_cache',
         help="check for pre-built Spack packages in mirrors")
@@ -392,7 +392,7 @@ def install(parser, args, **kwargs):
     kwargs.update({
         'keep_prefix': args.keep_prefix,
         'keep_stage': args.keep_stage,
-        'restage': args.restage,
+        'restage': not args.dont_restage,
         'install_source': args.install_source,
         'install_deps': 'dependencies' in args.things_to_install,
         'make_jobs': args.jobs,
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1343,6 +1343,12 @@ def do_install(self,
                 msg = '{0.name} is already installed in {0.prefix}'
                 tty.msg(msg.format(self))
                 rec = spack.store.db.get_record(self.spec)
+                # In case the stage directory has already been created,
+                # this ensures it's removed after we checked that the spec
+                # is installed
+                if keep_stage is False:
+                    self.stage.destroy()
+
                 return self._update_explicit_entry_in_db(rec, explicit)
 
         self._do_install_pop_kwargs(kwargs)


Test patch: