Repository: spack/spack

Issue:
Build error using spack mirrors to build py-chardet
### Steps to reproduce the issue
The first snippet of code is py-chardet installing with no issues from a mirror on a system with internet access. 
```console
$ spack mirror create -D py-chardet
$ spack mirror add $name *PATH*/$name
$ spack install py-chardet
==> diffutils is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/diffutils-3.7-ko7qdeieiylfx6v6v3u7jqptrv7lyvoj
==> bzip2 is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/bzip2-1.0.8-hhbrbrhbf5tkbqcg57apuqeg2b7nhich
==> libbsd is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/libbsd-0.9.1-z3iyo2ibak3luzwebdwmoganb4x4orje
==> expat is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/expat-2.2.5-cn2qjequsqaizlcxsvr74gq4rntgl5zn
==> pkgconf is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/pkgconf-1.6.1-zyia6fm5vvznsxxla43wto6vezv3jciz
==> ncurses is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/ncurses-6.1-rqw3cmcwvd76h4rjgtaxpvrqg47prwkg
==> readline is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/readline-7.0-b4z2xcjalfc4z7tgktx7txhe2my3wlfd
==> gdbm is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/gdbm-1.18.1-dv2qksj2dheh7hzmu7iftqhxlkqrinwt
==> libiconv is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/libiconv-1.15-bli6oh4rawy6bwdqa7ylbp7wt5tkynyv
==> xz is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/xz-5.2.4-agv5zlv7phi4ye3evlpv3t4ypgve4bpe
==> zlib is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/zlib-1.2.11-64vg6e4evdrlqgx7iicwhu2hs7lv6gpz
==> libxml2 is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/libxml2-2.9.9-7mziu5hpmcz6mzurl4tnfvr3edkcacjl
==> tar is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/tar-1.31-i3i4p3q35guhtu3qq5n2pr6f227xr7ha
==> gettext is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/gettext-0.19.8.1-osb2am7ooumpqy7dg3njcbzs6x4u4lfy
==> libffi is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/libffi-3.2.1-ksqyb2nne56f3f5z5cfsjwqyjfpnbejl
==> perl is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/perl-5.26.2-7tmxubxk4qnty7decxqsz5yu5v3p3lqq
==> openssl is already installed in*PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/openssl-1.1.1c-4j6vfpkc34grsa5inqmqpxspw77dt6pv
==> sqlite is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/sqlite-3.28.0-jymozgspl2bcxtorqvgcrkf2hbbdkr3s
==> python is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/python-2.7.16-akox7z53z6whefovfhrnidla5g5iqvye
==> py-setuptools is already installed in *PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-7aotd5zamac4vxrlr4l3tliwkqbd44j2
==> Installing py-chardet
==> Searching for binary cache of py-chardet
==> Finding buildcaches in *PATH*/spack/py-chardet-mirror//build_cache
==> No binary for py-chardet found: installing from source
==> Fetching file:///*PATH*/spack/py-chardet-mirror/py-chardet/py-chardet-3.0.2.tar.gz
######################################################################## 100.0%
==> Staging archive: /tmp/spack-stage/calvin/py-chardet-3.0.2-fj2yzc4aynffncjt4t7ykasoozx3n2jj/chardet-3.0.2.tar.gz
==> Created stage in /tmp/spack-stage/calvin/py-chardet-3.0.2-fj2yzc4aynffncjt4t7ykasoozx3n2jj
==> No patches needed for py-chardet
==> Building py-chardet [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed py-chardet
  Fetch: 0.02s.  Build: 2.11s.  Total: 2.13s.
[+] /*PATH*/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/py-chardet-3.0.2-fj2yzc4aynffncjt4t7ykasoozx3n2jj

```
Below is another system without access to the internet with the mirror from above copied over.  


