Repository: python-pillow/Pillow

Issue:
Installing pillow 5.0.0 is broken on PPC
### What did you do?
```
$pip install pillow==5.0.0
...
 writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-a8p_j031/pillow/setup.py", line 792, in <module>
        zip_safe=not (debug_build() or PLATFORM_MINGW), )
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/u/kraceku/miniconda3/envs/mdata/lib/python3.6/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/tmp/pip-build-a8p_j031/pillow/setup.py", line 373, in build_extensions
        for path in dirs:
    TypeError: 'NoneType' object is not iterable

    ----------------------------------------
  Rolling back uninstall of Pillow
Command "/u/kraceku/miniconda3/envs/mdata/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a8p_j031/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-77jo7rjr-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-a8p_j031/pillow/
```

### What did you expect to happen?
Installation should have succeeded. This problem doesn't happen on `X86`.

### What actually happened?

Installation failed.

### What versions of Pillow and Python are you using?

Pillow version 5.0.0
```
$ pip --version
pip 9.0.1 from /u/kraceku/miniconda3/envs/mdata/lib/python3.6/site-packages (python 3.6)
$ uname -a
Linux zhcc021 3.10.0-693.11.1.el7.ppc64le #1 SMP Fri Oct 27 05:42:02 EDT 2017 ppc64le ppc64le ppc64le GNU/Linux

```

`pip install pillow==4.3.0` installation goes through .



Discussion:
Sounds like the same thing as https://github.com/python-pillow/Pillow/pull/2923:

What are the values of `platform.architecture()` and `platform.processor()`?

Try changing the `if not platform_:` line to `if not dirs:`
```python
                for platform_ in arch_tp:
                    dirs = libdirs.get(platform_, None)
                    if not dirs:
                        continue
                    for path in dirs:
                        _add_directory(library_dirs, path)
                    break
```
```
In [2]: import platform

In [3]: platform.architecture()
Out[3]: ('64bit', 'ELF')

In [4]: platform.processor()
Out[4]: 'ppc64le'

```
Changing the line to `if not dirs:` worked.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -368,7 +368,7 @@ def build_extensions(self):
 
                 for platform_ in arch_tp:
                     dirs = libdirs.get(platform_, None)
-                    if not platform_:
+                    if not dirs:
                         continue
                     for path in dirs:
                         _add_directory(library_dirs, path)


Test patch: