Skip to content

Remove distutils usage, as is not available anymore on Python 3.12 #2912

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 2 commits into from
Nov 6, 2023

Conversation

misl6
Copy link
Member

@misl6 misl6 commented Nov 5, 2023

Recently, our CI pipeline began failing due to the default Python version provided by actions/setup-python being set to 3.12. This issue stems from the removal of distutils in Python 3.12.

Changes:

To address the Python 3.12 compatibility issue, this pull request introduces the following changes:

  • Replaced distutils.spawn.find_executable with shutil.which for locating executables.
  • Replaced the use of distutils.version.LooseVersion with packaging.version.version for version comparisons.
  • Introduced two new methods, build_tools_version_sort_key and max_build_tool_version, in the pythonforandroid.utils module. These additions not only resolve DRY (Don't Repeat Yourself) violations but also enhance testability.
  • Updates the testapps to use setuptools instead of distutils.
  • Adds a setuptools dependency

These changes ensure that our codebase remains compatible with Python 3.12 and eliminates any reliance on deprecated distutils functionality.

@misl6 misl6 force-pushed the feat/remove-distutils branch from caadfb2 to 3099c4d Compare November 5, 2023 10:39
@misl6 misl6 requested a review from Julian-O November 5, 2023 15:42
@misl6
Copy link
Member Author

misl6 commented Nov 5, 2023

@Julian-O , I've seen I touched some of your code, so added you as a reviewer 😉

Copy link
Contributor

@Julian-O Julian-O left a comment

Choose a reason for hiding this comment

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

All looks good to me.

There were some failing MacOs tests - I cant read the full logs from this tablet, but I assume they are unrelated.

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

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

Nice thanks

@@ -191,8 +187,9 @@ def check_ndk_api(ndk_api, android_api):

MIN_PYTHON_MAJOR_VERSION = 3
MIN_PYTHON_MINOR_VERSION = 6
Copy link
Member

Choose a reason for hiding this comment

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

Out of scope, but I'm wondering, is 3.6 still the minor recommended version?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd encourage upgrading to Python 3.8 as a minimum, but I see that as a project decision.

  • Python 3.6 and Python 3.7 are end of life. Python 3.8 has just under a year left of security support.

  • The latest released version of Buildozer claims to support back to 3.6. The in-dev version is 3.8 minimum.

  • The latest released version of Kivy claims to support back to 3.7. The in-dev version is 3.7 minimum.

  • p4a's setup.py advertises 3.7, not 3.6.

My attitude is if you don't test it, you aren't really supporting it, so whatever the decision, please ensure the CI tests cover what setup.py advertises.

Copy link
Member Author

Choose a reason for hiding this comment

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

About this specific issue (the one suggested by @AndreMiras ):
I will (immediately, so we do not miss it), open a new issue, and target with a separate proper PR.

Generally, about the minimum Python version:

  • kivy/kivy: We still need to include 3.7 even if reached EOL, at least for 2.3.0 as piwheels still requires 3.7 wheels (due to debian buster). Then, I will check out with piwheels maintainer, if there's a chance to avoid distributing wheels for debian buster.
  • Same applies for kivy/pyobjus, kivy/pyjnius and kivy/plyer, as are quite tied with kivy/kivy.
  • For kivy/python-for-android, kivy/kivy-ios and kivy/buildozer: what are we waiting to set the minimum version to 3.8 ? 😅

Copy link
Member

Choose a reason for hiding this comment

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

Great insight, thanks @misl6
And yeah of course it makes sense to address that in dedicated PR, it caught my attention in this PR, but it's totally out of this scope

@misl6 misl6 merged commit d8c3947 into kivy:develop Nov 6, 2023
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.

3 participants