-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MNT Support and test Python 3.9 #18761
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 Support and test Python 3.9 #18761
Conversation
6dc223a
to
5449fd5
Compare
build_tools/azure/install.sh
Outdated
# NOTE(honles): scikit-image does not include pyproject.toml in its | ||
# current release and these are what it needs to build. | ||
# This can be removed when | ||
# https://github.com/scikit-image/scikit-image/pull/5016 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That MR has been merged: scikit-image/scikit-image#5016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it has not been released yet. I will create a separate PR which can be merged after that is released to pypi/conda.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also trying to get Python 3.9 wheels built too, so hopefully that will all come together in the next release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not build scikit-image from source for now. Maybe we can only install scikit-image for the builds that are for Python PYTHON_VERSION < "3.9"
for now instead.
It's an optional dependency of scikit-learn, so it should still work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So would you prefer I change this to: python -m pip install --only-binary :all: sckit-image || true
? So it only installs binary packages and only if they exists? I'd have to see if anything else has to be altered, but I'd prefer not to add config that has to be updated manually and just install it automatically if it can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ogrisel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR but we need to pin the version of numpy in the build dependency:
build_tools/azure/install.sh
Outdated
# NOTE(honles): scikit-image does not include pyproject.toml in its | ||
# current release and these are what it needs to build. | ||
# This can be removed when | ||
# https://github.com/scikit-image/scikit-image/pull/5016 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not build scikit-image from source for now. Maybe we can only install scikit-image for the builds that are for Python PYTHON_VERSION < "3.9"
for now instead.
It's an optional dependency of scikit-learn, so it should still work.
pyproject.toml
Outdated
"numpy==1.16.5; python_version=='3.7'", | ||
"numpy==1.17.3; python_version=='3.8'", | ||
# do not pin numpy on future versions of python to avoid incompatible numpy and python versions | ||
"numpy; python_version>='3.9'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to pin the oldest version of numpy that supports python_version == '3.9' because it will define the ABI compatibility expectations for the scikit-learn wheel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow this comment. This is the same as scipy, and I figured that would be acceptable. I'm not sure if you can explain your thinking a little more.
I can change it to 1.19.3 if needed, since that is the first version that has released wheels for Python 3.9. I just figured it might cut down on the maintenance burden and I assumed that was why scipy set that as their default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the version of numpy pyproject.toml to build the wheels in a github actions workflow. scikit-learn has Cython extension that need numpy at build time and the generated wheel need to be built with the oldest supported version of numpy to make sure that our build do not depend on recently changes of the numpy ABI.
For instance the future scikit-learn 0.24 wheel for python 3.8 needs to be build with numpy 1.17.3 to make sure that users who have such old versions of numpy can install a binary package of scikit-learn that is binary compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wheel building workflow is here:
https://github.com/scikit-learn/scikit-learn/blob/master/.github/workflows/wheels.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @terencehonles,
Thank you for your PR!
I have a few of requested changes:
- I think that we may update the Python version used in
circleci
:
grep -rnw ".circleci" -e "python"
.circleci/config.yml:6: - image: circleci/python:3.7.3-stretch
.circleci/config.yml:47: - image: circleci/python:3.7.3-stretch
.circleci/config.yml:93: - image: circleci/python:3.6
.circleci/config.yml:122: - image: circleci/python:3.6
- If we decide to update the
NumPy
version for Python 3.6 to1.16.5
, we should update theNUMPY_MIN_VERSION
global variable in thesklearn/_min_dependencies.py
file.
@@ -11,7 +11,7 @@ jobs: | |||
- uses: actions/checkout@v2 | |||
- uses: actions/setup-python@v2 | |||
with: | |||
python-version: '3.8' | |||
python-version: '3.9' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, Python 3.9 is used in GitHub Actions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting I remove this? I believe it might make sense to keep this explicit since this is a C extension that may need to be pinned to a different version than what is the default. If you'd like me to remove it I can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us keep then.
@@ -15,7 +15,7 @@ jobs: | |||
steps: | |||
- task: UsePythonVersion@0 | |||
inputs: | |||
versionSpec: '3.8' | |||
versionSpec: '3.9' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the same applies for Azure Pipelines
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here, though I believe Azure Pipelines may not have switched the default (I know this was discussed earlier on). I also remember coming across microsoft/azure-pipelines-tasks#13708 but it looks like there has been no response there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, same here.
build_tools/azure/install.sh
Outdated
# NOTE(honles): scikit-image does not include pyproject.toml in its | ||
# current release and these are what it needs to build. | ||
# This can be removed when | ||
# https://github.com/scikit-image/scikit-image/pull/5016 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ogrisel.
35e7cde
to
0afb549
Compare
I'm not sure if we can update |
Yes Python is considered a dependency of scikit-learn as numpy, scipy, etc. So the min_dependency build of circle CI should use the oldest supported version of Python which is Python 3.6 at the moment. |
If scipy pins to an older version of numpy for Python 3.9, we can do so, but we need to wait for this Python 3.9 wheel for numpy to be uploaded to that version on PyPI, otherwise we won't be able to build our own wheels. |
@terencehonles To keep this PR focused and merge it quickly to prepare the scikit-learn 0.24 release, could you please revert the changes made on the circle ci configuration? They are not required to support and test Python 3.9. We can always bump up the python versions used in circle ci in another PR but this requires more in dept testing and now is not the time to risk making the doc building infrastructure unstable ;) Same for PyPy which is hard to test at the moment because of #18624. |
@terencehonles Do you mind updating the |
0afb549
to
249ebc3
Compare
@ogrisel I'm aware of that, I mean that they don't constrain future releases to the min version needed to build. It's not really important to discuss since it seems like there are more specific requirements for this package.
@ogrisel this PR really isn't that big and now two of you are asking for conflicting things. I changed it because @alfaro96 asked, but also because the change does need to be tested. The CI changes are not failing so I'm not sure what's your reason to not make the change now.
@alfaro96 done, I added some comments to explain when the constraints can be removed as Python versions are expired. |
The full doc build is very expensive and not triggered by your PR. The PyPy build is only triggered by a scheduled task it does not run on PRs. See: https://scikit-learn.org/dev/developers/contributing.html#continuous-integration-ci |
The following were used as references when updating pyproject.toml: - scipy/scipy#12940 - scikit-image/scikit-image#4920 - scikit-image/scikit-image#4920 (comment)
249ebc3
to
eafd63a
Compare
It really looks like that only applies to pypy which I had thought I hadn't included, but it looks like I had left it in. Since I was going to be pushing I reverted any changes to Circle CI at your request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I just pushed a commit to check that the new pyproject.toml does not break the wheel builder workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @terencehonles for your PR.
I would like to know if it would be possible to use oldest-supported-numpy
to simplify the pyproject.toml
file.
@@ -11,7 +11,7 @@ jobs: | |||
- uses: actions/checkout@v2 | |||
- uses: actions/setup-python@v2 | |||
with: | |||
python-version: '3.8' | |||
python-version: '3.9' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us keep then.
@@ -15,7 +15,7 @@ jobs: | |||
steps: | |||
- task: UsePythonVersion@0 | |||
inputs: | |||
versionSpec: '3.8' | |||
versionSpec: '3.9' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, same here.
|
||
# PyPy needs numpy >= 1.14.0 | ||
# platform_python_implementation!='CPython' not needed >= Python 3.7 which is numpy 1.14.5 | ||
"numpy==1.13.3; python_version=='3.6' and platform_machine!='aarch64' and platform_system!='AIX' and platform_python_implementation=='CPython'", | ||
"numpy==1.14.0; python_version=='3.6' and platform_machine!='aarch64' and platform_system!='AIX' and platform_python_implementation!='CPython'", | ||
|
||
# AIX needs numpy >= 1.16.0 | ||
# platform_system!='AIX' not needed >= Python 3.8 which is numpy 1.17.3 | ||
"numpy==1.16.0; python_version=='3.6' and platform_machine!='aarch64' and platform_system=='AIX'", | ||
"numpy==1.16.0; python_version=='3.7' and platform_machine!='aarch64' and platform_system=='AIX'", | ||
|
||
# ARM needs numpy >= 1.19.0 | ||
# platform_machine!='aarch64' not needed >= Python 3.9 which is numpy 1.19.3 | ||
"numpy==1.19.0; python_version=='3.6' and platform_machine=='aarch64'", | ||
"numpy==1.19.0; python_version=='3.7' and platform_machine=='aarch64'", | ||
"numpy==1.19.0; python_version=='3.8' and platform_machine=='aarch64'", | ||
|
||
# default numpy requirements | ||
"numpy==1.14.5; python_version=='3.7' and platform_machine!='aarch64' and platform_system!='AIX'", | ||
"numpy==1.17.3; python_version=='3.8' and platform_machine!='aarch64'", | ||
"numpy==1.19.3; python_version=='3.9'", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using oldest-supported-numpy
?
It would simplify the pyproject.toml
file quite a lot.
WDYT @thomasjpfan and @ogrisel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a pretty interesting idea to me, but we'd need to upstream all the changes that were made here (existing pypy constraints and added ARM constraints)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us accept this solution and keep us track of oldest-supported-numpy
to see if we could use it in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oldest-supported-numpy (implicitly by numpy developers) is not necessarily the same as oldest-supported-numpy by scikit-learn developers.
I think we are rather conservative, so the two might match, but we would have to discuss that with a dedicated issue.
Let's not block this PR further but feel free to open an issue on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know where the pypy version constraints come from? Looking at PyPI I can see the ARM wheels so I can create a PR for that, but I don't know if I should upstream the PyPy requirement of 1.14.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #11010 (comment). We had 7 failures with numpy==1.13.3
and none with numpy==1.14.0
for PyPy
.
I do not think that we could upstream such dependencies since as @ogrisel pointed out: "oldest-supported-numpy
is not necessarily the same as oldest-supported-numpy
by scikit-learn
developers."
Sorry for the noise!
Co-authored-by: Juan Carlos Alfaro Jiménez <JuanCarlos.Alfaro@uclm.es>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
||
# PyPy needs numpy >= 1.14.0 | ||
# platform_python_implementation!='CPython' not needed >= Python 3.7 which is numpy 1.14.5 | ||
"numpy==1.13.3; python_version=='3.6' and platform_machine!='aarch64' and platform_system!='AIX' and platform_python_implementation=='CPython'", | ||
"numpy==1.14.0; python_version=='3.6' and platform_machine!='aarch64' and platform_system!='AIX' and platform_python_implementation!='CPython'", | ||
|
||
# AIX needs numpy >= 1.16.0 | ||
# platform_system!='AIX' not needed >= Python 3.8 which is numpy 1.17.3 | ||
"numpy==1.16.0; python_version=='3.6' and platform_machine!='aarch64' and platform_system=='AIX'", | ||
"numpy==1.16.0; python_version=='3.7' and platform_machine!='aarch64' and platform_system=='AIX'", | ||
|
||
# ARM needs numpy >= 1.19.0 | ||
# platform_machine!='aarch64' not needed >= Python 3.9 which is numpy 1.19.3 | ||
"numpy==1.19.0; python_version=='3.6' and platform_machine=='aarch64'", | ||
"numpy==1.19.0; python_version=='3.7' and platform_machine=='aarch64'", | ||
"numpy==1.19.0; python_version=='3.8' and platform_machine=='aarch64'", | ||
|
||
# default numpy requirements | ||
"numpy==1.14.5; python_version=='3.7' and platform_machine!='aarch64' and platform_system!='AIX'", | ||
"numpy==1.17.3; python_version=='3.8' and platform_machine!='aarch64'", | ||
"numpy==1.19.3; python_version=='3.9'", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us accept this solution and keep us track of oldest-supported-numpy
to see if we could use it in the future.
Co-authored-by: Juan Carlos Alfaro Jiménez <JuanCarlos.Alfaro@uclm.es>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and pretty small at this point.
I've opened a PR to upstream the aarch constraints scipy/oldest-supported-numpy#13, but if the PyPy change doesn't get upstreamed you can probably use the |
Thanks all! |
What does this implement/fix? Explain your changes.
Updates Python 3.8 to Python 3.9 in latest tests, and updates trove classifiers to mention Python 3.9 support. I'm not sure what else is needed to build the Python 3.9 wheels since I didn't see anything obvious in this repo that should be changed.