Skip to content

Commit 9332b2e

Browse files
authored
Merge pull request #648 from hx2A/fix647
Fix647
2 parents bb1be2d + 8e9874e commit 9332b2e

5 files changed

Lines changed: 23 additions & 7 deletions

File tree

generator/reference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
("Py5Tools", "processing_installed_libraries"): [
364364
(
365365
[],
366-
"list[str]",
366+
"set[str]",
367367
)
368368
],
369369
("Py5Tools", "processing_check_library"): [

py5_docs/Reference/api_en/Py5Tools_processing_installed_libraries.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ category = processing
55
subcategory = None
66

77
@@ signatures
8-
processing_installed_libraries() -> list[str]
8+
processing_installed_libraries() -> set[str]
99

1010
@@ description
1111
List the Processing libraries stored in your computer's Processing library storage directory. These are all of the Processing libraries that have been installed using the [](py5tools_processing_download_library) function. To get the location of the library storage directory, use the [](py5tools_processing_library_storage_dir) function.

py5_resources/py5_module/py5_tools/javafx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222

2323
import py5_tools
2424

25-
if not py5_tools.is_jvm_running() and py5_tools.processing.check_library("JavaFX"):
25+
if (
26+
not py5_tools.is_jvm_running()
27+
and "JavaFX" in py5_tools.processing.installed_libraries()
28+
):
2629
try:
2730
library_dir = None
2831

py5_resources/py5_module/py5_tools/processing.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@
3333
class ProcessingLibraryManager:
3434

3535
def __init__(self):
36-
self._libraries = ProcessingLibraryInfo()
36+
self._libraries = None
37+
38+
def _check_libraries(self):
39+
try:
40+
if self._libraries is None:
41+
self._libraries = ProcessingLibraryInfo()
42+
except:
43+
raise RuntimeError(
44+
"Processing library information not available. Your network connection might not be working."
45+
) from None
3746

3847
def _store_library_info(self, library_name, info):
3948
info_file = STORAGE_DIR / f"{library_name}.txt"
@@ -66,7 +75,7 @@ def _load_library_info(self, library_name):
6675
return info
6776

6877
def installed_libraries(self):
69-
return [f.stem for f in STORAGE_DIR.glob("*.txt")]
78+
return {f.stem for f in STORAGE_DIR.glob("*.txt")}
7079

7180
def check_library(self, library_name):
7281
"""Check if a library is available and up to date.
@@ -77,6 +86,8 @@ def check_library(self, library_name):
7786
Returns:
7887
bool: True if the library is available and up to date, False otherwise.
7988
"""
89+
self._check_libraries()
90+
8091
info = self._libraries.get_library_info(library_name=library_name)
8192

8293
if len(info) == 0:
@@ -101,6 +112,8 @@ def get_library(self, library_name):
101112
Returns:
102113
dict: Information about the downloaded library.
103114
"""
115+
self._check_libraries()
116+
104117
info = self._libraries.get_library_info(library_name=library_name)
105118

106119
if len(info) == 0:
@@ -155,7 +168,7 @@ def library_storage_dir() -> Path:
155168
return STORAGE_DIR
156169

157170

158-
def installed_libraries() -> list[str]:
171+
def installed_libraries() -> set[str]:
159172
"""$module_Py5Tools_processing_installed_libraries"""
160173
global _library_manager
161174
if _library_manager is None:

py5_resources/py5_module/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "Processing for CPython"
99
readme = "README.md"
1010
license = "LGPL-2.1-only"
11-
requires-python = ">3.9"
11+
requires-python = ">=3.9"
1212
authors = [
1313
{ name = "Jim Schmitz", email = "jim@ixora.io" },
1414
]

0 commit comments

Comments
 (0)