Skip to content

Commit 0761df0

Browse files
authored
Merge pull request #641 from hx2A/prerelease
Pre release
2 parents 2eedeb4 + 34c47c0 commit 0761df0

File tree

7 files changed

+98
-10
lines changed

7 files changed

+98
-10
lines changed

py5_docs/Reference/api_en/Py5Tools_processing_download_library.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Downloaded libraries will be saved in the Processing library storage directory.
2020
@@ example
2121
import py5_tools
2222

23+
# this only needs to be run once
2324
py5_tools.processing.download_library("PeasyCam")
2425

2526
import py5

py5_docs/Reference/api_en/Py5Tools_processing_remove_library.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@@ meta
2-
name = processing_remove_library()
2+
name = processing.remove_library()
33
type = function
44
category = processing
55
subcategory = None

py5_jar/src/main/java/py5/core/SketchBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public static void setJOGLProperties(String py5Path) {
7070
if (variant.equals("macos")) {
7171
variant = "macosx-universal";
7272
} else {
73-
// TODO: may need to do something special for Raspberry Pi computers
74-
variant += "-" + System.getProperty("os.arch");
73+
String osarch = System.getProperty("os.arch");
74+
variant += "-" + (osarch.startsWith("arm") ? "armv6hf" : osarch);
7575
}
7676
String joglPath = py5Path + File.separator + "natives" + File.separator + variant;
7777
String javaLibraryPath = System.getProperty("java.library.path");

py5_resources/py5_module/py5/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from jpype import JClass # noqa
4242
from jpype.types import JArray, JChar, JFloat, JInt, JString # noqa
4343
from PIL import Image # noqa
44+
from py5_tools import javafx as _javafx # noqa
4445
from py5_tools.constants import VERSION as __version__
4546

4647
_environ = py5_tools.environ.Environment()
@@ -97,7 +98,7 @@
9798
pass
9899

99100
# add py5 jars to the classpath first
100-
py5_tools.add_jars(str(base_path / "jars"))
101+
py5_tools.add_jars(base_path / "jars")
101102
# add stored processing libraries
102103
py5_tools.add_jars(py5_tools.processing.library_storage_dir())
103104
# if the cwd has a jars subdirectory, add that next

py5_resources/py5_module/py5_tools/imported.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ def _run_sketch(sketch_path, classpath, exit_if_error):
223223
jvm.add_jars(sketch_path.parent / "jars")
224224

225225
set_imported_mode(True)
226-
try:
227-
import py5javafx
228-
except ImportError:
229-
pass
230226
import py5
231227

232228
if py5.is_running() if callable(py5.is_running) else py5.is_running:
@@ -290,7 +286,7 @@ def _run_sketch(sketch_path, classpath, exit_if_error):
290286
parsing.transform_py5_code(sketch_ast), filename=sketch_path, mode="exec"
291287
)
292288

293-
sys.path.extend([str(sketch_path.absolute().parent), os.getcwd()])
289+
sys.path.extend([(sketch_path.absolute().parent).as_posix(), os.getcwd()])
294290
py5_ns = dict()
295291
py5_ns.update(py5.__dict__)
296292
py5_ns["__file__"] = str(original_sketch_path)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# *****************************************************************************
2+
#
3+
# Part of the py5 library
4+
# Copyright (C) 2020-2025 Jim Schmitz
5+
#
6+
# This library is free software: you can redistribute it and/or modify it
7+
# under the terms of the GNU Lesser General Public License as published by
8+
# the Free Software Foundation, either version 2.1 of the License, or (at
9+
# your option) any later version.
10+
#
11+
# This library is distributed in the hope that it will be useful, but
12+
# WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
14+
# General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with this library. If not, see <https://www.gnu.org/licenses/>.
18+
#
19+
# *****************************************************************************
20+
import platform
21+
import sys
22+
23+
import py5_tools
24+
25+
if not py5_tools.is_jvm_running() and py5_tools.processing.check_library("JavaFX"):
26+
try:
27+
library_dir = None
28+
29+
os_arch = platform.machine()
30+
if sys.platform == "darwin":
31+
if os_arch in ("arm64", "aarch64"):
32+
# 64-bit ARM
33+
library_dir = "macos-aarch64"
34+
elif os_arch == "x86_64":
35+
# 64-bit Intel
36+
library_dir = "macos-x86_64"
37+
# else:
38+
# raise RuntimeError(f"Unsupported architecture for MacOS: {os_arch}")
39+
elif sys.platform == "linux":
40+
if os_arch == "x86_64":
41+
# 64-bit Intel
42+
library_dir = "linux-amd64"
43+
elif os_arch.startswith("armv"):
44+
# 32-bit ARM
45+
library_dir = "linux-arm"
46+
elif os_arch == "aarch64":
47+
# 64-bit ARM
48+
library_dir = "linux-aarch64"
49+
# else:
50+
# raise RuntimeError(f"Unsupported architecture for Linux: {os_arch}")
51+
elif sys.platform in ["windows", "win32"]:
52+
if os_arch in ("AMD64", "x86_64"):
53+
# 64-bit Intel
54+
library_dir = "windows-amd64"
55+
# else:
56+
# raise RuntimeError(f"Unsupported architecture for Windows: {os_arch}")
57+
# else:
58+
# raise RuntimeError(f"Unrecognized platform: sys.platform={sys.platform}")
59+
60+
if library_dir is not None:
61+
base_path = py5_tools.processing.library_storage_dir()
62+
py5_tools.add_options(
63+
f"-Djava.library.path={base_path}/javafx/library/{library_dir}/"
64+
)
65+
py5_tools.add_options(
66+
f"--module-path={base_path}/javafx/library/{library_dir}/modules/"
67+
)
68+
69+
py5_tools.add_options(
70+
"--add-exports=javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED"
71+
)
72+
py5_tools.add_options(
73+
"--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED"
74+
)
75+
76+
# add all 7 modules
77+
py5_tools.add_options(
78+
"--add-modules=javafx.base,javafx.graphics,javafx.swing,javafx.controls,javafx.media,javafx.web,javafx.fxml"
79+
)
80+
except Exception as e:
81+
print(
82+
f"JavaFX is not properly installed. Please remove JavaFX and possibly try installing it again. Error: {e}",
83+
file=sys.stderr,
84+
)
85+
86+
87+
__all__ = []
88+
89+
90+
def __dir__():
91+
return __all__

py5_resources/py5_module/py5_tools/live_coding/syncing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import zipfile
2525
from pathlib import Path
2626

27-
import numpy as np
2827
import stackprinter
2928

3029
from .import_hook import activate_py5_live_coding_import_hook

0 commit comments

Comments
 (0)