```console
$ spack install py-chardet
==> diffutils is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/diffutils-3.7-q6kg3el76v4ow4besjharxq7pmbk5e77
==> bzip2 is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/bzip2-1.0.8-fslu4eku7nv64btwtycq45jf4iqebzq4
==> libbsd is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/libbsd-0.9.1-li3rs5m2upxtnedr4ym5nujzc3cgiwmh
==> expat is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/expat-2.2.5-7wtpegybe7jlv46j53pzyl7ivxe6v3zr
==> pkgconf is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/pkgconf-1.6.1-painzorzjyprtyujfegxjkfbzl4jtdhn
==> ncurses is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/ncurses-6.1-wkyck363aqihprfuuiipgdmzt6vjk6nk
==> readline is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/readline-7.0-sfsamtunmnste5uxxmlvskfkjz7uhbcj
==> gdbm is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/gdbm-1.18.1-verdgofikxsccbgxxozvdsrnewnc6jgh
==> libiconv is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/libiconv-1.15-vlje6jumvfnor2wlmrq6cfilfi6zm7jt
==> xz is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/xz-5.2.4-rh7gav63dk5xbjp2hq4rtp4wmuwk7slb
==> zlib is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/zlib-1.2.11-vhzh5cfaki5lx5sjuth5iuojq5azdkbd
==> libxml2 is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/libxml2-2.9.9-hionxpggi5cnp3jrsjh7s7fyial4hshv
==> tar is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/tar-1.31-wiqmehfabuu63qb5puqfc6ext3sywhrl
==> gettext is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/gettext-0.19.8.1-h7pjtji5nclu5vibcwpuvj5kerwx6mbk
==> libffi is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/libffi-3.2.1-4s3dshkk5mra3bp2vdxqfasds2sxmzrp
==> perl is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/perl-5.26.2-wa43pmynkm6qb5j7yi7mxo45jmrmi5iz
==> openssl is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/openssl-1.1.1c-otnl3ibgdbsdxtkuqlcnmt2a76tsu3a4
==> sqlite is already installed in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/sqlite-3.28.0-vina3q22pu3ipnjuswwwtwkjalwph34e
==> Installing python
==> Searching for binary cache of python
==> Finding buildcaches on ./spack-mirror-2019-08-22/
==> Warning: Spack will not check SSL certificates. You need to update your Python to enable certificate verification.
==> Finding buildcaches in *PATH*/py-chardet-mirror//build_cache
==> No binary for python found: installing from source
==> Fetching file://*PATH*/py-chardet-mirror/python/python-2.7.16.tgz
######################################################################## 100.0%
==> Staging archive: *PATH*/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/Python-2.7.16.tgz
==> Created stage in *PATH*/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa
==> Ran patch() for python
==> Building python [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Warning: Patched overlong shebang in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/bin/python2-config
==> Warning: Patched overlong shebang in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/bin/pydoc
==> Warning: Patched overlong shebang in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/bin/idle
==> Warning: Patched overlong shebang in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/bin/2to3
==> Warning: Patched overlong shebang in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/bin/smtpd.py
==> Successfully installed python
  Fetch: 0.32s.  Build: 1m 46.89s.  Total: 1m 47.21s.
[+] *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa
==> Installing py-setuptools
==> Searching for binary cache of py-setuptools
==> Finding buildcaches on ./spack-mirror-2019-08-22/
==> Warning: Spack will not check SSL certificates. You need to update your Python to enable certificate verification.
==> Finding buildcaches in *PATH*/py-chardet-mirror//build_cache
==> No binary for py-setuptools found: installing from source
==> Fetching file://*PATH*/py-chardet-mirror/py-setuptools/py-setuptools-41.0.1.zip
######################################################################## 100.0%
==> Staging archive: *PATH*/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/setuptools-41.0.1.zip
==> Created stage in *PATH*/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx
==> No patches needed for py-setuptools
==> Building py-setuptools [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Warning: Patched overlong shebang in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/bin/easy_install
==> Warning: Patched overlong shebang in *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/bin/easy_install-2.7
==> Successfully installed py-setuptools
  Fetch: 0.03s.  Build: 2.70s.  Total: 2.73s.
[+] *PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx
==> Installing py-chardet
==> Searching for binary cache of py-chardet
==> Finding buildcaches on ./spack-mirror-2019-08-22/
==> Warning: Spack will not check SSL certificates. You need to update your Python to enable certificate verification.
==> Finding buildcaches in *PATH*/py-chardet-mirror//build_cache
==> No binary for py-chardet found: installing from source
==> Using cached archive: *PATH*/spack/var/spack/cache/py-chardet/py-chardet-3.0.2.tar.gz
==> Staging archive: *PATH*/py-chardet-3.0.2-2aeirjvr3ekqu4xdi753ishosfdzxo3b/chardet-3.0.2.tar.gz
==> Created stage in *PATH*/py-chardet-3.0.2-2aeirjvr3ekqu4xdi753ishosfdzxo3b
==> No patches needed for py-chardet
==> Building py-chardet [PythonPackage]
==> Executing phase: 'build'
==> Error: ProcessError: Command exited with status 1:
    '*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/bin/python2.7' '-s' 'setup.py' '--no-user-cfg' 'build'
See build log for details:
  *PATH*/py-chardet-3.0.2-2aeirjvr3ekqu4xdi753ishosfdzxo3b/spack-build-out.txt

```
Here are the contents of the `spack-build-out.txt`
```console
==> Executing phase: 'build'
==> [2019-08-23-15:56:02.753350] '*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.16-amwgjf5cxfwuyk5x5x4jge5gn56vkhfa/bin/python2.7' '-s' 'setup.py' '--no-user-cfg' 'build'
Download error on https://pypi.org/simple/pytest-runner/: [Errno 97] Address family not supported by protocol -- Some packages may not be found!
Couldn't find index page for 'pytest-runner' (maybe misspelled?)
Download error on https://pypi.org/simple/: [Errno 97] Address family not supported by protocol -- Some packages may not be found!
No local packages or working download links found for pytest-runner
Traceback (most recent call last):
  File "setup.py", line 52, in <module>
    ['chardetect = chardet.cli.chardetect:main']})
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/setuptools/__init__.py", line 144, in setup
    _install_setup_requires(attrs)
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/setuptools/dist.py", line 717, in fetch_build_eggs
    replace_conflicting=True,
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/pkg_resources/__init__.py", line 782, in resolve
    replace_conflicting=replace_conflicting
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1065, in best_match
    return self.obtain(req, installer)
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1077, in obtain
    return installer(requirement)
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/setuptools/dist.py", line 784, in fetch_build_egg
    return cmd.easy_install(req)
  File "*PATH*/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-setuptools-41.0.1-oczl4htyiutqfuhwmi2bqv4zmoytujkx/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 673, in easy_install
    raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pytest-runner')
```

