Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BLD Remove support for setuptools build #29400

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 21 commits into from
Jul 11, 2024

Conversation

lesteve
Copy link
Member

@lesteve lesteve commented Jul 3, 2024

Close #29346

Fix #29302

Comments:

  • tolerance was slightly increased in debian 32 CI build, not really clear why this is needed, maybe going from setuptools build to Meson build has different compiler tool flags 🤷
  • I used a more recent Debian for Debian 32 bit Docker image, otherwise you get an error that the pip does not know how to deal with a pyproject.toml without a setup.py (ah the good old days 🙃)

@lesteve lesteve changed the title Remove setup py BLD Remove support for setuptools build Jul 3, 2024
Copy link

github-actions bot commented Jul 3, 2024

✔️ Linting Passed

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

Generated for commit: c147b33. Link to the linter CI: here

Comment on lines -90 to -116
def gen_from_templates(templates):
"""Generate cython files from a list of templates"""
# Lazy import because cython is not a runtime dependency.
from Cython import Tempita

for template in templates:
outfile = template.replace(".tp", "")

# if the template is not updated, no need to output the cython file
if not (
os.path.exists(outfile)
and os.stat(template).st_mtime < os.stat(outfile).st_mtime
):
with open(template, "r") as f:
tmpl = f.read()

tmpl_ = Tempita.sub(tmpl)

warn_msg = (
"# WARNING: Do not edit this file directly.\n"
f"# It is automatically generated from {template!r}.\n"
"# Changes must be made there.\n\n"
)

with open(outfile, "w") as f:
f.write(warn_msg)
f.write(tmpl_)
Copy link
Member

Choose a reason for hiding this comment

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

meson generates the cython files from tempita templates automatically ?
Is there a way to have this warning in the generated files with meson ?

Copy link
Member Author

Choose a reason for hiding this comment

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

we have a script that has similar logic and is used in meson.build files https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/_build_utils/tempita.py. It was strongly inspired from Numpy and Scipy.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could have the warning if we really insist but the .c files are out of tree (build/<something> by default) in general they are in some deeply nested subfolder so I would argue it is a lot less tempting to modify them compared to the in-tree situation before?

Copy link
Member

Choose a reason for hiding this comment

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

but the .c files are out of tree

I was more worried about the .pxd and .pyx generated files, but the fact that it's out of tree should prevent any direct edit of these files. So the current situation is fine to me

Comment on lines 1 to 3
"""
Utilities useful during the build.
"""
Copy link
Member

Choose a reason for hiding this comment

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

I guess you can just remove the full _build_utils folder at once since there's nothing left besides this docstring

Copy link
Member

Choose a reason for hiding this comment

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

never mind there are other files...

Copy link
Member Author

@lesteve lesteve Jul 3, 2024

Choose a reason for hiding this comment

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

I removed the docstring but there are stuff that are used e.g. https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/_build_utils/tempita.py https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/_build_utils/version.py. To be honest not sure why they are under sklearn since it feels like maybe they don't have to be? I mirrored Numpy and Scipy here.

Edit: maybe there is a use case when installing from sdist, not sure ...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah you can ignore this comment, I thought you were removing all files and content from this folder, but realized afterward that there are other files left.

Copy link
Member

Choose a reason for hiding this comment

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

Edit: maybe there is a use case when installing from sdist, not sure ...

Not actionable for this PR: I can not think of a good reason for having them under sklearn. _build_utils can be in the sdist at the root level.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep I kind of agree ...

@lesteve
Copy link
Member Author

lesteve commented Jul 3, 2024

The wheels succeeded in 25743a5 see build log.

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 once the lock files have been regenerated after a merge with main.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
# TODO temporary hack while waiting for version checks inside meson.build
# if [[ "$DISTRIB" == "ubuntu" || "$DISTRIB" == "debian-32" ]]; then
# ADDITIONAL_PIP_OPTIONS="$ADDITIONAL_PIP_OPTIONS --check-build-dependencies"
# fi
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the TODO comment: it's a temporary hack but actually it's commented out. Do you mean that we we would like to pass --check-build-dependencies but it's not possible because of a limitation of meson.build?

Copy link
Member Author

@lesteve lesteve Jul 9, 2024

Choose a reason for hiding this comment

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

Good point I forgot this, let me fix this.

Basically what happens following the Debian 32 bit Docker image update:

  • pip is recent enough to have --check-build-dependencies
  • system numpy is too old (1.24) to satisfy the pyproject.toml build dependencies (numpy>=1.25) so using pip install --check-build-dependencies will result in an error

Previously (before the Debian 32 bit Docker image update), pip was too old to have --check-build-dependencies flag ...

The temporary hack was to never add --check-build-dependencies as it will be removed in #28721 anyway. I can do a bit less hacky I think.

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 ended up removing this since there is no need to use --check-build-dependencies in the CI. This was mostly intended to have user friendly error when your build dependencies are not recent enough but it has limitation and #28721 will remove --check-build-dependencies everywhere soonish.

lesteve and others added 4 commits July 9, 2024 17:20
dotting the i's and crossing the t's

Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
@lesteve lesteve force-pushed the remove-setup-py branch from 8e3c0f3 to 7275616 Compare July 9, 2024 15:32
build_tools/azure/install.sh Show resolved Hide resolved
Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

LGTM

@lesteve
Copy link
Member Author

lesteve commented Jul 11, 2024

Merging my own PR with 3 approvals. Bye bye setuptools!

@lesteve lesteve merged commit 7eb7eff into scikit-learn:main Jul 11, 2024
46 checks passed
@lesteve lesteve deleted the remove-setup-py branch July 11, 2024 06:34
glemaitre added a commit to glemaitre/scikit-learn that referenced this pull request Sep 9, 2024
glemaitre added a commit that referenced this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC Remove setuptools-based build in scikit-learn 1.6 Remove uneeded SKLEARN_BUILD_PARALLEL environment variable
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.