Skip to content

Commit d79deef

Browse files
author
kx79wq
committed
ENH: use importlib to collect hg resources
- importlib only available since python 3.9 - turn off tests for deprecated python 3.8
1 parent 055d1f4 commit d79deef

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest]
13-
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
13+
python: ['3.9', '3.10', '3.11', '3.12']
1414
runs-on: ${{ matrix.os }}
1515

1616
steps:

histogrammar/resources.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,18 @@
1919

2020

2121
# Resources lookup file for histogrammar
22-
23-
import pathlib
24-
25-
ROOT_DIRECTORY = pathlib.Path(__file__).resolve().parent
26-
22+
from importlib import resources
2723

2824
# data files that are shipped with histogrammar.
2925
_DATA = {
3026
_.name: _
31-
for _ in pathlib.Path(ROOT_DIRECTORY / "test_data").glob("*")
27+
for _ in resources.files("histogrammar.test_data").iterdir()
3228
}
3329

3430
# Tutorial notebooks
3531
_NOTEBOOK = {
36-
_.name: _
37-
for _ in pathlib.Path(ROOT_DIRECTORY / "notebooks").glob("*.ipynb")
32+
p.name: p
33+
for p in resources.files("histogrammar.notebooks").iterdir() if p.suffix == ".ipynb"
3834
}
3935

4036
# Resource types

0 commit comments

Comments
 (0)