Skip to content

Commit

Permalink
Handle module __builtins__ both as dict or module
Browse files Browse the repository at this point in the history
  • Loading branch information
rffontenelle committed Mar 11, 2024
1 parent 854a84f commit d9a68fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@
)
sys.exit(1)

def set_builtin(name, value):
if isinstance(__builtins__, dict):
__builtins__[name] = value
else:
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 d9a68fa

Please sign in to comment.