### Platform and user environment
linux-rhel7-x86_64

### Additional information
It would appear despite the mirror, py-chardet is still trying to reach out to the internet. 
Difference between the two machines centos7(worked) -> rhel7(failed)



Discussion:
It appears the `py-chardet` requires `pytest-runner`: it looks like this dependency is not currently recorded in the Spack `py-chardet` package. Adding `py-pytest-runner` as a `py-chardet` dependency (I think the `build` deptype is appropriate) should resolve this issue.

Could you confirm that addresses your issue? If so I can submit a PR to make that change (or you can do so and I'll merge it).
Sorry for the late response. Adding `depends_on('py-pytest-runner', type='build')` inside of `py-chardet/package.py` fixes the issue and charliecloud/0.10 can build fully from the mirror now. 
Thanks for your help. 

 I don't have correct access rights to make my own branch so If you just want to submit a PR I'd appreciate it. 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-chardet/package.py b/var/spack/repos/builtin/packages/py-chardet/package.py
--- a/var/spack/repos/builtin/packages/py-chardet/package.py
+++ b/var/spack/repos/builtin/packages/py-chardet/package.py
@@ -16,3 +16,4 @@ class PyChardet(PythonPackage):
     version('2.3.0', '25274d664ccb5130adae08047416e1a8')
 
     depends_on('py-setuptools', type='build')
+    depends_on('py-pytest-runner', type='build')


Test patch: