Skip to content

Commit 2f2b852

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 2f2b852

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@
1919

2020

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

2726

2827
# data files that are shipped with histogrammar.
2928
_DATA = {
3029
_.name: _
31-
for _ in pathlib.Path(ROOT_DIRECTORY / "test_data").glob("*")
30+
for _ in resources.files(histogrammar.test_data).iterdir()
3231
}
3332

3433
# Tutorial notebooks
3534
_NOTEBOOK = {
36-
_.name: _
37-
for _ in pathlib.Path(ROOT_DIRECTORY / "notebooks").glob("*.ipynb")
35+
p.name: p
36+
for p in resources.files(histogrammar.notebooks).iterdir() if p.suffix == ".ipynb"
3837
}
3938

4039
# Resource types

0 commit comments

Comments
 (0)