8000 [MRG] Make pip install numpy and scipy for us by barrywhart · Pull Request #10398 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[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
Changes from all commits
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
114 changes: 38 additions & 76 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
else:
extra_setuptools_args = dict()


# Custom clean command to remove build artifacts

class CleanCommand(Clean):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 [])
Copy link
Member

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?


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,
Copy link
Member

Choose a reason for hiding this comment

The 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)

Expand Down
0