Skip to content

Commit 9e5f792

Browse files
Merge pull request #27 from NicolaDonelli/wip-issue-26
[ISSUE-26] Fix python 3.8 compatibilty
2 parents 8074da0 + 270f9d7 commit 9e5f792

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

licensecheck/packageinfo.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
from __future__ import annotations
44

55
import configparser
6-
from importlib import metadata, resources
6+
import sys
7+
from importlib import metadata
8+
if sys.version_info < (3, 9, 0):
9+
import importlib_resources as ilr
10+
else:
11+
import importlib.resources as ilr
712
from pathlib import Path
813
from typing import Any, cast
914

@@ -33,7 +38,7 @@ def getPackageInfoLocal(requirement: str) -> PackageInfo:
3338
version = pkgMetadata.get("Version", UNKNOWN)
3439
size = 0
3540
try:
36-
packagePath = resources.files(requirement)
41+
packagePath = ilr.files(requirement)
3742
size = getModuleSize(cast(Path, packagePath), name)
3843
except TypeError:
3944
pass

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ requests = "<3,>=2.28.1"
3333
fhconfparser = "<2024,>=2022"
3434
tomli = "<3,>=2.0.1"
3535
rich = "<13,>=12.6.0"
36+
importlib-resources = { version = ">=3.0.0", python = "<3.9" }
3637

3738
[tool.poetry.dev-dependencies]
3839
pytest = "^7.1.1"

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
fhconfparser<2024,>=2022
2+
importlib-resources>=3.0.0;python_version<'3.9'
23
requests<3,>=2.28.1
34
requirements-parser<2,>=0.5.0
45
rich<13,>=12.6.0

0 commit comments

Comments
 (0)