Skip to content

Conversation

GoToLoop
Copy link
Contributor

@GoToLoop GoToLoop commented Sep 10, 2025

Plugin can now download JDK-21 if no minimum version is found.
But it still accepts versions before JDK-21 but >= JDK-17.
Also, this pull request has comment & code style refactors.

P.S.: Tested on a custom Thonny venv using Python 3.10.8 on Garuda (Arch-based) Linux 6.16.5 + KDE 6.4.4 (Wayland).

@hx2A
Copy link
Collaborator

hx2A commented Sep 10, 2025

Looks good to me. @villares , what do you think of this change?

@GoToLoop , how you are you formatting code? I've been using black for all of py5's code.

@GoToLoop
Copy link
Contributor Author

GoToLoop commented Sep 10, 2025

, how are you formatting code?

You mean, some "beautify" VSCode extension? I don't use any! I format everything manually as I type. :D

BtW, I use extension BasedPyright as my linter on VSCodium.

@hx2A
Copy link
Collaborator

hx2A commented Sep 10, 2025

You mean, some "beautify" VSCode extension? I don't use any! I format everything manually as I type. :D

Code formatting is cosmetic but it also helps for git diffs. It is confusing when it looks like there are a lot of changes that are actually just formatting changes, and it can cause one to overlook code changes.

@villares
Copy link
Collaborator

It all looks great. I'll try to test it on Windows soon, but I don't see how this could be any problem.

Kind of off topic, but, I have to check how to test and maybe implement my "portable hack" over this that avoids re-downloading the JDK (as it is already there). Maybe in the next plug-in version we can add a portable check and special behavior, as Thonny provides a special file to flag on the portable version.

@GoToLoop
Copy link
Contributor Author

GoToLoop commented Sep 12, 2025

... maybe implement my "portable hack" over this that avoids re-downloading the JDK (as it is already there).

This is the new function get_thonny_jdk_install() which searches for a JDK subfolder inside thonny.THONNY_USER_DIR:

def get_thonny_jdk_install() -> PurePath | Literal['']:
'''Check Thonny's user folder for a JDK installation subfolder
and return its path. Otherwise, return an empty string.'''
for subfolder in get_all_thonny_folders(): # Loop over each subfolder name
# Use regexp to check if subfolder contains a valid JDK name:
if match := _JDK_PATTERN.search(subfolder):
# Check JDK major version from 1st match group:
if is_valid_jdk_version(match.group(1)):
# Create a full path by joining THONNY_USER_DIR + folder name:
jdk_path = adjust_jdk_path(_THONNY_USER_PATH / subfolder)
# Check and return a valid JDK subfolder in THONNY_USER_DIR:
if is_valid_jdk_path(jdk_path): return jdk_path
return '' # No JDK with required version found in THONNY_USER_DIR

As long as your portable version has its JDK inside THONNY_USER_DIR, new py5mode plugin won't re-download anything.

@hx2A
Copy link
Collaborator

hx2A commented Sep 14, 2025

@GoToLoop , please let us know when you are done working on this and are ready for review. After this is merged, we can all do some more testing and then prepare for the release.

@GoToLoop
Copy link
Contributor Author

GoToLoop commented Sep 14, 2025

You can merge it at any time! That'd also relieve me to focus on other files.

@hx2A hx2A merged commit 540ed1b into py5coding:main Sep 15, 2025
@hx2A
Copy link
Collaborator

hx2A commented Sep 16, 2025

You can merge it at any time! That'd also relieve me to focus on other files.

Just merged it. Thank you for working on this!

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