From 1491e1edb0dc8f1ab0cc7d0d6a0954958a97bbf9 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Wed, 5 Apr 2023 15:24:35 +0300 Subject: [PATCH] Fix path to data/licenses.json When we install and run this from CI, this file needs to exist in the package's folder inside site-packages. Then we can use __file__ to get the path relative to the package. See: https://python-packaging.readthedocs.io/en/latest/non-code-files.html --- MANIFEST.in | 1 + csv_metadata_quality/util.py | 4 ++-- setup.py | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..02f46d1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include csv_metadata_quality/data/licenses.json diff --git a/csv_metadata_quality/util.py b/csv_metadata_quality/util.py index 32b80ab..741476c 100644 --- a/csv_metadata_quality/util.py +++ b/csv_metadata_quality/util.py @@ -2,7 +2,7 @@ import json -from importlib.resources import files +import os from ftfy.badness import is_bad @@ -58,7 +58,7 @@ def is_mojibake(field): def load_spdx_licenses(): """Returns a Python list of SPDX short license identifiers.""" - with open(files("csv_metadata_quality").joinpath("data/licenses.json")) as f: + with open(os.path.join(os.path.dirname(__file__), "data/licenses.json")) as f: licenses = json.load(f) # List comprehension to extract the license ID for each license diff --git a/setup.py b/setup.py index 396bc8e..9160741 100644 --- a/setup.py +++ b/setup.py @@ -32,5 +32,6 @@ setuptools.setup( entry_points={ "console_scripts": ["csv-metadata-quality = csv_metadata_quality.__main__:main"] }, + include_package_data=True, install_requires=install_requires, )