Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pathlib to get path to site-packages instead of importlib.resources #707

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion jnius_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_classpath():
# add a path to java classes packaged with jnius
if sys.version_info >= (3, 9):
from contextlib import ExitStack
from pathlib import Path
import importlib.resources
import atexit

Expand All @@ -80,7 +81,7 @@ def get_classpath():
atexit.register(file_manager.close)
# importlib.resources.files is only available from Python 3.9
# use https://github.com/python/importlib_resources/issues/60 not __name__ as jnius_config.py is not a package
resource_path = importlib.resources.files('jnius') / 'src'
resource_path = Path(__file__).parent / 'jnius' / 'src'
return_classpath = [ str(resource_path) ]
file_manager.enter_context(importlib.resources.as_file(resource_path))
else:
Expand Down