8000 BLD Migrate away from distutils and only use setuptools by thomasjpfan · Pull Request #24563 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

BLD Migrate away from distutils and only use setuptools #24563

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
771573e
BLD Migrate away from distutils and only use setuptools
thomasjpfan Oct 2, 2022
9ba6a47
CI [cd build]
thomasjpfan Oct 2, 2022
68f84a1
CLN Reduce diff
thomasjpfan Oct 2, 2022
c524327
CI [cd build]
thomasjpfan Oct 2, 2022
0c510bf
FIX Removes remaining setup.py file [cd build]
thomasjpfan Oct 5, 2022
739c11a
Merge remote-tracking branch 'upstream/main' into wheels/remove_numpy…
thomasjpfan Oct 12, 2022
d0f4a7a
CI [cd build gh]
thomasjpfan Oct 12, 2022
ba8a018
Merge remote-tracking branch 'upstream/main' into wheels/remove_numpy…
thomasjpfan Oct 14, 2022
979d764
CI [cd build gh]
thomasjpfan Oct 14, 2022
7baf7d0
CI Remove BUILD_WITH_ICC everywhere [cd build gh]
thomasjpfan Oct 14, 2022
0efa8b1
Merge branch 'main' into wheels/remove_numpy_distutils_pr
glemaitre Oct 26, 2022
5dda5d4
CLN Remove more distutil references [cd build gh]
thomasjpfan Oct 26, 2022
429eed6
FIX Fixes build_utils [cd build gh]
thomasjpfan Oct 26, 2022
2f547bc
FIX Remove disutils.version [cd build gh]
thomasjpfan Oct 26, 2022
bd22900
CI Set minimum setuptools [cd build gh]
thomasjpfan Oct 26, 2022
af0b25c
CI Allow for lower versions of setuptools [cd build gh]
thomasjpfan Oct 26, 2022
bc55cd7
DOC Better formatting [cd buil 8000 d gh]
thomasjpfan Oct 26, 2022
aebf345
Update comment for builtins.__SKLEARN_SETUP__
ogrisel Nov 3, 2022
2d162e8
Apply suggestions from code review
thomasjpfan Nov 3, 2022
a4db54e
Do not use distutils for BLAS/LAPACK inspection
ogrisel Nov 3, 2022
8a12d9b
Merge branch 'main' into wheels/remove_numpy_distutils_pr
ogrisel Nov 3, 2022
38b61b5
Apply suggestions from code review
thomasjpfan Nov 3, 2022
dd60027
CLN Remove remaining references to intel compilers
thomasjpfan Nov 3, 2022
4c18f92
CLN Remove remaining references to intel compilers [cd build gh]
thomasjpfan Nov 3, 2022
24ac0fb
CLN Remove c++ distutil entry in partition_nodes
thomasjpfan Nov 3, 2022
a9feb59
CLN Improve grammar
thomasjpfan Nov 3, 2022
8661809
TST Remove ignore warning in testing [cd build gh]
thomasjpfan Nov 3, 2022
aad2bff
CLN Fixes warnings in openmp_helpers
thomasjpfan Nov 3, 2022
ee3c884
CI [cd build gh]
thomasjpfan Nov 3, 2022
98fe1e2
CI [cd build gh]
thomasjpfan Nov 3, 2022
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
2 changes: 1 addition & 1 deletion MANIFEST.in
8000
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include *.rst
recursive-include doc *
recursive-include examples *
recursive-include sklearn *.c *.h *.pyx *.pxd *.pxi *.tp
recursive-include sklearn *.c *.cpp *.h *.pyx *.pxd *.pxi *.tp
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required for the sdist to contain *.cpp files that is not a source file. Specifically, svm/src/libsvm/svm.cpp.

recursive-include sklearn/datasets *.csv *.csv.gz *.rst *.jpg *.txt *.arff.gz *.json.gz
include COPYING
include README.rst
Expand Down
22 changes: 0 additions & 22 deletions azure-pipelines.yml
F438
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,6 @@ jobs:
LOCK_FILE: './build_tools/azure/python_nogil_lock.txt'
COVERAGE: 'false'

# Check compilation with intel C++ compiler (ICC)
- template: build_tools/azure/posix.yml
parameters:
name: Linux_Nightly_ICC
vmImage: ubuntu-20.04
dependsOn: [git_commit, linting]
condition: |
and(
succeeded(),
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]')),
or(eq(variables['Build.Reason'], 'Schedule'),
contains(dependencies['git_commit']['outputs']['commit.message'], '[icc-build]')
)
)
matrix:
pylatest_conda_forge_mkl:
DISTRIB: 'conda'
LOCK_FILE: 'build_tools/azure/pylatest_conda_forge_mkl_no_coverage_linux-64_conda.lock'
COVERAGE: 'false'
BUILD_WITH_ICC: 'true'

