Skip to content
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

MNT Remove setuptools dependency in our test suite #27355

Merged

Conversation

lesteve
Copy link
Member

@lesteve lesteve commented Sep 13, 2023

This was noticed when working on Python 3.12 wheels in #27027. In Python 3.12 setuptools is not a core dependency venv (see this).

As noted in #27027 (comment), our test suite should not depend on setuptools.

This PR:

  • remove test_tabs which is not useful since we are using black
  • avoids importing sklearn._build_utils.pre_build_helpers (which is the only module depending on setuptools) to check its __all__ in test_import_all_consistency`

@lesteve lesteve added Quick Review For PRs that are quick to review No Changelog Needed labels Sep 13, 2023
@github-actions
Copy link

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 2f05e9c. Link to the linter CI: here

@@ -217,6 +217,9 @@ def test_import_all_consistency():
for modname in submods + ["sklearn"]:
if ".tests." in modname:
continue
# Avoid test suite depending on setuptools
Copy link
Member

Choose a reason for hiding this comment

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

Does the act of using pkgutil.pkgutil.walk_packages to go through every submodule which includes _build_utils end up importing setuptools anyways?

XREF: #26992

Copy link
Member Author

@lesteve lesteve Sep 14, 2023

Choose a reason for hiding this comment

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

My understanding is that it will indeed try to import all the submodules (and hence try to import setuptools), but that ImportError is going to be ignored. By default (onerror=None), only ImportError is ignored. When specifying onerror, any kind of Exception is ignored:
https://github.com/python/cpython/blob/1f885df2a580360c5de69cc41191f3c6bfaaeb35/Lib/pkgutil.py#L76-L86

In other words, there is no hard dependency on setuptools by using pkgutil.walk_packages but this may still have side-effects as in #26992 if setuptools can be imported.

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM, thanks very much @lesteve.

@adrinjalali adrinjalali merged commit b8e9d38 into scikit-learn:main Sep 15, 2023
30 of 32 checks passed
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Sep 18, 2023
@lesteve lesteve deleted the remove-tests-setuptools-dependency branch September 19, 2023 13:01
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Changelog Needed Quick Review For PRs that are quick to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants