From 93ceb4df6fa78d45a79ac62a56d0dbcb7e79d3521cfd92ac9a421393d21a3c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20S=C3=BAkup?= Date: Wed, 1 Nov 2023 15:47:22 +0000 Subject: [PATCH] Accepting request 1121580 from home:buschmann23:branches:devel:languages:python - update to version 2.5.31 * no changelog available, alternatively have a look at https://github.com/pre-commit/identify/compare/v2.2.13...v2.5.31 - use editdistance instead of ukkonen * Upstream changed from editdistance_s to ukkonen for performance reasons. Ukkonen is not now available for openSUSE. So switch back to editdistance for now. * Add 0001-use-editdistance-not-ukkonen.patch - spec file changes * remove not required python-setuptools from Requires * upstream URL has changed to https://github.com/pre-commit/identify * change requirement for python-editdistance from Suggests to Recommends OBS-URL: https://build.opensuse.org/request/show/1121580 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-identify?expand=0&rev=20 --- 0001-use-editdistance-not-ukkonen.patch | 61 +++++++++++++++++++++++++ identify-2.2.13.tar.gz | 3 -- identify-2.5.31.tar.gz | 3 ++ python-identify.changes | 17 +++++++ python-identify.spec | 21 ++++----- 5 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 0001-use-editdistance-not-ukkonen.patch delete mode 100644 identify-2.2.13.tar.gz create mode 100644 identify-2.5.31.tar.gz diff --git a/0001-use-editdistance-not-ukkonen.patch b/0001-use-editdistance-not-ukkonen.patch new file mode 100644 index 0000000..65c0624 --- /dev/null +++ b/0001-use-editdistance-not-ukkonen.patch @@ -0,0 +1,61 @@ +From: Matthias Fehring +Date: 2023-11-01 09:44:00 +0100 +Subject: Use editdistance instead of ukkonen +Upstream: never + +Upstream switched from editdistance_s to ukkonen that is currently +not packaged for openSUSE. + +--- + identify/identify.py | 10 ++++------ + setup.cfg | 2 +- + 2 files changed, 5 insertions(+), 7 deletions(-) + +--- a/identify/identify.py 2023-10-28 19:19:41.000000000 +0200 ++++ b/identify/identify.py 2023-11-01 09:39:16.942021416 +0100 +@@ -243,7 +243,7 @@ + 3. check exact text match with existing licenses + 4. failing that use edit distance + """ +- import ukkonen # `pip install identify[license]` ++ import editdistance # `pip install identify[license]` + + with open(filename, encoding='UTF-8') as f: + contents = f.read() +@@ -253,8 +253,6 @@ + min_edit_dist = sys.maxsize + min_edit_dist_spdx = '' + +- cutoff = math.ceil(.05 * len(norm)) +- + # try exact matches + for spdx, text in licenses.LICENSES: + norm_license = _norm_license(text) +@@ -265,13 +263,13 @@ + if norm and abs(len(norm) - len(norm_license)) / len(norm) > .05: + continue + +- edit_dist = ukkonen.distance(norm, norm_license, cutoff) +- if edit_dist < cutoff and edit_dist < min_edit_dist: ++ edit_dist = editdistance.distance(norm, norm_license) ++ if edit_dist < min_edit_dist: + min_edit_dist = edit_dist + min_edit_dist_spdx = spdx + + # if there's less than 5% edited from the license, we found our match +- if norm and min_edit_dist < cutoff: ++ if norm and min_edit_dist / len(norm) < .05: + return min_edit_dist_spdx + else: + # no matches :'( +--- a/setup.cfg 2023-10-28 19:19:41.000000000 +0200 ++++ b/setup.cfg 2023-11-01 10:13:07.904157653 +0100 +@@ -31,7 +31,7 @@ + + [options.extras_require] + license = +- ukkonen ++ editdistance + + [options.package_data] + identify = diff --git a/identify-2.2.13.tar.gz b/identify-2.2.13.tar.gz deleted file mode 100644 index 5370a28..0000000 --- a/identify-2.2.13.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cd06ccd046da3ece6bbc0a581173c8b67322bbfe6a80a2f52c5915cac560333f -size 101136 diff --git a/identify-2.5.31.tar.gz b/identify-2.5.31.tar.gz new file mode 100644 index 0000000..136f289 --- /dev/null +++ b/identify-2.5.31.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d119d9e1cff305bbcb0743f106daaada7035d171c7c9fd21883b5f414d2f422 +size 101612 diff --git a/python-identify.changes b/python-identify.changes index d1121cb..7b2685d 100644 --- a/python-identify.changes +++ b/python-identify.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Wed Nov 1 09:17:44 UTC 2023 - Matthias Fehring + +- update to version 2.5.31 + * no changelog available, alternatively have a look at + https://github.com/pre-commit/identify/compare/v2.2.13...v2.5.31 +- use editdistance instead of ukkonen + * Upstream changed from editdistance_s to ukkonen for performance + reasons. Ukkonen is not now available for openSUSE. So switch + back to editdistance for now. + * Add 0001-use-editdistance-not-ukkonen.patch +- spec file changes + * remove not required python-setuptools from Requires + * upstream URL has changed to https://github.com/pre-commit/identify + * change requirement for python-editdistance from Suggests to + Recommends + ------------------------------------------------------------------- Wed Aug 18 12:47:19 UTC 2021 - John Paul Adrian Glaubitz diff --git a/python-identify.spec b/python-identify.spec index 31655f9..a0674fb 100644 --- a/python-identify.spec +++ b/python-identify.spec @@ -1,7 +1,7 @@ # # spec file for package python-identify # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,24 +16,24 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-identify -Version: 2.2.13 +Version: 2.5.31 Release: 0 Summary: File identification library for Python License: MIT Group: Development/Languages/Python -URL: https://github.com/chriskuehl/identify -Source: https://github.com/chriskuehl/identify/archive/v%{version}.tar.gz#/identify-%{version}.tar.gz +URL: https://github.com/pre-commit/identify +Source: https://github.com/pre-commit/identify/archive/v%{version}.tar.gz#/identify-%{version}.tar.gz +# PATCH-FIX-OPENSUSE 0001-use-editdistance-not-ukkonen.patch -- ukkonen not packaged for opensuse now +Patch1: 0001-use-editdistance-not-ukkonen.patch BuildRequires: %{python_module editdistance} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-setuptools Requires(post): update-alternatives Requires(postun):update-alternatives -Suggests: python-editdistance +Recommends: python-editdistance BuildArch: noarch %python_subpackages @@ -42,9 +42,7 @@ File identification library for Python, including license file SPDX identifier. %prep %setup -q -n identify-%{version} -# stick with editdistance as it generally has more functionality -sed -i 's/editdistance_s.distance/editdistance.eval/' identify/identify.py -sed -i 's/editdistance_s/editdistance/' identify/identify.py +%autopatch -p1 %build %python_build @@ -67,6 +65,7 @@ sed -i 's/editdistance_s/editdistance/' identify/identify.py %doc README.md %license LICENSE %python_alternative %{_bindir}/identify-cli -%{python_sitelib}/* +%{python_sitelib}/identify +%{python_sitelib}/identify-%{version}-*-info %changelog