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

Implement numpy hack in setup.py to enable install under Poetry #3363

Merged
merged 2 commits into from
Dec 3, 2022
Merged
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,15 @@ def finalize_options(self):
build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
# https://docs.python.org/2/library/__builtin__.html#module-__builtin__
__builtins__.__NUMPY_SETUP__ = False
try:
__builtins__.__NUMPY_SETUP__ = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

This particular part appears to be for Python 2 - we don't need it, right?

except:
try:
# For python 3
import builtins
builtins.__NUMPY_SETUP__ = False
except:
print("Skipping numpy hack; if installation fails, try installing numpy first")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What exception can possibly get raised here?

Assuming that some exception can, then a explicit error message would be better:

Suggested change
print("Skipping numpy hack; if installation fails, try installing numpy first")
print("Skipping numpy hack; if gensim installation fails, try installing numpy first")

Also, may as well output the reason why the hack failed (what exception was caught) and a trace.


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