From c9f0ca09c5defe997ac8be97e4ae7416790db5ab5d4e15cd424c1b13d7afe7fc Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 16 Feb 2022 18:13:57 +0000 Subject: [PATCH 1/2] =?UTF-8?q?-=20Update=20to=200.4.25:=20=20=20-=20Suppo?= =?UTF-8?q?rt=20file=205.41.=20=20=20-=20Support=20os.PathLike=20types=20?= =?UTF-8?q?=20=20-=20Fix=20compat=20mode=20handling=20with=20empty=20mime?= =?UTF-8?q?=20string=20=20=20-=20Cleanup=20library=20loading=20=20=20-=20a?= =?UTF-8?q?dd=20py.typed=20sentinal=20per=20https://www.python.org/dev/pep?= =?UTF-8?q?s/pep-0561/#p=E2=80=A6=20=20=20-=20Check=20for=20cookie=20attri?= =?UTF-8?q?bute=20before=20trying=20to=20delete=20it=20=20=20-=20Revert=20?= =?UTF-8?q?"Fix=20bug=20in=20Magic=20when=20destructor=20called=20too=20ea?= =?UTF-8?q?rly"=20=20=20-=20Fix=20yet=20another=20import=20error=20=20=20-?= =?UTF-8?q?=20add=20more=20doc=20pointers=20for=20compat=20mode,=20and=20e?= =?UTF-8?q?nable=20PendingDeprecationW=E2=80=A6=20=20=20-=20restore=20pyth?= =?UTF-8?q?on=202.7=20to=20setup.py,=20to=20preserve=20back=20compat=20=20?= =?UTF-8?q?=20-=20document=20libmagic=20compat=20layer=20=20=20-=20prefix?= =?UTF-8?q?=20add=5Fcompat=20with=20an=20underscore=20to=20avoid=20namespa?= =?UTF-8?q?ce=20pollution=20=20=20-=20remove=20from=5Fopen=5Ffile,=20since?= =?UTF-8?q?=20its=20duplicative=20with=20from=5Fdescriptor=20and=E2=80=A6?= =?UTF-8?q?=20=20=20-=20move=20typing=20stubs=20next=20to=20implementation?= =?UTF-8?q?=20=20=20-=20temorarily=20remove=20dropped=20support=20for=20py?= =?UTF-8?q?thon2=20=20=20-=20Revert=20"Remove=20Python2=20from=20the=20tes?= =?UTF-8?q?ts"=20=20=20-=20Merge=20branch=20'master'=20into=20redo-compat?= =?UTF-8?q?=20=20=20-=20Remove=20Python2=20from=20the=20tests=20=20=20-=20?= =?UTF-8?q?Add=20support=20for=20Python=203.9=20=20=20-=20Added=20support?= =?UTF-8?q?=20for=20magic=5Fdescriptor=20routine=20=20=20-=20Handle=20unde?= =?UTF-8?q?codable=20characters=20in=20description=20=20=20-=20Handle=20li?= =?UTF-8?q?bmagic=20versions=20that=20don't=20support=20MAGIC=5FEXTENSION?= =?UTF-8?q?=20=20=20-=20MAGIC=5FEXTENSION=20support=20(file=20--extension)?= =?UTF-8?q?=20=20=20-=20support=20changed=20mime=20types=20in=20test=20=20?= =?UTF-8?q?=20-=20Fix=20tests=20with=20file=205.39=20=20=20-=20add=20docke?= =?UTF-8?q?r=20tests=20for=20archlinux=20=20=20-=20Fallback=20to=20default?= =?UTF-8?q?=20behavior=20on=20setparam=20failure=20=20=20-=20Fix=20bug=20i?= =?UTF-8?q?n=20Magic=20when=20destructor=20called=20too=20early=20=20=20-?= =?UTF-8?q?=20sheep=20Create=20basic=20stub=20file=20for=20magic.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-magic?expand=0&rev=19 --- 0.4.18.tar.gz | 3 --- 0.4.25.tar.gz | 3 +++ fix-4-file-5.40.patch | 15 ------------- fix-support-file-5.41.patch | 13 ------------ fix-test-tumbleweed.patch | 34 ------------------------------ fix-test.patch | 13 ------------ python-python-magic.changes | 42 +++++++++++++++++++++++++++++++++++++ python-python-magic.spec | 40 +++++++++-------------------------- 8 files changed, 55 insertions(+), 108 deletions(-) delete mode 100644 0.4.18.tar.gz create mode 100644 0.4.25.tar.gz delete mode 100644 fix-4-file-5.40.patch delete mode 100644 fix-support-file-5.41.patch delete mode 100644 fix-test-tumbleweed.patch delete mode 100644 fix-test.patch diff --git a/0.4.18.tar.gz b/0.4.18.tar.gz deleted file mode 100644 index ef3283e..0000000 --- a/0.4.18.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b787e8056c115f37e2af11e0b98dc67d5fc182ed5ed827a62f95e3a7f0ed4be4 -size 856291 diff --git a/0.4.25.tar.gz b/0.4.25.tar.gz new file mode 100644 index 0000000..5430ac0 --- /dev/null +++ b/0.4.25.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c1f483995067ffff268103f8bb6860d2f42aa3a5a9b906eaf34bcce1de36329 +size 864121 diff --git a/fix-4-file-5.40.patch b/fix-4-file-5.40.patch deleted file mode 100644 index 6b4c743..0000000 --- a/fix-4-file-5.40.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- - test/test.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- test/test.py -+++ test/test.py 2021-04-16 12:54:00.275731435 +0000 -@@ -87,7 +87,7 @@ class MagicTest(unittest.TestCase): - try: - self.assert_values(m, { - 'magic._pyc_': 'python 2.4 byte-compiled', -- 'test.pdf': 'PDF document, version 1.2', -+ 'test.pdf': 'PDF document, version 1.2, 2 pages', - 'test.gz': - ('gzip compressed data, was "test", from Unix, last ' - 'modified: Sun Jun 29 01:32:52 2008', diff --git a/fix-support-file-5.41.patch b/fix-support-file-5.41.patch deleted file mode 100644 index f5293bd..0000000 --- a/fix-support-file-5.41.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/test/test.py b/test/test.py -index 8ea9138..968f904 100755 ---- a/test/test.py -+++ b/test/test.py -@@ -70,7 +70,7 @@ class MagicTest(unittest.TestCase): - try: - m = magic.Magic(mime=True) - self.assert_values(m, { -- 'magic._pyc_': 'text/x-bytecode.python', -+ 'magic._pyc_': ('application/octet-stream', 'text/x-bytecode.python', 'application/x-bytecode.python'), - 'test.pdf': 'application/pdf', - 'test.gz': ('application/gzip', 'application/x-gzip'), - 'test.snappy.parquet': 'application/octet-stream', diff --git a/fix-test-tumbleweed.patch b/fix-test-tumbleweed.patch deleted file mode 100644 index c0d5dd4..0000000 --- a/fix-test-tumbleweed.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- python-magic-0.4.18/test/test.py 2020-05-06 04:25:46.000000000 +0200 -+++ python-magic-0.4.18/test/test.py 2020-07-25 19:51:08.263172240 +0200 -@@ -59,9 +59,9 @@ - def test_from_buffer_str_and_bytes(self): - m = magic.Magic(mime=True) - s = '#!/usr/bin/env python\nprint("foo")' -- self.assertEqual("text/x-python", m.from_buffer(s)) -+ self.assertEqual("text/x-script.python", m.from_buffer(s)) - b = b'#!/usr/bin/env python\nprint("foo")' -- self.assertEqual("text/x-python", m.from_buffer(b)) -+ self.assertEqual("text/x-script.python", m.from_buffer(b)) - - def test_mime_types(self): - dest = os.path.join(MagicTest.TESTDATA_DIR, -@@ -70,7 +70,7 @@ - try: - m = magic.Magic(mime=True) - self.assert_values(m, { -- 'magic._pyc_': 'application/octet-stream', -+ 'magic._pyc_': 'text/x-bytecode.python', - 'test.pdf': 'application/pdf', - 'test.gz': ('application/gzip', 'application/x-gzip'), - 'test.snappy.parquet': 'application/octet-stream', -@@ -97,7 +97,9 @@ - ': Sun Jun 29 01:32:52 2008, from Unix, original size 15', - 'gzip compressed data, was "test", ' - 'last modified: Sun Jun 29 01:32:52 2008, ' -- 'from Unix, original size modulo 2^32 15' -+ 'from Unix, original size modulo 2^32 15', -+ 'gzip compressed data, was "test", last modified: ' -+ 'Sun Jun 29 01:32:52 2008, from Unix, truncated', - ), - 'text.txt': 'ASCII text', - 'test.snappy.parquet': ('Apache Parquet', 'Par archive data'), diff --git a/fix-test.patch b/fix-test.patch deleted file mode 100644 index 64d5908..0000000 --- a/fix-test.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- python-magic-0.4.18/test/test.py 2020-05-06 04:25:46.000000000 +0200 -+++ python-magic-0.4.18/test/test.py 2020-07-25 20:02:37.988452945 +0200 -@@ -97,7 +97,9 @@ - ': Sun Jun 29 01:32:52 2008, from Unix, original size 15', - 'gzip compressed data, was "test", ' - 'last modified: Sun Jun 29 01:32:52 2008, ' -- 'from Unix, original size modulo 2^32 15' -+ 'from Unix, original size modulo 2^32 15', -+ 'gzip compressed data, was "test", last modified: ' -+ 'Sun Jun 29 01:32:52 2008, from Unix, truncated', - ), - 'text.txt': 'ASCII text', - 'test.snappy.parquet': ('Apache Parquet', 'Par archive data'), diff --git a/python-python-magic.changes b/python-python-magic.changes index d1a76fc..513562f 100644 --- a/python-python-magic.changes +++ b/python-python-magic.changes @@ -1,3 +1,45 @@ +------------------------------------------------------------------- +Wed Feb 16 17:32:56 UTC 2022 - Matej Cepl + +- Update to 0.4.25: + - Support file 5.41. + - Support os.PathLike types + - Fix compat mode handling with empty mime string + - Cleanup library loading + - add py.typed sentinal per https://www.python.org/dev/peps/pep-0561/#p… + - Check for cookie attribute before trying to delete it + - Revert "Fix bug in Magic when destructor called too early" + - Fix yet another import error + - add more doc pointers for compat mode, and enable PendingDeprecationW… + - restore python 2.7 to setup.py, to preserve back compat + - document libmagic compat layer + - prefix add_compat with an underscore to avoid namespace pollution + - remove from_open_file, since its duplicative with from_descriptor and… + - move typing stubs next to implementation + - temorarily remove dropped support for python2 + - Revert "Remove Python2 from the tests" + - Merge branch 'master' into redo-compat + - Remove Python2 from the tests + - Add support for Python 3.9 + - Added support for magic_descriptor routine + - Handle undecodable characters in description + - Handle libmagic versions that don't support MAGIC_EXTENSION + - MAGIC_EXTENSION support (file --extension) + - support changed mime types in test + - Fix tests with file 5.39 + - add docker tests for archlinux + - Fallback to default behavior on setparam failure + - Fix bug in Magic when destructor called too early + - sheep Create basic stub file for magic.py + - various cleanups proposed by debian folks + - Merge in compatability mode with libmagic + - add from_open_file to match libmagic binding featureset +- Remove upstreamed patches: + - fix-test-tumbleweed.patch + - fix-test.patch + - fix-4-file-5.40.patch + - fix-support-file-5.41.patch + ------------------------------------------------------------------- Fri Oct 22 10:09:21 UTC 2021 - Matej Cepl diff --git a/python-python-magic.spec b/python-python-magic.spec index b24983b..e988aeb 100644 --- a/python-python-magic.spec +++ b/python-python-magic.spec @@ -1,7 +1,7 @@ # # spec file for package python-python-magic # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,30 +19,24 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define oldpython python Name: python-python-magic -Version: 0.4.18 +Version: 0.4.25 Release: 0 Summary: File type identification using libmagic License: Python-2.0 Group: Development/Languages/Python URL: https://github.com/ahupp/python-magic Source: https://github.com/ahupp/python-magic/archive/%{version}.tar.gz -#PATCH-FIX-OPENSUSE fix-test.patch -- adapt file outputs to opensuse -Patch0: fix-test.patch -Patch1: fix-test-tumbleweed.patch -Patch2: fix-4-file-5.40.patch -Patch3: fix-support-file-5.41.patch +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: file BuildRequires: python-rpm-macros Requires: file -# python-python-magic and python-magic use the same namespace (ie. filename) -# and have a very similar functionality but are incompatible to each other. -# https://github.com/ahupp/python-magic/issues/21 -Conflicts: python-magic +Provides: python-magic BuildArch: noarch %ifpython2 -Conflicts: %{oldpython}-magic +Provides: %{oldpython}-magic %endif %python_subpackages @@ -53,25 +47,12 @@ supports both textual and MIME-type output. %prep %setup -q -n python-magic-%{version} -%if 0%{?suse_version} > 1500 -# Tumbleweed -%patch1 -p1 -%elif 0%{?sle_version} < 150300 && 0%{?is_opensuse} -# Leap 15.2 and older -%patch0 -p1 -%endif -%if %{?pkg_vcmp:%{pkg_vcmp file >= 5.40}}%{!?pkg_vcmp:0} -%patch2 -p0 -%endif -%if %{?pkg_vcmp:%{pkg_vcmp file >= 5.41}}%{!?pkg_vcmp:0} -%patch3 -p1 -%endif %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check @@ -81,8 +62,7 @@ export LC_ALL=en_US.UTF-8 %files %{python_files} %license LICENSE %doc README.md -%{python_sitelib}/magic.py* -%pycache_only %{python_sitelib}/__pycache__/magic*.py* -%{python_sitelib}/python_magic-%{version}-py*.egg-info +%{python_sitelib}/magic +%{python_sitelib}/python_magic-%{version}*-info %changelog From 9bfe278c0f584e857f1768bcc226eacb6114396e65da3d43b493044c1801f13b Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 16 Feb 2022 18:23:59 +0000 Subject: [PATCH 2/2] Rollback to python setup.py method for now. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-magic?expand=0&rev=20 --- python-python-magic.spec | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python-python-magic.spec b/python-python-magic.spec index e988aeb..6513e4e 100644 --- a/python-python-magic.spec +++ b/python-python-magic.spec @@ -26,9 +26,8 @@ License: Python-2.0 Group: Development/Languages/Python URL: https://github.com/ahupp/python-magic Source: https://github.com/ahupp/python-magic/archive/%{version}.tar.gz -BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} -BuildRequires: %{python_module wheel} +BuildRequires: %{python_module xml} BuildRequires: fdupes BuildRequires: file BuildRequires: python-rpm-macros @@ -49,10 +48,10 @@ supports both textual and MIME-type output. %setup -q -n python-magic-%{version} %build -%pyproject_wheel +%python_build %install -%pyproject_install +%python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check