From 4f03ceaf662e5877c985045518d07f2f766253b96ee7aa5dfa7d8763c086174d Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Fri, 2 May 2025 03:13:25 +0000 Subject: [PATCH] - Switch to pyproject macros. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-aenum?expand=0&rev=28 --- .gitattributes | 23 +++++ .gitignore | 1 + aenum-3.1.15.tar.gz | 3 + fix-python312-tests.patch | 34 +++++++ python-aenum.changes | 181 +++++++++++++++++++++++++++++++++++ python-aenum.spec | 88 +++++++++++++++++ skip_failing_testcases.patch | 24 +++++ tempdir_missing.patch | 86 +++++++++++++++++ 8 files changed, 440 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 aenum-3.1.15.tar.gz create mode 100644 fix-python312-tests.patch create mode 100644 python-aenum.changes create mode 100644 python-aenum.spec create mode 100644 skip_failing_testcases.patch create mode 100644 tempdir_missing.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/aenum-3.1.15.tar.gz b/aenum-3.1.15.tar.gz new file mode 100644 index 0000000..1928154 --- /dev/null +++ b/aenum-3.1.15.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc9275eef098ce51254f361fb027abf2fdca6c53115ddf63be64b76f9c09bfe1 +size 111286 diff --git a/fix-python312-tests.patch b/fix-python312-tests.patch new file mode 100644 index 0000000..7e1d0c8 --- /dev/null +++ b/fix-python312-tests.patch @@ -0,0 +1,34 @@ +Index: aenum-3.1.15/aenum/test_v3.py +=================================================================== +--- aenum-3.1.15.orig/aenum/test_v3.py ++++ aenum-3.1.15/aenum/test_v3.py +@@ -1792,6 +1792,7 @@ class TestExtendEnumV3(TestCase): + self.assertEqual(len(Color), 3) + + @unittest.skipUnless(StdlibEnum, 'Stdlib Enum not available') ++ @unittest.skipIf(pyver > PY3_11, 'Failing test') + def test_extend_enum_shadow_property_stdlib(self): + class Color(StdlibEnum): + red = 1 +Index: aenum-3.1.15/aenum/doc/aenum.rst +=================================================================== +--- aenum-3.1.15.orig/aenum/doc/aenum.rst ++++ aenum-3.1.15/aenum/doc/aenum.rst +@@ -1120,7 +1120,7 @@ alias:: + ... "aliases not allowed in UniqueEnum: %r --> %r" + ... % (a, e)) + ... +- >>> class Color(UniqueEnum): ++ >>> class Color(UniqueEnum): # doctest: +SKIP + ... _order_ = 'red green blue' + ... red = 1 + ... green = 2 +@@ -1386,7 +1386,7 @@ attribute, which all function similarly: + >>> Pixel = NamedTuple('Pixel', Point+Color, module=__name__) + >>> pixel = Pixel(99, -101, 255, 128, 0) + +- >>> pixel._asdict() ++ >>> pixel._asdict() # doctest: +SKIP + OrderedDict([('x', 99), ('y', -101), ('r', 255), ('g', 128), ('b', 0)]) + + >>> Point._make((4, 5)) diff --git a/python-aenum.changes b/python-aenum.changes new file mode 100644 index 0000000..05c6346 --- /dev/null +++ b/python-aenum.changes @@ -0,0 +1,181 @@ +------------------------------------------------------------------- +Fri May 2 03:13:04 UTC 2025 - Steve Kowalik + +- Switch to pyproject macros. + +------------------------------------------------------------------- +Tue Feb 6 08:42:07 UTC 2024 - Daniel Garcia + +- Add fix-python312-tests.patch to skip failing tests with python 3.12 + gh#ethanfurman/aenum#36 + +------------------------------------------------------------------- +Thu Dec 14 09:12:26 UTC 2023 - Petr Gajdos + +- update to 3.1.15 + * remove Python 2.6 code + * add Python 3.12 enhancements + * split source code into separate files + * Enum and Flag inherit from stdlib versions + * support inheriting from empty NamedTuples + * prevent test_v3.py from being run as main + * Move Py2/3 specific code to dedicated files + +------------------------------------------------------------------- +Mon Nov 13 09:13:22 UTC 2023 - Dirk Müller + +- add sle15_python_module_pythons for SLE15 build + +------------------------------------------------------------------- +Tue Jun 20 16:44:43 UTC 2023 - Dirk Müller + +- update to 3.1.12: + * no changelog available + +------------------------------------------------------------------- +Thu Jan 19 17:25:19 UTC 2023 - Daniel Garcia + +- Update to 3.1.11: + * update MANIFEST file +- 3.1.10 + * improve tests +- 3.1.9 + * fail gracefully for badly written EnumType +- 3.1.8 + * recalculate bits used after all flags created (sometimes needed when a + custom `__new__` is in place. +- 3.1.7 + * update flag creation to (possibly) add bitwise operator methods to newly + created flags + * update extend_enum() to work with 3.11 flags +- 3.1.6 + * Update `dir()` on mixed enums to include mixed data type methods and + attributes. + + * Rename `enum_property` to `property` to match stdlib. Recommended usage is + `aenum.property` (prefix with module name). + + * Remove quadritic creation behavior. + + BREAKING CHANGE BUG FIX that won't affect most people + + Enums with a custom `__new__` that: + + - use the enum machinery to generate the values; AND + - have keyword arguments set to a default (like `None`) + + will fail to generate a missing value. To fix: remove the default value and + instead specify it on the member creation line. + + BREAKING CHANGE + + In Python 3.11 the `str()` of mixed enums will now match its `format()` which + will be the normal `str()` of the data type -- so for an IntEnum you'll see + `5` instead of `Perm.R|X`. This affects IntEnum, StrEnum, and IntFlag. + +------------------------------------------------------------------- +Mon Jan 10 14:57:17 UTC 2022 - Dirk Müller + +- update to 3.1.5: + * fix support of `auto()` kwds + * rename `aenum.property` to `aenum.enum_property` + * fix `extend_enum()` for unhashable values + * fix `extend_enum()` for most cases + +------------------------------------------------------------------- +Sat Aug 28 20:45:16 UTC 2021 - Matej Cepl + +- Convert test script into proper unittest module and then skip + failing tests (gh#ethanfurman/aenum#12): + - tempdir_missing.patch + - skip_failing_testcases.patch + +------------------------------------------------------------------- +Tue Aug 24 11:38:26 UTC 2021 - John Paul Adrian Glaubitz + +- Update to 3.1.0: + * redo EnumConstants + * add `__set_name__` to `constant` + * add new test; make re strings raw + +------------------------------------------------------------------- +Tue Apr 13 04:55:38 UTC 2021 - Steve Kowalik + +- Update to 3.0.0: + * The more esoteric method of creating Enums have been modified or removed + * Member creation has been redone to match Python 3.10's methods. + * enum_property() has been renamed to property() (old name still available, + but deprecated). + * bin() replacement shows negative integers in twos-complement + * call __init_subclass__ after members have been added, and in Pythons < 3.6 + * call __set_name__ in Pythons < 3.6 + * do not convert/disallow private names + * add iteration/len support to NamedConstant + * add support to Constant to retrieve members by value + * add pickle/deepcopy support to Constant + * add support for Constant to use other Constant values + * AutoNumber and auto() now work together +- Update URL now that bitbucket is dead. + +------------------------------------------------------------------- +Wed Dec 11 11:56:29 UTC 2019 - Tomáš Chvátal + +- Update to 2.2.3: + * Various minor fixes + +------------------------------------------------------------------- +Mon Jul 29 14:51:06 UTC 2019 - pgajdos@suse.com + +- version update to 2.2.1 + 2.2.1 + ===== + . allow Enums to be called without a value + . allow Enum name use while constructing Enum (Python 3.4+ only) + 2.2.0 + ===== + BREAKING CHANGE + --------------- + . In Python 3+ classes defined inside an Enum no longer become members by + default; in Python 2 they still become members, but see below. + For cross-compatibility and full control two decorators are provided: + - @member --> forces item to become a member + - @nonmember --> excludes item from becoming a member + dark = 3 + 2.1.4 + ===== + EnumMeta: + - change __member_new__ to __new_member__ (as the stdlib enum does) + - assign member name to enum() instances (an Enum helper for defining members) + - handle empty iterables when using functional API + - make auto() work with previous enum members + - keep searching mixins until base class is found + Enum: + - fix bug in Flag checks (ensure it is a Flag before checking the name) + - add multiple mixin support + - do not allow blank names (functional API) + - raise TypeError if _missing_* returns wrong type + - fix __format__ to honor custom __str__ + extend_enum: + - support stdlib Enums + - use _generate_next_value_ if value not provided + general: + - standardize exception formatting + - use getfullargspec() in Python 3 (avoids deprecation warnings) + +------------------------------------------------------------------- +Tue Dec 4 12:45:29 UTC 2018 - Matej Cepl + +- Remove superfluous devel dependency for noarch package + +------------------------------------------------------------------- +Wed May 23 19:09:16 UTC 2018 - toddrme2178@gmail.com + +- Update to version 2.1.0 + * support Flags being combined with other data types: + * add _create_pseudo_member_values_ + * add default __new__ and temporary _init_ + +------------------------------------------------------------------- +Thu Nov 16 17:44:07 UTC 2017 - toddrme2178@gmail.com + +- Initial version diff --git a/python-aenum.spec b/python-aenum.spec new file mode 100644 index 0000000..83d09b4 --- /dev/null +++ b/python-aenum.spec @@ -0,0 +1,88 @@ +# +# spec file for package python-aenum +# +# Copyright (c) 2025 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%{?sle15_python_module_pythons} +Name: python-aenum +Version: 3.1.15 +Release: 0 +Summary: Advanced Enumerations, NamedTuples, and NamedConstants +License: BSD-3-Clause +URL: https://github.com/ethanfurman/aenum +Source: https://github.com/ethanfurman/aenum/archive/refs/tags/%{version}.tar.gz#/aenum-%{version}.tar.gz +# PATCH-FIX-UPSTREAM tempdir_missing.patch gh#ethanfurman/aenum#12 mcepl@suse.com +# Make test file into a proper one. +Patch0: tempdir_missing.patch +# PATCH-FIX-UPSTREAM skip_failing_testcases.patch gh#ethanfurman/aenum#12 mcepl@suse.com +# Skip failing tests +Patch1: skip_failing_testcases.patch +# PATCH-FIX-UPSTREAM fix-python312-tests.patch gh#ethanfurman/aenum#36 +Patch2: fix-python312-tests.patch +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes +BuildRequires: python-rpm-macros +BuildArch: noarch + +%python_subpackages + +%description +Advanced Enumerations (compatible with Python's stdlib Enum), +NamedTuples, and NamedConstants + +AEnum includes a Python stdlib Enum-compatible data type, as well as +a metaclass-based NamedTuple implementation and a NamedConstant +class. + +An Enum is a set of symbolic names (members) bound to unique, +constant values. Within an enumeration, the members can be compared +by identity, and the enumeration itself can be iterated over. If +using Python 3 there is built-in support for unique values, multiple +values, auto-numbering, and suspension of aliasing (members with the +same value are not identical), plus the ability to have values +automatically bound to attributes. + +A NamedTuple is a class-based, fixed-length tuple with a name for +each possible position accessible using attribute-access notation as +well as the standard index notation. + +A NamedConstant is a class whose members cannot be rebound; it lacks +all other Enum capabilities, however; consequently, it can have +duplicate values. + +%prep +%autosetup -p1 -n aenum-%{version} + +%build +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +export LANG=en_US.UTF-8 +%pyunittest -v aenum.test + +%files %{python_files} +%doc README.md aenum/CHANGES aenum/doc/* +%license aenum/LICENSE +%{python_sitelib}/aenum +%{python_sitelib}/aenum-%{version}.dist-info + +%changelog diff --git a/skip_failing_testcases.patch b/skip_failing_testcases.patch new file mode 100644 index 0000000..7e168be --- /dev/null +++ b/skip_failing_testcases.patch @@ -0,0 +1,24 @@ +--- + aenum/test.py | 2 ++ + 1 file changed, 2 insertions(+) + +Index: aenum-3.1.15/aenum/test_v3.py +=================================================================== +--- aenum-3.1.15.orig/aenum/test_v3.py ++++ aenum-3.1.15/aenum/test_v3.py +@@ -65,6 +65,7 @@ class TestEnumV3(TestCase): + self.Holiday = Holiday + + @unittest.skipUnless(StdlibEnumMeta, 'Stdlib enum not available') ++ @unittest.skip('Failing test') + def test_stdlib_inheritence(self): + # 3.4 + self.assertTrue(issubclass(self.Season, StdlibEnum)) +@@ -1885,6 +1886,7 @@ class TestExtendEnumV3(TestCase): + self.assertTrue(issubclass(Color, StdlibFlag)) + + @unittest.skipUnless(StdlibFlag and pyver < PY3_11, 'Stdlib Flag not available') ++ @unittest.skip('Failing test') + def test_extend_flag_backwards_stdlib(self): + class Color(StdlibFlag): + BLACK = 0 diff --git a/tempdir_missing.patch b/tempdir_missing.patch new file mode 100644 index 0000000..409b517 --- /dev/null +++ b/tempdir_missing.patch @@ -0,0 +1,86 @@ +--- + aenum/test.py | 32 ++++++++++++++++---------------- + 1 file changed, 16 insertions(+), 16 deletions(-) + +Index: aenum-3.1.11/aenum/test.py +=================================================================== +--- aenum-3.1.11.orig/aenum/test.py ++++ aenum-3.1.11/aenum/test.py +@@ -51,13 +51,18 @@ def load_tests(loader, tests, ignore): + return tests + + class TestCase(unittest.TestCase): +- + def __init__(self, *args, **kwds): + regex = getattr(self, 'assertRaisesRegex', None) + if regex is None: + self.assertRaisesRegex = getattr(self, 'assertRaisesRegexp') + super(TestCase, self).__init__(*args, **kwds) + ++ def setUp(self): ++ self.tempdir = tempfile.mkdtemp() ++ if pyver >= (3, ): ++ test_v3.tempdir = self.tempdir ++ # self.addCleanup(shutil.rmtree, self.tempdir, True) ++ + + # for pickle tests + try: +@@ -940,6 +945,8 @@ class TestEnum(TestCase): + IDES_OF_MARCH = 2013, 3, 15 + self.Holiday = Holiday + ++ super(TestEnum, self).setUp() ++ + def test_set_name(self): + class Descriptor(object): + name = None +@@ -2081,7 +2088,7 @@ class TestEnum(TestCase): + # for use with both Python 2/3 + JSONEnum = JSONEnumMeta('JsonEnum', (Enum, ), {}) + +- test_file = os.path.join(tempdir, 'test_json.json') ++ test_file = os.path.join(self.tempdir, 'test_json.json') + with open(test_file, 'w') as f: + f.write( + '[{"name":"Afghanistan","alpha-2":"AF","country-code":"004","notes":{"description":"pretty"}},' +@@ -4040,6 +4047,8 @@ class TestFlag(TestCase): + CE = 1<<19 + self.Open = Open + ++ super(TestFlag, self).setUp() ++ + def test_set_name(self): + class Descriptor(object): + name = None +@@ -4338,7 +4347,7 @@ class TestFlag(TestCase): + self.assertEqual(AS.STREET._value_, 32) + self.assertEqual(AS.SECONDARY_TYPE._value_, 128) + self.assertEqual((AS.NAME | AS.STREET)._value_, 48, "%r is not 48" % (AS.NAME | AS.STREET)) +- ++ + def test_iteration(self): + C = self.Color + self.assertEqual(list(C), [C.RED, C.GREEN, C.BLUE]) +@@ -5025,6 +5034,8 @@ class TestIntFlag(TestCase): + self.Color = Color + self.Open = Open + ++ super(TestIntFlag, self).setUp() ++ + def test_set_name(self): + class Descriptor(object): + name = None +@@ -6197,10 +6208,10 @@ class TestStackoverflowAnswers(TestCase) + fh.write('#define %s %r\n' % (enum.name, enum.value)) + class Arduino(CHeader): + _order_ = 'ONE TWO' +- __header = os.path.join(tempdir, 'arduino.h') ++ __header = os.path.join(self.tempdir, 'arduino.h') + ONE = 1 + TWO = 2 +- with open(os.path.join(tempdir, 'arduino.h')) as fh: ++ with open(os.path.join(self.tempdir, 'arduino.h')) as fh: + data = fh.read() + self.assertEqual(textwrap.dedent("""\ + initial header stuff here