tabreturn / thonny-py5mode

A py5 plug-in for Thonny
Do What The F*ck You Want To Public License
23 stars 8 forks source link

thonny-py5mode plugin installs incompatible JDK runtime #45

Closed claudefalbriard closed 4 months ago

claudefalbriard commented 2 years ago

Using the Thonny plugin by calling "thonny-py5mode" I've got into an issue related to the architecture choice for the JDK-17 package. My test environment is a Raspberry Pi-3B using architecture aarch64. The JDK, which was automatically installed by the plugin, was incompatible. As a temporary fix, I've manually downloaded an OpenJDK 17 and fixed the PATH via bash and corrected the JAVA_HOME variable inside the Thonny settings. This fix works OK. Please analyze the automatic install routine of the plugin in order to download a hardware compatible JDK runtime.

villares commented 2 years ago

This is where the jdk-install module is used: https://github.com/tabreturn/thonny-py5mode/blob/main/thonnycontrib/thonny-py5mode/install_jdk.py

Reading its documentation it should detect architecture: image

@claudefalbriard, can you try:

import jdk

print(jdk.OS)       # Detected platform operating system
print(jdk.ARCH)     # Detected platform CPU architecture

To see if it is detecting the aarch64 correctly?

claudefalbriard commented 2 years ago

Here you find the debugs from the console of the Ubuntu as well as the output generated by the Python jdk packet. Its results shows that it picks a wrong architecture code for my Raspberry hardware.

Ubuntu Terminal:

(base) claude@claude-raspberry:~$ uname -m

aarch64

Thonny IDE:

import jdk
print(jdk.OS)
print(jdk.ARCH)

output is: linux x64

claudefalbriard commented 2 years ago

The error seems to be located at the package: python "jdk". The "install-jdk" package doesn't mention other architectures like: Raspberry aarch64. The web page says: "Currently supports 32-bit and 64-bit versions of Windows, Linux, and macOS"

villares commented 2 years ago

Cool, let's see how we can improve that.

Can we hack our own version of jdk-install?

Then perhaps we could offer a PR upstream...

villares commented 2 years ago

This is where the magic should happen... https://github.com/jyksnw/install-jdk/blob/master/jdk/__init__.py

from sys import platform, maxsize
from os import path

_IS_WINDOWS = os.name == "nt"
_IS_DARWIN = platform == "darwin"
_UNPACK200 = "unpack200.exe" if _IS_WINDOWS else "unpack200"
_UNPACK200_ARGS = '-r -v -l ""' if _IS_WINDOWS else ""
_USER_DIR = path.expanduser("~")
_JRE_DIR = path.join(_USER_DIR, ".jre")
_JDK_DIR = path.join(_USER_DIR, ".jdk")

OS = "windows" if _IS_WINDOWS else "mac" if _IS_DARWIN else platform
ARCH = "x64" if maxsize > 2 ** 32 else "x32"
villares commented 2 years ago

According to this: https://raspberrypi.stackexchange.com/a/117313/3089

platform.machine() will return:

armv7l on Raspberry Pi running on Raspbian 32-bit. aarch64 on all Arm 64-bit OSes, including those running in Amazon AWS Graviton2.

[UPDATE] I can't find how to call platform.machine()!!!

[UPDATE 2]:

import os
print(os.uname().machine)
villares commented 2 years ago

https://github.com/jyksnw/install-jdk/issues/18

jyksnw commented 1 year ago

Hi, I am the creator and maintainer of install-JDK. First, I apologize that I didn't get to this issue sooner. I had no clue that the project became popular and was being used in many places. I had created it as a one-off script for something I needed at work one day. With that said, I plan to give attention to the project over the coming weeks and months to see how I can better support the adopted community. The first two items I plan to tackle are moving to the Adoptium API next up and adding support for other architectures.

villares commented 1 year ago

Hi, I am the creator and maintainer of install-JDK. First, I apologize that I didn't get to this issue sooner. I had no clue that the project became popular and was being used in many places. I had created it as a one-off script for something I needed at work one day. With that said, I plan to give attention to the project over the coming weeks and months to see how I can better support the adopted community. The first two items I plan to tackle are moving to the Adoptium API next up and adding support for other architectures.

Wonderful news @jyksnw! We will try to help you with the limited knowledge we have, probably testing. Thank you so much for your work.

Cheers @MarcScott check this good news... and maybe you'll be able to help too :wink:

villares commented 4 months ago

@claudefalbriard, I think we can close this now. If you find any problems, we can re-open it!