Repository: spack/spack

Issue:
py-astropy@2.0.14 build error: option -j not recognized
### Steps to reproduce the issue
A recent addition to the package file for parallel build seems to break it for earlier versions as shown below. Once I disabled the `'-j', str(make_jobs),` build arg, v2.0.14 builds just fine. I am guessing the parallel build option must have been introduced in the later versions of the package.

```console
$ spack install py-astropy@2.0.14 ^python@2.7.16
... 
==> Installing py-astropy
==> Searching for binary cache of py-astropy
==> Warning: No Spack mirrors are currently configured
==> No binary for py-astropy found: installing from source
==> Using cached archive: /mnt/local/spack/var/spack/cache/py-astropy/py-astropy-2.0.14.tar.gz
==> Staging archive: /cache/sbulut/spack-stage/py-astropy-2.0.14-rbk3kevz63ex6xyknnp2qa6qxacxmaob/astropy-2.0.14.tar.gz
==> Created stage in /cache/sbulut/spack-stage/py-astropy-2.0.14-rbk3kevz63ex6xyknnp2qa6qxacxmaob
==> No patches needed for py-astropy
==> Building py-astropy [PythonPackage]
==> Executing phase: 'build'
==> Error: ProcessError: Command exited with status 1:
    '/mnt/local/spack/opt/spack/linux-centos7-x86_64/gcc-7.4.0/python-2.7.16-acz7a4g4lll7ombmgcoyykrjpfhc7xct/bin/python2.7' '-s' 'setup.py' '--no-user-cfg' 'build' '-j' '12
' '--use-system-libraries' '--use-system-erfa' '--use-system-wcslib' '--use-system-cfitsio' '--use-system-expat'

1 error found in build log:
     2    ==> [2019-10-09-21:26:07.070697] '/mnt/local/spack/opt/spack/linux-centos7-
          x86_64/gcc-7.4.0/python-2.7.16-acz7a4g4lll7ombmgcoyykrjpfhc7xct/bin/python2
          .7' '-s' 'setup.py' '--no-user-cfg' 'build' '-j' '12' '--use-system-librari
          es' '--use-system-erfa' '--use-system-wcslib' '--use-system-cfitsio' '--use
          -system-expat'
     3    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     4       or: setup.py --help [cmd1 cmd2 ...]
     5       or: setup.py --help-commands
     6       or: setup.py cmd --help
     7    
  >> 8    error: option -j not recognized
```

### Platform and user environment

Centos 7.6



Discussion:
```console
$ python3 setup.py build --help
Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package

Global options:
  --verbose (-v)  run verbosely (default)
  --quiet (-q)    run quietly (turns verbosity off)
  --dry-run (-n)  don't actually do anything
  --help (-h)     show detailed help message
  --no-user-cfg   ignore pydistutils.cfg in your home directory

Options for 'build' command:
  --build-base (-b)       base directory for build library
  --build-purelib         build directory for platform-neutral distributions
  --build-platlib         build directory for platform-specific distributions
  --build-lib             build directory for all distribution (defaults to
                          either build-purelib or build-platlib
  --build-scripts         build directory for scripts
  --build-temp (-t)       temporary build directory
  --plat-name (-p)        platform name to build for, if supported (default:
                          macosx-10.14-x86_64)
  --compiler (-c)         specify the compiler type
  --parallel (-j)         number of parallel build jobs
  --debug (-g)            compile extensions and libraries with debugging
                          information
  --force (-f)            forcibly build everything (ignore file timestamps)
  --executable (-e)       specify final destination interpreter path
                          (build.py)
  --use-system-libraries  Use system libraries whenever possible
  --use-system-erfa       Use the system erfa library
  --use-system-wcslib     Use the system wcslib library
  --use-system-cfitsio    Use the system cfitsio library
  --use-system-expat      Use the system expat library
  --help-compiler         list available compilers

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help
```
Maybe it's exclusive to Python 3? This is with Astropy 2.0.14 and 1.1.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-astropy/package.py b/var/spack/repos/builtin/packages/py-astropy/package.py
--- a/var/spack/repos/builtin/packages/py-astropy/package.py
+++ b/var/spack/repos/builtin/packages/py-astropy/package.py
@@ -60,11 +60,15 @@ class PyAstropy(PythonPackage):
     depends_on('expat')
 
     def build_args(self, spec, prefix):
-        return [
-            '-j', str(make_jobs),
+        args = [
             '--use-system-libraries',
             '--use-system-erfa',
             '--use-system-wcslib',
             '--use-system-cfitsio',
             '--use-system-expat'
         ]
+
+        if spec.satisfies('^python@3:'):
+            args.extend(['-j', str(make_jobs)])
+
+        return args


Test patch: