-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] Make pip install numpy and scipy for us #10398
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
Closed
barrywhart
wants to merge
6
commits into
scikit-learn:master
from
barrywhart:issue_7867_build_and_install_requirements
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,6 @@ | |
else: | ||
extra_setuptools_args = dict() | ||
|
||
|
||
# Custom clean command to remove build artifacts | ||
|
||
class CleanCommand(Clean): | ||
|
@@ -137,46 +136,6 @@ def configuration(parent_package='', top_path=None): | |
return config | ||
|
||
|
||
def get_scipy_status(): | ||
""" | ||
Returns a dictionary containing a boolean specifying whether SciPy | ||
is up-to-date, along with the version string (empty string if | ||
not installed). | ||
""" | ||
scipy_status = {} | ||
try: | ||
import scipy | ||
scipy_version = scipy.__version__ | ||
scipy_status['up_to_date'] = parse_version( | ||
scipy_version) >= parse_version(SCIPY_MIN_VERSION) | ||
scipy_status['version'] = scipy_version | ||
except ImportError: | ||
traceback.print_exc() | ||
scipy_status['up_to_date'] = False | ||
scipy_status['version'] = "" | ||
return scipy_status | ||
|
||
|
||
def get_numpy_status(): | ||
""" | ||
Returns a dictionary containing a boolean specifying whether NumPy | ||
is up-to-date, along with the version string (empty string if | ||
not installed). | ||
""" | ||
numpy_status = {} | ||
try: | ||
import numpy | ||
numpy_version = numpy.__version__ | ||
numpy_status['up_to_date'] = parse_version( | ||
numpy_version) >= parse_version(NUMPY_MIN_VERSION) | ||
numpy_status['version'] = numpy_version | ||
except ImportError: | ||
traceback.print_exc() | ||
numpy_status['up_to_date'] = False | ||
numpy_status['version'] = "" | ||
return numpy_status | ||
|
||
|
||
def setup_package(): | ||
metadata = dict(name=DISTNAME, | ||
maintainer=MAINTAINER, | ||
|
@@ -226,41 +185,44 @@ def setup_package(): | |
|
||
metadata['version'] = VERSION | ||
else: | ||
numpy_status = get_numpy_status() | ||
numpy_req_str = "scikit-learn requires NumPy >= {0}.\n".format( | ||
NUMPY_MIN_VERSION) | ||
scipy_status = get_scipy_status() | ||
scipy_req_str = "scikit-learn requires SciPy >= {0}.\n".format( | ||
SCIPY_MIN_VERSION) | ||
|
||
instructions = ("Installation instructions are available on the " | ||
"scikit-learn website: " | ||
"http://scikit-learn.org/stable/install.html\n") | ||
|
||
if numpy_status['up_to_date'] is False: | ||
if numpy_status['version']: | ||
raise ImportError("Your installation of Numerical Python " | ||
"(NumPy) {0} is out-of-date.\n{1}{2}" | ||
.format(numpy_status['version'], | ||
numpy_req_str, instructions)) | ||
else: | ||
raise ImportError("Numerical Python (NumPy) is not " | ||
"installed.\n{0}{1}" | ||
.format(numpy_req_str, instructions)) | ||
if scipy_status['up_to_date'] is False: | ||
if scipy_status['version']: | ||
raise ImportError("Your installation of Scientific Python " | ||
"(SciPy) {0} is out-of-date.\n{1}{2}" | ||
.format(scipy_status['version'], | ||
scipy_req_str, instructions)) | ||
else: | ||
raise ImportError("Scientific Python (SciPy) is not " | ||
"installed.\n{0}{1}" | ||
.format(scipy_req_str, instructions)) | ||
|
||
from numpy.distutils.core import setup | ||
|
||
metadata['configuration'] = configuration | ||
try: | ||
metadata['configuration'] = configuration | ||
from numpy.distutils.core import setup | ||
|
||
metadata['configuration'] = configuration | ||
except ImportError: | ||
try: | ||
from setuptools import setup | ||
except ImportError: | ||
from distutils.core import setup | ||
|
||
build_requires = [] | ||
try: | ||
import numpy # noqa: F401 | ||
except ImportError: # We do not have numpy installed | ||
build_requires += ['numpy>={0}'.format(NUMPY_MIN_VERSION)] | ||
else: | ||
# If we're building a wheel, assume there already exist numpy wheels | ||
# for this platform, so it is safe to add numpy to build requirements. | ||
build_requires += ( | ||
['numpy>={0}'.format(NUMPY_MIN_VERSION)] | ||
if 'bdist_wheel' in sys.argv[1:] else []) | ||
|
||
try: | ||
import scipy # noqa: F401 | ||
except ImportError: # We do not have scipy installed | ||
build_requires += ['scipy>={0}'.format(SCIPY_MIN_VERSION)] | ||
else: | ||
# If we're building a wheel, assume there already exist scipy wheels | ||
# for this platform, so it is safe to add scipy to build requirements. | ||
build_requires += ( | ||
['scipy>={0}'.format(SCIPY_MIN_VERSION)] | ||
if 'bdist_wheel' in sys.argv[1:] else []) | ||
|
||
if build_requires: | ||
metadata.update( | ||
setup_requires=build_requires, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @njsmith was saying we should not use this...? |
||
install_requires=build_requires) | ||
|
||
setup(**metadata) | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be clearer as an if statement rather than appending an empty list.
Also, in the case where we add [], should we be checking that the numpy version meets minimum requirements?