From 1b39b573235fb8f97b072b39762db2a61267b762 Mon Sep 17 00:00:00 2001 From: Fabien Snauwaert Date: Mon, 8 Dec 2025 21:59:10 +0100 Subject: [PATCH] Fix Python 3.13 compatibility by updating scikit-image and using modern importlib.resources API --- colornamer/colornamer.py | 10 +++------- setup.py | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/colornamer/colornamer.py b/colornamer/colornamer.py index ecded44..e93ff83 100644 --- a/colornamer/colornamer.py +++ b/colornamer/colornamer.py @@ -1,11 +1,7 @@ from typing import List, Dict from functools import lru_cache -try: - import importlib.resources as pkg_resources -except ImportError: - # Try backported to PY<37 `importlib_resources`. - import importlib_resources as pkg_resources +from importlib.resources import files import numpy as np, json from skimage.color import rgb2lab, deltaE_ciede2000 @@ -15,7 +11,7 @@ @lru_cache(maxsize=1) def _get_color_data(): - hierarchy_txt = pkg_resources.read_text("static", HIERARCHY_JSON_FILE) + hierarchy_txt = files("static").joinpath(HIERARCHY_JSON_FILE).read_text() color_json = json.loads(hierarchy_txt) rgb_values = np.array( [ @@ -87,7 +83,7 @@ def get_color_json() -> Dict: """ Just return the whole json from color_hierarchy.json; you can then use it however you like. For example, pd.DataFrame(color_json) if a pandas DataFrame is useful to you.""" - hierarchy_txt = pkg_resources.read_text("static", HIERARCHY_JSON_FILE) + hierarchy_txt = files("static").joinpath(HIERARCHY_JSON_FILE).read_text() color_json = json.loads(hierarchy_txt) return color_json diff --git a/setup.py b/setup.py index e7414d9..a961a55 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ url="https://github.com/stitchfix/colornamer", packages=find_packages(), package_data={"static": ["color_hierarchy.json", "color_hierarchy.csv"],}, - install_requires=["importlib_resources", "numpy", "scikit-image==0.19.1",], - python_requires=">=3.7", + install_requires=["numpy", "scikit-image>=0.22.0",], + python_requires=">=3.9", author="Dan Tasse", author_email="dan.tasse@stitchfix.com" )