forked from pool/python-identify
Accepting request 1121649 from devel:languages:python
OBS-URL: https://build.opensuse.org/request/show/1121649 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-identify?expand=0&rev=10
This commit is contained in:
61
0001-use-editdistance-not-ukkonen.patch
Normal file
61
0001-use-editdistance-not-ukkonen.patch
Normal file
@@ -0,0 +1,61 @@
|
||||
From: Matthias Fehring <buschmann23@opensuse.org>
|
||||
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 =
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cd06ccd046da3ece6bbc0a581173c8b67322bbfe6a80a2f52c5915cac560333f
|
||||
size 101136
|
||||
3
identify-2.5.31.tar.gz
Normal file
3
identify-2.5.31.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4d119d9e1cff305bbcb0743f106daaada7035d171c7c9fd21883b5f414d2f422
|
||||
size 101612
|
||||
@@ -1,3 +1,20 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 1 09:17:44 UTC 2023 - Matthias Fehring <buschmann23@opensuse.org>
|
||||
|
||||
- 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 <adrian.glaubitz@suse.com>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user