Comment on lines -109 to -129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few occurrences of ICC in the code-base, namely:

[icc-build] Build & test with the Intel C compiler (ICC)

if sys.platform == "win32" and ("icc" in compiler or "icl" in compiler):
return ["/Qopenmp"]
elif sys.platform == "win32":
return ["/openmp"]
elif sys.platform in ("darwin", "linux") and "icc" in compiler:

Should we let users be able to use icc? or should we remove those if we do not test the support of this compiler on the CI?

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 we should keep this, assuming setting the CC env variable works for setuptools. But it's true it would be better to test it at some point. But I would not make this a blocker for this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not get the Intel compilers to work by setting the CC environment variable (and friends). From memory, I got Intel to compile by setting environment variables, but there was an issue when running pytest.

(The Azure logs does not exist anymore because it has been too long)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's keep that in mind for a follow-up PR.

- template: build_tools/azure/posix-docker.yml
parameters:
name: Linux_Nightly_PyPy
Expand Down Expand Up @@ -182,7 +161,6 @@ jobs:
DISTRIB: 'conda'
LOCK_FILE: './build_tools/azure/py38_conda_forge_openblas_ubuntu_2204_linux-64_conda.lock'
COVERAGE: 'false'
BUILD_WITH_ICC: 'false'
SKLEARN_TESTS_GLOBAL_RANDOM_SEED: '0' # non-default seed

- template: build_tools/azure/posix.yml
Expand Down
16 changes: 0 additions & 16 deletions build_tools/azure/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ pre_python_environment_install() {
export PYTHON_NOGIL_PATH="${PYTHON_NOGIL_CLONE_PATH}/python"
cd $OLDPWD

elif [[ "$BUILD_WITH_ICC" == "true" ]]; then
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
source /opt/intel/oneapi/setvars.sh

fi
}

