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

Add support for Python 3.12 #315

Merged
merged 18 commits into from
Jun 18, 2024
Merged

Add support for Python 3.12 #315

merged 18 commits into from
Jun 18, 2024

Conversation

dhermes
Copy link
Owner

@dhermes dhermes commented Oct 18, 2023

Also remove support for Python 3.9

@dhermes
Copy link
Owner Author

dhermes commented Oct 30, 2023

Likely relevant here: https://gregoryszorc.com/blog/2023/10/30/my-user-experience-porting-off-setup.py/

(Having issues with sys.path in setup.py; it differs from within nox and outside of nox)

It seems like pip install --no-build-isolation . is the trick here. (Though I think we should start listing numpy as a build dependency.)

@epicwhale
Copy link

Any luck with supporting python 3.12?

@pd-nisse
Copy link

pd-nisse commented Jun 11, 2024

@dhermes We would be very interested to get Python 3.12 support for bezier. It currently blocks our internal library's upgrade to 3.12. It would be great if we could continue using bezier, because we enjoy it.

I install locally with both Python 3.11 and 3.12, and compared unit test results. Both failed with the same few errors in test_triangle_triangle.py which at least doesn't hint at Python 3.12 being (more) incompatible than 3.11.

image

@dhermes
Copy link
Owner Author

dhermes commented Jun 11, 2024

@pd-nisse I have been quite busy recently but expect to have some free time soon to get this resolved. Thanks for the ping!

Luckily #315 (comment) seems to unlock the headscratching issue here.

As for failing functional tests, there may be accuracy issues (e.g. tests may need more wiggle room) for newer versions of NumPy. (A lot of code is dependent on the underlying C/C++/Fortran code AS WELL AS the compiler AS WELL AS the flags used to create redistributable binary wheels.) I'll be sure to look into it when I get this PR working!

@pd-nisse
Copy link

pd-nisse commented Jun 11, 2024

@dhermes thanks for the news and great update!
Why do you plan to remove 3.9 support at the same time? Looking at EOL schedule it's not until Nov 2025.
https://devguide.python.org/versions/

[edit:] I just realize we can just pin the dependency to an older version for python 3.9 so we should be good.

import os
import pathlib
import re
import subprocess

import setuptools._distutils.ccompiler
Copy link
Owner Author

Choose a reason for hiding this comment

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

Relying on setuptools._distutils isn't my favorite, but figuring out the "right way" to do this isn't worth the time right now (and I don't have the time for it unfortunately).

@@ -1,5 +1,6 @@
# NumPy is required for building `bezier` from source.
numpy >= 2.0.0
setuptools >= 70.0.0
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is for doctest and may be able to be done more close to doctests in noxfile.py

@@ -0,0 +1,3 @@
[build-system]
requires = ["numpy>=1.25.2", "setuptools>=70.0.0", "wheel>=0.43.0"]
Copy link
Owner Author

Choose a reason for hiding this comment

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

@dhermes
Copy link
Owner Author

dhermes commented Jun 18, 2024

Why do you plan to remove 3.9 support at the same time? Looking at EOL schedule it's not until Nov 2025. https://devguide.python.org/versions/

@pd-nisse My policy has been to support the 3 most recent Python versions. I unfortunately don't have much free time for maintaining this these days. (Separate but relevant, the Python packaging story around binary packages has had a lot of churn the last few years so things can be hard to keep up with.)

I'm happy to consider adding back 3.9 support if I hear enough requests from users, but

  • 3.10 (a replacement for 3.9) was released almost 3 full years ago
  • Ubuntu / Debian default Python 3 was 3.10 as of 22.04 (last LTS) and is 3.12 in 24.04 (current LTS); 3.8 was 20.04 LTS

For related policies, see SPEC 0 — Minimum Supported Dependencies:

Support for Python versions be dropped 3 years after their initial release.

See Status of Python versions doc for release dates:

  • 3.9 First release: 2020-10-05
  • 3.10 First release: 2021-10-04

@dhermes dhermes merged commit 684b0f2 into main Jun 18, 2024
11 checks passed
@dhermes dhermes deleted the dhermes/python-3.12 branch June 18, 2024 21:31
@dhermes
Copy link
Owner Author

dhermes commented Jun 18, 2024

I install locally with both Python 3.11 and 3.12, and compared unit test results. Both failed with the same few errors in test_triangle_triangle.py which at least doesn't hint at Python 3.12 being (more) incompatible than 3.11.

@pd-nisse Got all tests green is this PR, but made sure to upgrade to NumPy 2.0 first (via #319 + #320)

I'll be fixing up .github/workflows/wheels.yaml to ensure I can actually create wheels and source dist artifacts (to do a release) and then I'll be doing a release.

@dhermes
Copy link
Owner Author

dhermes commented Jun 21, 2024

@pd-nisse https://pypi.org/project/bezier/2024.6.20/ is released and supports 3.12

@pd-nisse
Copy link

Awesome, thanks for the quick turnaround @dhermes 🙇
I'll test it out on my side!

@pd-nisse
Copy link

@dhermes I tested it with our project, but ran into issue because it now requires numpy>=2.0.0. Some of our other dependencies have constraint numpy<2.0.0 😢
Is your constraint a hard requirement? I'm wondering if it could be loosened.

@dhermes
Copy link
Owner Author

dhermes commented Jun 28, 2024

@pd-nisse Have you tried installing with --no-deps so you can manage your own NumPy?

Given the usage of Cython-ized binary extension (_speedup.c), I'm not entirely sure it's possible to support NumPy 1.x and 2.x at the same time. (I think some parts of the NumPy ABI may have changed.)

@Jamim
Copy link

Jamim commented Jun 28, 2024

Hello @pd-nisse,

@dhermes I tested it with our project, but ran into issue because it now requires numpy>=2.0.0. Some of our other dependencies have constraint numpy<2.0.0 😢 Is your constraint a hard requirement? I'm wondering if it could be loosened.

Can you share a list of those packages?
I'm wondering if it wouldn't be easier to add support for numpy>=2.0.0 to them.

@pd-nisse
Copy link

Hey there, quick update: I was able to resolve it on my side. I tested our own package with numpy>=2.0.0 and all tests complete. So for Python 3.11 and lower, I continue using bezier==2023.7.28 with numpy<2.0.0. For Python 3.12 and higher, I use bezier==2024.6.20 and numpy>=2.0.0.
Thanks again for all the help!

@dhermes
Copy link
Owner Author

dhermes commented Jul 18, 2024

Cheers @pd-nisse! Onward and upward to newer and bigger things!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants