Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add numpy as setup requirement #67

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions setup.py
Expand Up @@ -11,16 +11,22 @@
except ImportError:
cythonize = None

include_dirs = []
try:
import numpy

include_dirs.append(numpy.get_include())
except ImportError:
print("Numpy and its headers are required to run setup(). Exiting.")
sys.exit(1)
class get_numpy_include:
"""Helper class to determine the numpy include path
The purpose of this class is to postpone importing numpy
until it is actually installed, so that the ``get_include()``
method can be invoked. """

def __str__(self):
import numpy
return numpy.get_include()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the class is overpriced!
a simple function should be enough

def get_numpy_include():
    import numpy
    yield numpy.get_include()

and the in the setup() do

    include_dirs=[get_numpy_include()],
    setup_requires=["numpy"],

🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:homer:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image



include_dirs = [
get_numpy_include()
]

# Parse the version from the fiona module.
with open("rio_color/__init__.py") as f:
for line in f:
Expand Down Expand Up @@ -90,6 +96,7 @@ def read(fname):
ext_modules=ext_modules,
include_dirs=include_dirs,
extras_require={"test": ["pytest", "colormath==2.0.2", "pytest-cov", "codecov"]},
setup_requires=["numpy"],
entry_points="""
[rasterio.rio_plugins]
color=rio_color.scripts.cli:color
Expand Down