Skip to content

Commit

Permalink
MNT: Use importlib_resources for Python < 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jul 14, 2022
1 parent 63d6cec commit 0d542ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/schemacode/schemacode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""A Python package for working with the BIDS schema."""
from . import render, schema, utils

from importlib import resources as ilr
try:
from importlib.resources import as_file, files
except ImportError: # PY<3.9
from importlib_resources import as_file, files

__all__ = [
"render",
"schema",
"utils",
]

version_file = ilr.files("schemacode.data") / "schema" / "SCHEMA_VERSION"
with ilr.as_file(version_file) as path:
version_file = files("schemacode.data") / "schema" / "SCHEMA_VERSION"
with as_file(version_file) as path:
__version__ = path.read_text().strip()
1 change: 1 addition & 0 deletions tools/schemacode/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ install_requires =
pandas
tabulate
pyyaml
importlib_resources; python_version < "3.9"
packages = find:
include_package_data = false
zip_safe = false
Expand Down

0 comments on commit 0d542ea

Please sign in to comment.