Postpone importing numpy until compiling starts #27
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 lazy evaluation enables CVXcanon to be pip installed even if numpy isn't
separately installed beforehand, because pip is able to interpret the
requirements from setup.py. Previously, since the setup file for CVXcanon began
by importing numpy, pip would error if numpy wasn't already installed.
For example, suppose your requirements.txt is like
and run
pip install -r requirements.txt
to install those packages,pip checks dependencies written in install_requires in setup.py in order to
install those dependencies before compiling CVXcanon starts.
However, since setup.py imports numpy at the top, this checking step fails due
to an import error.
This pull request introduces a lazy import of numpy to postpone importing
it until actual compiling phase starts, and it allows pip to evaluate setup.py
and install dependencies first.
After numpy and scipy are installed, the compiling CVXcanon phase starts.
pip now evaluates the lazy import to obtain the include path of numpy.
At the time, since numpy has been installed, no import error raises.
You will also no longer need
pip install numpy
as a first step in the CVXcanoninstallation instructions, if missing it will be installed when CVXcanon is pip
installed.