Skip to content

Commit

Permalink
Handle module __builtins__ both as dict or module (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
rffontenelle authored Mar 15, 2024
1 parent 10607cd commit 2f565c7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,21 @@
sys.exit(1)


def set_builtin(name, value):
if isinstance(__builtins__, dict):
__builtins__[name] = value
else:
# to support https://github.com/pypa/build
# see https://github.com/jopohl/urh/issues/1106
setattr(__builtins__, name, value)


class build_ext(_build_ext):
def finalize_options(self):
print("Finalizing options")
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
set_builtin("__NUMPY_SETUP__", False)
import numpy

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

0 comments on commit 2f565c7

Please sign in to comment.