Resolve Compilation Failure Due to Missing numpy/arrayobject.h #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This merge request introduces a fix to the build process, addressing a compilation failure that occurs when numpy is not installed in the global Python environment. The issue manifests as a missing header file (
numpy/arrayobject.h
), leading to a failure during the compilation offunshade.c
.Problem Description
During the build process, in an environment without a global installation of numpy, the compiler raises a fatal error due to the absence of numpy/arrayobject.h. This issue arises because the build process previously assumed access to numpy's include directories without explicitly specifying them. The error log is as follows:
Reproduce the error
python -m venv env
source env/bin/activate
pip install .
Solution
To address this issue, the proposed change adds a single line of code:
self.include_dirs.append(numpy.get_include())
This addition dynamically appends numpy's include directory to the include_dirs list during the build process. By integrating this line, we ensure that the compiler can locate the necessary numpy header files, regardless of numpy's installation scope (global or virtual environment).