Skip to content

Commit 6297815

Browse files
taionjnothman
authored andcommitted
BLD: Add 'alldeps' extra for installing with pip (scikit-learn#6990)
This allows advanced users who are using standard Python package management tools to install scikit-learn[alldeps], which includes the appropriate numpy and scipy dependencies.
1 parent db56cf4 commit 6297815

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

doc/install.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,22 @@ or ``conda``::
2828

2929
conda install scikit-learn
3030

31-
**We don't recommend installing scipy or numpy using pip on linux**,
32-
as this will involve a lengthy build-process with many dependencies.
33-
Without careful configuration, building numpy yourself can lead to an installation
34-
that is much slower than it should be.
31+
**We don't recommend installing scipy or numpy using pip on Linux**,
32+
as this will involve a lengthy build process with many dependencies.
33+
Without careful configuration, building numpy yourself is likely to lead to an
34+
installation that is much slower than it should be.
3535
If you are using Linux, consider using your package manager to install
3636
scikit-learn. It is usually the easiest way, but might not provide the newest
3737
version.
3838
If you haven't already installed numpy and scipy and can't install them via
39-
your operation system, it is recommended to use a third party distribution.
39+
your operating system, we recommended using a third-party distribution.
40+
41+
If you must install scikit-learn and its dependencies with pip, you can install
42+
it as ``scikit-learn[alldeps]``. We strongly recommend against doing this
43+
unless you are familiar with how to correctly build numpy and scipy. The most
44+
common use case for this is in a ``requirements.txt`` file used as part of an
45+
automated build process for a PaaS application or a Docker image. This option
46+
is not intended for manual installation from the command line.
4047

4148
Third-party Distributions
4249
==========================

setup.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242

4343
VERSION = sklearn.__version__
4444

45+
SCIPY_MIN_VERSION = '0.9'
46+
NUMPY_MIN_VERSION = '1.6.1'
47+
48+
4549
# Optional setuptools features
4650
# We need to import setuptools early, if we want setuptools features,
4751
# as it monkey-patches the 'setup' function
@@ -58,6 +62,12 @@
5862
extra_setuptools_args = dict(
5963
zip_safe=False, # the package can run out of an .egg file
6064
include_package_data=True,
65+
extras_require={
66+
'alldeps': (
67+
'numpy >= {0}'.format(NUMPY_MIN_VERSION),
68+
'scipy >= {0}'.format(SCIPY_MIN_VERSION),
69+
),
70+
},
6171
)
6272
else:
6373
extra_setuptools_args = dict()
@@ -131,10 +141,6 @@ def configuration(parent_package='', top_path=None):
131141
return config
132142

133143

134-
scipy_min_version = '0.9'
135-
numpy_min_version = '1.6.1'
136-
137-
138144
def get_scipy_status():
139145
"""
140146
Returns a dictionary containing a boolean specifying whether SciPy
@@ -146,7 +152,7 @@ def get_scipy_status():
146152
import scipy
147153
scipy_version = scipy.__version__
148154
scipy_status['up_to_date'] = parse_version(
149-
scipy_version) >= parse_version(scipy_min_version)
155+
scipy_version) >= parse_version(SCIPY_MIN_VERSION)
150156
scipy_status['version'] = scipy_version
151157
except ImportError:
152158
scipy_status['up_to_date'] = False
@@ -165,7 +171,7 @@ def get_numpy_status():
165171
import numpy
166172
numpy_version = numpy.__version__
167173
numpy_status['up_to_date'] = parse_version(
168-
numpy_version) >= parse_version(numpy_min_version)
174+
numpy_version) >= parse_version(NUMPY_MIN_VERSION)
169175
numpy_status['version'] = numpy_version
170176
except ImportError:
171177
numpy_status['up_to_date'] = False
@@ -236,10 +242,10 @@ def setup_package():
236242
else:
237243
numpy_status = get_numpy_status()
238244
numpy_req_str = "scikit-learn requires NumPy >= {0}.\n".format(
239-
numpy_min_version)
245+
NUMPY_MIN_VERSION)
240246
scipy_status = get_scipy_status()
241247
scipy_req_str = "scikit-learn requires SciPy >= {0}.\n".format(
242-
scipy_min_version)
248+
SCIPY_MIN_VERSION)
243249

244250
instructions = ("Installation instructions are available on the "
245251
"scikit-learn website: "

0 commit comments

Comments
 (0)