@@ -64,11 +64,11 @@ feature, code or documentation improvement).
64
64
65
65
If you installed Python with conda, we recommend to create a dedicated
66
66
`conda environment `_ with all the build dependencies of scikit-learn
67
- (namely NumPy _, SciPy _, and Cython _ ):
67
+ (namely NumPy _, SciPy _, Cython _, meson-python _ and Ninja _ ):
68
68
69
69
.. prompt :: bash $
70
70
71
- conda create -n sklearn-env -c conda-forge python=3.9 numpy scipy cython
71
+ conda create -n sklearn-env -c conda-forge python=3.9 numpy scipy cython meson-python ninja
72
72
73
73
It is not always necessary but it is safer to open a new prompt before
74
74
activating the newly created conda environment.
@@ -87,17 +87,19 @@ feature, code or documentation improvement).
87
87
88
88
python3 -m venv sklearn-env
89
89
source sklearn-env/bin/activate
90
- pip install wheel numpy scipy cython
90
+ pip install wheel numpy scipy cython meson-python ninja
91
91
92
92
#. Install a compiler with OpenMP _ support for your platform. See instructions
93
93
for :ref: `compiler_windows `, :ref: `compiler_macos `, :ref: `compiler_linux `
94
94
and :ref: `compiler_freebsd `.
95
95
96
- #. Build the project with pip in :ref: ` editable_mode ` :
96
+ #. Build the project with pip:
97
97
98
98
.. prompt :: bash $
99
99
100
- pip install -v --no-use-pep517 --no-build-isolation -e .
100
+ pip install --editable . \
101
+ --verbose --no-build-isolation \
102
+ --config-settings editable-verbose=true
101
103
102
104
#. Check that the installed scikit-learn has a version number ending with
103
105
`.dev0 `:
@@ -111,14 +113,14 @@ feature, code or documentation improvement).
111
113
112
114
.. note ::
113
115
114
- You will have to run the `` pip install -v --no-use-pep517 --no-build-isolation -e . ``
115
- command every time the source code of a Cython file is updated
116
- (ending in ` .pyx ` or ` .pxd `). This can happen when you edit them or when you
117
- use certain git commands such as ` git pull `. Use the `` --no-build-isolation `` flag
118
- to avoid compiling the whole project each time, only the files you have
119
- modified. Include the `` --no-use-pep517 `` flag because the `` --no-build-isolation ``
120
- option might not work otherwise (this is due to a bug which will be fixed in the
121
- future) .
116
+ ` --config-settings editable-verbose=true ` is optional but recommended
117
+ to avoid surprises when you import ` sklearn `. ` meson-python ` implements
118
+ editable installs by rebuilding ` sklearn ` when executing ` import sklearn `.
119
+ With the recommended setting you will see a message when this happens,
120
+ rather than potentially waiting without feed-back and wondering
121
+ what is taking so long. Bonus: this means you only have to run the `pip
122
+ install ` command once, ` sklearn ` will automatically be rebuilt when
123
+ importing ` sklearn ` .
122
124
123
125
Dependencies
124
126
------------
@@ -182,100 +184,6 @@ If you want to build a stable version, you can ``git checkout <VERSION>``
182
184
to get the code for that particular version, or download an zip archive of
183
185
the version from github.
184
186
185
- .. _editable_mode :
186
-
187
- Editable mode
188
- -------------
189
-
190
- If you run the development version, it is cumbersome to reinstall the package
191
- each time you update the sources. Therefore it is recommended that you install
192
- in with the ``pip install -v --no-use-pep517 --no-build-isolation -e . `` command,
193
- which allows you to edit the code in-place. This builds the extension in place and
194
- creates a link to the development directory (see `the pip docs
195
- <https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs> `_).
196
-
197
- As the doc above explains, this is fundamentally similar to using the command
198
- ``python setup.py develop ``. (see `the setuptool docs
199
- <https://setuptools.pypa.io/en/latest/userguide/development_mode.html> `_).
200
- It is however preferred to use pip.
201
-
202
- On Unix-like systems, you can equivalently type ``make in `` from the top-level
203
- folder. Have a look at the ``Makefile `` for additional utilities.
204
-
205
- .. _building_with_meson :
206
-
207
- Building with Meson
208
- -------------------
209
-
210
- Support for Meson is experimental, in scikit-learn 1.5.0.dev0.
211
- `Open an issue <https://github.com/scikit-learn/scikit-learn/issues/new >`__ if
212
- you encounter any problems!
213
-
214
- Make sure you have `meson-python ` and `ninja ` installed, either with `conda `:
215
-
216
- .. code-block :: bash
217
-
218
- conda install -c conda-forge meson-python ninja -y
219
-
220
- or with pip:
221
-
222
- .. code-block :: bash
223
-
224
- pip install meson-python ninja
225
-
226
- Simplest way to build with Meson
227
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228
-
229
- To build scikit-learn, the simplest way is to run:
230
-
231
- .. code-block :: bash
232
-
233
- make dev-meson
234
-
235
- You need to do it once after this you can run your code that imports `sklearn `
236
- and it will recompile as needed.
237
-
238
- In case you want to go back to using setuptools:
239
-
240
- .. code-block :: bash
241
-
242
- make clean-meson
243
-
244
- More advanced way to build with Meson
245
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246
-
247
- If you can not use `make `, want to do it yourself or understand what goes in
248
- behind the scenes, you can build scikit-learn with the following `pip ` command:
249
-
250
- .. code-block :: bash
251
-
252
- pip install --editable . \
253
- --verbose --no-build-isolation \
254
- --config-settings editable-verbose=true
255
-
256
- If you want to go back to using `setuptools `:
257
-
258
- .. code-block :: bash
259
-
260
- pip uninstall -y scikit-learn
261
-
262
- Note `--config-settings editable-verbose=true ` is advised to avoid surprises.
263
- meson-python implements editable install by recompiling when doing `import
264
- sklearn `. Even changing python files involves copying files to the Meson build
265
- directory. You will see the meson output when that happens, rather than
266
- potentially waiting a while and wondering what is taking so long. Bonus: that
267
- means you only have to do the `pip install ` once, after that your code will
268
- recompile when doing `import sklearn `.
269
-
270
- Other places that may be worth looking at:
271
-
272
- - `pandas setup doc
273
- <https://pandas.pydata.org/docs/development/contributing_environment.html#step-3-build-and-install-pandas> `_:
274
- pandas has a similar setup as ours (no spin or dev.py)
275
- - `scipy Meson doc
276
- <https://scipy.github.io/devdocs/building/understanding_meson.html> `_ gives
277
- more background about how Meson works behind the scenes
278
-
279
187
.. _platform_specific_instructions :
280
188
281
189
Platform-specific instructions
@@ -324,11 +232,13 @@ Please be aware that the path above might be different from user to user. The
324
232
aim is to point to the "vcvarsall.bat" file that will set the necessary
325
233
environment variables in the current command prompt.
326
234
327
- Finally, build scikit-learn from this command prompt:
235
+ Finally, build scikit-learn with this command prompt:
328
236
329
237
.. prompt :: bash $
330
238
331
- pip install -v --no-use-pep517 --no-build-isolation -e .
239
+ pip install --editable . \
240
+ --verbose --no-build-isolation \
241
+ --config-settings editable-verbose=true
332
242
333
243
.. _compiler_macos :
334
244
@@ -367,7 +277,7 @@ scikit-learn from source:
367
277
.. prompt :: bash $
368
278
369
279
conda create -n sklearn-dev -c conda-forge python numpy scipy cython \
370
- joblib threadpoolctl pytest compilers llvm-openmp
280
+ joblib threadpoolctl pytest compilers llvm-openmp meson-python ninja
371
281
372
282
It is not always necessary but it is safer to open a new prompt before
373
283
activating the newly created conda environment.
@@ -376,7 +286,9 @@ activating the newly created conda environment.
376
286
377
287
conda activate sklearn-dev
378
288
make clean
379
- pip install -v --no-use-pep517 --no-build-isolation -e .
289
+ pip install --editable . \
290
+ --verbose --no-build-isolation \
291
+ --config-settings editable-verbose=true
380
292
381
293
.. note ::
382
294
@@ -450,7 +362,9 @@ Finally, build scikit-learn in verbose mode (to check for the presence of the
450
362
.. prompt :: bash $
451
363
452
364
make clean
453
- pip install -v --no-use-pep517 --no-build-isolation -e .
365
+ pip install --editable . \
366
+ --verbose --no-build-isolation \
367
+ --config-settings editable-verbose=true
454
368
455
369
.. _compiler_linux :
456
370
@@ -476,7 +390,9 @@ then proceed as usual:
476
390
.. prompt :: bash $
477
391
478
392
pip3 install cython
479
- pip3 install --verbose --editable .
393
+ pip3 install --editable . \
394
+ --verbose --no-build-isolation \
395
+ --config-settings editable-verbose=true
480
396
481
397
Cython and the pre-compiled wheels for the runtime dependencies (numpy, scipy
482
398
and joblib) should automatically be installed in
@@ -508,15 +424,17 @@ in the user folder using conda:
508
424
.. prompt :: bash $
509
425
510
426
conda create -n sklearn-dev -c conda-forge python numpy scipy cython \
511
- joblib threadpoolctl pytest compilers
427
+ joblib threadpoolctl pytest compilers meson-python ninja
512
428
513
429
It is not always necessary but it is safer to open a new prompt before
514
430
activating the newly created conda environment.
515
431
516
432
.. prompt :: bash $
517
433
518
434
conda activate sklearn-dev
519
- pip install -v --no-use-pep517 --no-build-isolation -e .
435
+ pip install --editable . \
436
+ --verbose --no-build-isolation \
437
+ --config-settings editable-verbose=true
520
438
521
439
.. _compiler_freebsd :
522
440
@@ -545,13 +463,17 @@ Finally, build the package using the standard command:
545
463
546
464
.. prompt :: bash $
547
465
548
- pip install -v --no-use-pep517 --no-build-isolation -e .
466
+ pip install --editable . \
467
+ --verbose --no-build-isolation \
468
+ --config-settings editable-verbose=true
549
469
550
470
For the upcoming FreeBSD 12.1 and 11.3 versions, OpenMP will be included in
551
471
the base system and these steps will not be necessary.
552
472
553
473
.. _OpenMP : https://en.wikipedia.org/wiki/OpenMP
554
474
.. _Cython : https://cython.org
475
+ .. _meson-python : https://mesonbuild.com/meson-python
476
+ .. _Ninja : https://ninja-build.org/
555
477
.. _NumPy : https://numpy.org
556
478
.. _SciPy : https://www.scipy.org
557
479
.. _Homebrew : https://brew.sh
@@ -566,7 +488,9 @@ The following command will build scikit-learn using your default C/C++ compiler.
566
488
567
489
.. prompt :: bash $
568
490
569
- pip install --verbose --editable .
491
+ pip install --editable . \
492
+ --verbose --no-build-isolation \
493
+ --config-settings editable-verbose=true
570
494
571
495
If you want to build scikit-learn with another compiler handled by ``setuptools ``,
572
496
use the following command:
@@ -597,17 +521,3 @@ When setting these environment variables, it is advised to first check their
597
521
598
522
In addition, since Scikit-learn uses OpenMP, you need to include the appropriate OpenMP
599
523
flag of your compiler into the ``CFLAGS `` and ``CPPFLAGS `` environment variables.
600
-
601
- Parallel builds
602
- ===============
603
-
604
- It is possible to build scikit-learn compiled extensions in parallel by setting
605
- and environment variable as follows before calling the ``pip install `` or
606
- ``python setup.py build_ext `` commands::
607
-
608
- export SKLEARN_BUILD_PARALLEL=3
609
- pip install -v --no-use-pep517 --no-build-isolation -e .
610
-
611
- On a machine with 2 CPU cores, it can be beneficial to use a parallelism level
612
- of 3 to overlap IO bound tasks (reading and writing files on disk) with CPU
613
- bound tasks (actually compiling).
0 commit comments