Commit cbc3f787 authored by Josiah Johnston's avatar Josiah Johnston Committed by Mat
Browse files

Stop crashing during installation when numpy isn't already installed.

Update setup.py to list numpy as a pre-requisite and skip the correct
guess of the include directory if numpy hasn't been installed yet. To
test, start a fresh virtual environment and run `pip install
SharedArray`. It crashes without this fix and installs with this fix.
parent 6e34fae2
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -20,7 +20,14 @@ from distutils.core import setup, Extension
from glob import glob
from os import path
import sys

# Fail gracefully if numpy isn't installed
try:
    import numpy
    include_dirs = [numpy.get_include()]
except:
    include_dirs = []


# Convert a file to reStructuredText with pypandoc, when available,
# otherwise return the raw file.
@@ -61,9 +68,10 @@ setup(name = 'SharedArray',
      ],

      # Compilation
      install_requires=['numpy'],
      ext_modules  = [
          Extension('SharedArray',
                    glob(path.join('.', 'src', '*.c')),
                    libraries = [ 'rt' ] if sys.platform.startswith('linux') else [],
                    include_dirs=[numpy.get_include()])
                    include_dirs=include_dirs)
      ])