Expand Down Expand Up @@ -122,13 +113,6 @@ scikit_learn_install() {
export LDFLAGS="$LDFLAGS -Wl,--sysroot=/"
fi

if [[ "$BUILD_WITH_ICC" == "true" ]]; then
# The "build_clib" command is implicitly used to build "libsvm-skl".
# To compile with a different compiler, we also need to specify the
# compiler for this command
python setup.py build_ext --compiler=intelem -i build_clib --compiler=intelem
fi

# TODO use a specific variable for this rather than using a particular build ...
if [[ "$DISTRIB" == "conda-pip-latest" ]]; then
# Check that pip can automatically build scikit-learn with the build
Expand Down
4 changes: 0 additions & 4 deletions build_tools/azure/test_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ elif [[ "$DISTRIB" == "ubuntu" || "$DISTRIB" == "pip-nogil" ]]; then
source $VIRTUALENV/bin/activate
fi

if [[ "$BUILD_WITH_ICC" == "true" ]]; then
source /opt/intel/oneapi/setvars.sh
fi

make test-doc
7 changes: 0 additions & 7 deletions build_tools/azure/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ elif [[ "$DISTRIB" == "ubuntu" || "$DISTRIB" == "debian-32" || "$DISTRIB" == "pi
source $VIRTUALENV/bin/activate
fi

if [[ "$BUILD_WITH_ICC" == "true" ]]; then
source /opt/intel/oneapi/setvars.sh
fi

if [[ "$BUILD_REASON" == "Schedule" ]]; then
# Enable global random seed randomization to discover seed-sensitive tests
# only on nightly builds.
Expand Down Expand Up @@ -62,9 +58,6 @@ if [[ -n "$CHECK_WARNINGS" ]]; then
# removes its usage
TEST_CMD="$TEST_CMD -Wignore:tostring:DeprecationWarning"

# Python 3.10 deprecates distutils, which is imported by numpy internally
TEST_CMD="$TEST_CMD -Wignore:The\ distutils:DeprecationWarning"

# Ignore distutils deprecation warning, used by joblib internally
TEST_CMD="$TEST_CMD -Wignore:distutils\ Version\ classes\ are\ deprecated:DeprecationWarning"

Expand Down
8 changes: 4 additions & 4 deletions build_tools/circle/list_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import sys

from distutils.version import LooseVersion
from sklearn.utils.fixes import parse_version
from urllib.request import urlopen


Expand Down Expand Up @@ -37,8 +37,8 @@ def get_file_extension(version):
# The 'dev' branch should be explicitly handled
return "zip"

current_version = LooseVersion(version)
min_zip_version = LooseVersion("0.24")
current_version = parse_version(version)
min_zip_version = parse_version("0.24")

return "zip" if current_version >= min_zip_version else "pdf"

Expand Down Expand Up @@ -94,7 +94,7 @@ def get_file_size(version):
# Output in order: dev, stable, decreasing other version
seen = set()
for name in NAMED_DIRS + sorted(
(k for k in dirs if k[:1].isdigit()), key=LooseVersion, reverse=True
(k for k in dirs if k[:1].isdigit()), key=parse_version, reverse=True
):
version_num, file_size = dirs[name]
if version_num in seen:
Expand Down
5 changes: 0 additions & 5 deletions build_tools/github/build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ if [[ "$RUNNER_OS" == "macOS" ]]; then
export CFLAGS="$CFLAGS -I$PREFIX/include"
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"
export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"
# Disable the use of setuptools's vendored copy distutils when invoking setuptools
# See: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html
# TODO: remove the definition of this environment variable when no
# reference to distutils exist in the code-base for building scikit-learn.
export SETUPTOOLS_USE_DISTUTILS=stdlib
fi

# The version of the built dependencies are specified
Expand Down
5 changes: 2 additions & 3 deletions doc/computing/computational_performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,9 @@ BLAS implementation and lead to orders of magnitude speedup over a
non-optimized BLAS.

You can display the BLAS / LAPACK implementation used by your NumPy / SciPy /
scikit-learn install with the following commands::
scikit-learn install with the following command::

from numpy import show_config
show_config()
python -c "import sklearn; sklearn.show_versions()"

Optimized BLAS / LAPACK implementations include:
- Atlas (need hardware specific tuning by rebuilding on the target machine)
Expand Down
69 changes: 0 additions & 69 deletions doc/developers/advanced_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -461,75 +461,6 @@ the base system and these steps will not be necessary.
.. _conda environment: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
.. _Miniforge3: https://github.com/conda-forge/miniforge#miniforge3

Alternative compilers
=====================

The command:

.. prompt:: bash $

pip install --verbose --editable .

will build scikit-learn using your default C/C++ compiler. If you want to build
scikit-learn with another compiler handled by ``distutils`` or by
``numpy.distutils``, use the following command:

.. prompt:: bash $

python setup.py build_ext --compiler=<compiler> -i build_clib --compiler=<compiler>

To see the list of available compilers run:

.. prompt:: bash $

python setup.py build_ext --help-compiler

If your compiler is not listed here, you can specify it via the ``CC`` and
``LDSHARED`` environment variables (does not work on windows):

.. prompt:: bash $

CC=<compiler> LDSHARED="<compiler> -shared" python setup.py build_ext -i

Building with Intel C Compiler (ICC) using oneAPI on Linux
----------------------------------------------------------

Intel provides access to all of its oneAPI toolkits and packages through a
public APT repository. First you need to get and install the public key of this
repository:

.. prompt:: bash $

wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB

Then, add the oneAPI repository to your APT repositories:

.. prompt:: bash $

sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update

Install ICC, packaged under the name
``intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic``:

.. prompt:: bash $

sudo apt-get install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic

Before using ICC, you need to set up environment variables:

.. prompt:: bash $

source /opt/intel/oneapi/setvars.sh

Finally, you can build scikit-learn. For example on Linux x86_64:

.. prompt:: bash $

python setup.py build_ext --compiler=intelem -i build_clib --compiler=intelem

Parallel builds
===============

Expand Down
1 change: 0 additions & 1 deletion doc/developers/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ message, the following actions are taken.
[lint skip] Azure pipeline skips linting
[scipy-dev] Build & test with our dependencies (numpy, scipy, etc ...) development builds
[nogil] Build & test with the nogil experimental branches of CPython, Cython, NumPy, SciPy...
[icc-build] Build & test with the Intel C compiler (ICC)
[pypy] Build & test with PyPy
[float32] Run float32 tests by setting `SKLEARN_RUN_FLOAT32_TESTS=1`. See :ref:`environment_variable` for more details
[doc skip] Docs are not built
Expand Down
3 changes: 1 addition & 2 deletions maint_tools/check_pxd_in_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
f.write(
textwrap.dedent(
"""
from distutils.core import setup
from distutils.extension import Extension
from setuptools import setup, Extension
from Cython.Build import cythonize
import numpy

Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[options]
packages = find_namespace:

[options.packages.find]
include = sklearn*

[aliases]
test = pytest

Expand Down
Loading
0