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

fix numpy hack in setup.py #3416

Merged
merged 1 commit into from
Dec 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,26 @@ class CustomBuildExt(build_ext):
"""Custom build_ext action with bootstrapping.

We need this in order to use numpy and Cython in this script without
importing them at module level, because they may not be available yet.
importing them at module level, because they may not be available at that time.
"""
#
# Prevent numpy from thinking it is still in its setup process
# http://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py
#
def finalize_options(self):
build_ext.finalize_options(self)

import builtins
builtins.__NUMPY_SETUP__ = False

import numpy

#
# Prevent numpy from thinking it is still in its setup process
# http://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py
#
# Newer numpy versions don't support this hack, nor do they need it.
# https://github.com/pyvista/pyacvd/pull/23#issue-1298467701
#
try:
builtins.__NUMPY_SETUP__ = False
except Exception as ex:
print(f'could not use __NUMPY_SETUP__ hack (numpy version: {numpy.__version__}): {ex}')

self.include_dirs.append(numpy.get_include())

if need_cython():
Expand Down