Skip to content

Commit

Permalink
Use backport importlib_resources for older pythons
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Jan 22, 2024
1 parent cd18008 commit 6d12b57
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Lib/gfsubsets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import re
import sys
import warnings
from importlib import resources
# importlib.resources.files only available since Python>3.9,
# temporarily use backport
from importlib_resources import files
from fontTools import ttLib

from . import subsets

nam_files = resources.files("gfsubsets.data")
nam_files = files("gfsubsets.data")


class NamFileDict(dict):
Expand Down
6 changes: 4 additions & 2 deletions Lib/gfsubsets/subsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
# limitations under the License.
#
import os
from importlib import resources
# importlib.resources.files only available since Python>3.9,
# temporarily use backport
from importlib_resources import files

subset_files = [resource.name for resource
in resources.files("gfsubsets.data").iterdir()
in files("gfsubsets.data").iterdir()
if resource.name.endswith("_unique-glyphs.nam")]

SUBSETS = sorted(
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ authors = [
{name = 'Garret Rieger', email = "[email protected]" },
{name = 'Roderick Sheeter', email = "[email protected]" }
]
dependencies = [
"importlib_resources" # Backport for Python < 3.9
]

[project.optional-dependencies]
dev = [
"youseedee"
]


[tool.setuptools.package-dir]
gfsubsets = "Lib/gfsubsets"

0 comments on commit 6d12b57

Please sign in to comment.