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

Factor out dependency checking. Use modern version handling #2866

Merged
merged 1 commit into from
Jul 30, 2023

Conversation

Julian-O
Copy link
Contributor

toolset.py uses the class LooseVersion from distutils to implement comparison of versions.

Distutils is deprecated, and won't be in Python 3.12 which is < 3 months away.

As a result, deprecations warnings are appearing in p4a's logs.

This PR moves over to use packaging.Version. packaging is a already an install_req.

Note: packaging.Version is a lot more opinionated about what a version number must look like. The current Python dependencies that are checked are sh and colorama, both of which adhere to this versioning standard, so there is no issue there.

But, Android SDK versions sometimes contain spaces, so that code has become more complex.

This presented an opportunity to move the dependency-checking out of toolchain.py (another 1300-line file) into its own file.

[This area is expected to need an overhaul to eventually support different python dependencies on different platforms, and Windows Prerequisites.]

Which presented an opportunity to cleanup the imports to follow PEP8 (alphabetical order, standard-then-3rd-party-then-local).

I have added no additional unit-tests. It is tricky to work out a good way to test this.

LooseVersion used again


Handle bad SDK versions
Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@misl6 misl6 merged commit 7a0c935 into kivy:develop Jul 30, 2023
misl6 added a commit that referenced this pull request Sep 17, 2023
* Update `cffi` recipe for Python 3.10 (#2800)

* Update __init__.py

version bump to 1.15.1

* Update disable-pkg-config.patch

adjust patch for 1.15.1

* Use build rather than pep517 for building (#2784)

pep517 has been renamed to pyproject-hooks, and as a consequence all of
the deprecated functionality has been removed. build now provides the
functionality required, and since we are only interested in the
metadata, we can leverage a helper function for that. I've also removed
all of the subprocess machinery for calling the wrapping function, since
it appears to not be as noisy as pep517.

* Bump actions/setup-python and actions/checkout versions, as old ones are deprecated (#2827)

* Removes `mysqldb` recipe as does not support Python 3 (#2828)

* Removes `Babel` recipe as it's not needed anymore. (#2826)

* Remove dateutil recipe, as it's not needed anymore (#2829)

* Optimize CI runs, by avoiding unnecessary rebuilds (#2833)

* Remove `pytz` recipe, as it's not needed anymore (#2830)

* `freetype` recipe: Changed the url to use https as http doesn't work (#2846)

* Fix `vlc` recipe build (#2841)

* Correct sys_platform (#2852)

On Window, sys.platform = "win32".

I think "nt" is a reference to os.name.

* Fix code string - quickstart.rst

* Bump `kivy` version to `2.2.1` (#2855)

* Use a pinned version of `Cython` for now, as most of the recipes are incompatible with `Cython==3.x.x` (#2862)

* Automatically generate required pre-requisites (#2858)

`get_required_prerequisites()` maintains a list of Prerequisites required by each platform.

But that same information is already stored in each Prerequisite class.

Rather than rather than maintaining two lists which might become inconsistent, auto-generate one.

* Use `platform.uname` instead of `os.uname` (#2857)

Advantages:

- Works cross platform, not just Unix.
- Is a namedtuple, so can use meaningful  fieldnames.

Also snuck in correction to typo in Readme which doesn't warrant its own review.

* Fix simple typos in comments (#2863)

One typo I introduced while trying to fix the other.

* `build_platform` should be all-lowercase (#2864)

* Docs: Fix typos and improved README quickstart (#2860)

* Made p4a apk build command more general - readme

* Fix twice spelled - readme

* updated p4a build command

* Cleanup `patching.py` (#2868)

Major changes to comments, param names, function ordering.
Removed deprecated LooseVersion
Move os.uname to platform.uname
Added win32 check
Windows fix

* Update Python versions in CI tests

Python 3.11 was released October 2022.
Python 3.7 went end-of-life June 2023

* Update documentation to reflect Python 3.7 being end-of-life.

* Correct check for `--sdk` option (#2870)

* Factor out dependency checking. Use modern version handling (#2866)

LooseVersion used again


Handle bad SDK versions

* Linter fixes (#2874)

The errors were:
```
pythonforandroid/bootstrap.py:136:5: F811 redefinition of unused 'name' from line 73
pythonforandroid/build.py:111:5: F811 redefinition of unused 'libs_dir' from line 82
pythonforandroid/build.py:127:5: F811 redefinition of unused 'aars_dir' from line 83
pythonforandroid/graph.py:48:12: E721 do not compare types, for exact checks use `is`
pythonforandroid/graph.py:163:20: E721 do not compare types, for exact checks use `is`
tests/test_build.py:39:41: E231 missing whitespace after ','
tests/test_build.py:40:58: E231 missing whitespace after ','
tests/test_build.py:41:61: E231 missing whitespace after ','
tests/test_build.py:42:71: E231 missing whitespace after ','
```

* Remove deprecated FlatDir in Gradle template (#2876)

Based on lessons from https://stackoverflow.com/questions/68215302/using-flatdirs-should-be-avoided-because-it-doesnt-support-any-meta-data-format

* Standardise `ensure_dir` and `rmdir` (#2871)

* Standardise ensure_dir and rmdir

* Standardise ensure_dir and rmdir

* Add libmysqlclient to broken list

* Libtorrent failing to be rebuilt

* Add boost to broken recipes list

* Standardise on move (files, directories) (#2884)

* Add new util function (and tests) called `move`.
* Change references to sh.mv to use move (as it is faster and cross-platform).
* Change conditional "mv -t" to a for loop.

* Standardise on touch files (#2886)

Existing code shells out to run the `touch` Unix command.
This can be done faster (and cross-platform) with `pathlib`'s touch method.

* Created a utility to accept string paths or pathlib paths and applies touch.
* Created test for it.
* Update all instances to use it, and updated their tests.

* Update CHANGELOG.md and bump version to 2023.09.16

---------

Co-authored-by: HyTurtle <[email protected]>
Co-authored-by: Steve Kowalik <[email protected]>
Co-authored-by: Mathias Lindström <[email protected]>
Co-authored-by: Ansh Dadwal <[email protected]>
Co-authored-by: Julian <[email protected]>
Co-authored-by: Kulothungan U.G <[email protected]>
Co-authored-by: Andre Miras <[email protected]>
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.

2 participants