Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pepclibs/helperlibs/ProjectFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

# TODO: remove the 'importlib_resources' import and use 'importlib.resources' instead when
# switching to Python 3.10+. This hack is needed only to support Python 3.9.
#import importlib.resources
import importlib_resources
try:
import importlib.resources
importlib_resources_files = importlib.resources.files
except:
import importlib_resources
importlib_resources_files = importlib_resources.files
Copy link
Contributor

@dedekind dedekind Aug 18, 2025

Choose a reason for hiding this comment

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

We prefer symbols that are not supposed to be used outside of module to start with "_", as a mark that the symbol is private. This is a standard practice in Python programs.

Also there is a warning: No exception type(s) specified.

But I'll address these minor things on top of your patch, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume I need to intercept ImportError.


from pepclibs.helperlibs import ProcessManager, Logging
from pepclibs.helperlibs.Exceptions import Error, ErrorNotFound

Expand Down Expand Up @@ -78,7 +83,7 @@ def get_python_data_package_path(prjname: str) -> Path | None:
# 'improtlib.resources.files()' into a 'Path' object. Just using 'str()' does not work.
# However, with 'joinpath()' it is possible to get a string, and then we can convert it
# to a 'Path' object.
multiplexed_path = importlib_resources.files(pkgname)
multiplexed_path = importlib_resources_files(pkgname)
pkgpath = Path(str(multiplexed_path.joinpath(f"../{pkgname}")))
if pkgpath:
return pkgpath.resolve()
Expand Down