From f11b1eaf9cccbfeb2a0f441ca8a363f2e60b743c Mon Sep 17 00:00:00 2001 From: "Henrique B." Date: Sat, 15 Jun 2024 09:37:19 -0300 Subject: [PATCH 1/3] Drop support for older Python versions --- .gitignore | 6 ++++++ .travis.yml | 6 ++++-- enzyme/compat.py | 13 ------------- enzyme/parsers/ebml/readers.py | 1 - setup.py | 13 ++++++++----- tox.ini | 6 ++++++ 6 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 enzyme/compat.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 24b6329..2ca3a38 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,9 @@ lib lib64 __pycache__ +# Tests +.tox/ + # Installer logs pip-log.txt @@ -24,6 +27,9 @@ pip-log.txt .pydevproject .settings +# Visual Studio Code +.vscode/ + # Sphinx docs/_build diff --git a/.travis.yml b/.travis.yml index d661ae1..7e82f64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,9 @@ language: python python: - - 2.7 - - 3.3 + - 3.8 + - 3.9 + - 3.10 + - 3.11 script: python setup.py test notifications: irc: "irc.freenode.org#enzyme" diff --git a/enzyme/compat.py b/enzyme/compat.py deleted file mode 100644 index 81e3a4c..0000000 --- a/enzyme/compat.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -import sys - - -_ver = sys.version_info -is_py3 = _ver[0] == 3 -is_py2 = _ver[0] == 2 - - -if is_py2: - bytes = lambda x: chr(x[0]) # @ReservedAssignment -elif is_py3: - bytes = bytes # @ReservedAssignment diff --git a/enzyme/parsers/ebml/readers.py b/enzyme/parsers/ebml/readers.py index 3c9709b..7429c2e 100644 --- a/enzyme/parsers/ebml/readers.py +++ b/enzyme/parsers/ebml/readers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from ...compat import bytes from ...exceptions import ReadError, SizeError from datetime import datetime, timedelta from io import BytesIO diff --git a/setup.py b/setup.py index 12a8ff3..4082ce0 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from setuptools import setup, find_packages +tests_requirements = ['requests', 'PyYAML'] setup(name='enzyme', version='0.4.2-dev', @@ -18,12 +19,14 @@ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Topic :: Multimedia :: Video', 'Topic :: Software Development :: Libraries :: Python Modules'], + python_requires="<3.12,>=3.8", test_suite='enzyme.tests.suite', - tests_require=['requests', 'PyYAML']) + tests_require=tests_requirements, + extras_require={'test': tests_requirements}) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..036dfa9 --- /dev/null +++ b/tox.ini @@ -0,0 +1,6 @@ +[tox] +envlist = py{38,39,310,311} + +[testenv] +extras = test +commands = python -m unittest From 9a740f683955b8f8b5bcbfa5dc7fa2bc7dc8bbdf Mon Sep 17 00:00:00 2001 From: "Henrique B." Date: Sun, 16 Jun 2024 10:45:26 -0300 Subject: [PATCH 2/3] Migrate setup.py to pyproject.toml --- .travis.yml | 2 +- MANIFEST.in | 9 ++++++++- enzyme/__init__.py | 2 +- pyproject.toml | 39 +++++++++++++++++++++++++++++++++++++++ setup.cfg | 7 ------- setup.py | 32 -------------------------------- 6 files changed, 49 insertions(+), 42 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.travis.yml b/.travis.yml index 7e82f64..af28882 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,6 @@ python: - 3.9 - 3.10 - 3.11 -script: python setup.py test +script: python -m unittest notifications: irc: "irc.freenode.org#enzyme" diff --git a/MANIFEST.in b/MANIFEST.in index 0a4d8b0..6ca7fbe 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,8 @@ -include LICENSE HISTORY.rst enzyme/parsers/ebml/specs/matroska.xml enzyme/tests/parsers/ebml/test1.mkv.yml +include LICENSE +include HISTORY.rst +include tox.ini +include enzyme/parsers/ebml/specs/matroska.xml +include enzyme/tests/parsers/ebml/test1.mkv.yml + +graft docs + diff --git a/enzyme/__init__.py b/enzyme/__init__.py index 9a171b5..134efbe 100644 --- a/enzyme/__init__.py +++ b/enzyme/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- __title__ = 'enzyme' -__version__ = '0.4.2' +__version__ = '0.4.2-dev' __author__ = 'Antoine Bertin' __license__ = 'Apache 2.0' __copyright__ = 'Copyright 2013 Antoine Bertin' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b4aec08 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,39 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "enzyme" +description = "Python video metadata parser" +requires-python = ">=3.8,<3.12" +license = { file = "LICENSE" } +keywords = ["parser", "video", "metadata", "mkv"] +authors = [{ name = "Antoine Bertin", email = "diaoulael@gmail.com" }] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Multimedia :: Video", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dynamic = ["version", "readme"] + +[project.optional-dependencies] +docs = ["sphinx"] +test = ["PyYAML", "requests"] +dev = ["tox"] + +[project.urls] +homepage = "https://github.com/Diaoul/enzyme" +repository = "https://github.com/Diaoul/enzyme" +documentation = "https://enzyme.readthedocs.io" + +[tool.setuptools.dynamic] +version = { attr = "enzyme.__version__" } +readme = { file = ["README.rst", "HISTORY.rst"] } diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7389055..0000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[build_sphinx] -source-dir = docs/ -build-dir = docs/_build -all_files = 1 - -[upload_sphinx] -upload-dir = docs/_build/html diff --git a/setup.py b/setup.py deleted file mode 100644 index 4082ce0..0000000 --- a/setup.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from setuptools import setup, find_packages - -tests_requirements = ['requests', 'PyYAML'] - -setup(name='enzyme', - version='0.4.2-dev', - license='Apache 2.0', - description='Python video metadata parser', - long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(), - keywords='parser video metadata mkv', - url='https://github.com/Diaoul/enzyme', - author='Antoine Bertin', - author_email='diaoulael@gmail.com', - packages=find_packages(), - package_data={'enzyme.parsers.ebml': ['specs/matroska.xml'], 'enzyme.tests': ['parsers/ebml/test1.mkv.yml']}, - classifiers=['Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Topic :: Multimedia :: Video', - 'Topic :: Software Development :: Libraries :: Python Modules'], - python_requires="<3.12,>=3.8", - test_suite='enzyme.tests.suite', - tests_require=tests_requirements, - extras_require={'test': tests_requirements}) From c48e1b47720467b7ea0a107f82c41948c6486a03 Mon Sep 17 00:00:00 2001 From: "Henrique B." Date: Sun, 16 Jun 2024 11:07:52 -0300 Subject: [PATCH 3/3] Fixes #33 --- .travis.yml | 1 + enzyme/parsers/ebml/core.py | 9 ++++++--- pyproject.toml | 6 +++++- tox.ini | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index af28882..7ca2f4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ python: - 3.9 - 3.10 - 3.11 + - 3.12 script: python -m unittest notifications: irc: "irc.freenode.org#enzyme" diff --git a/enzyme/parsers/ebml/core.py b/enzyme/parsers/ebml/core.py index ae025ac..43300e7 100644 --- a/enzyme/parsers/ebml/core.py +++ b/enzyme/parsers/ebml/core.py @@ -1,10 +1,12 @@ -# -*- coding: utf-8 -*- from ...exceptions import ReadError from .readers import * -from pkg_resources import resource_stream # @UnresolvedImport from xml.dom import minidom import logging +try: + from importlib.resources import files +except ImportError: + from importlib_resources import files # type: ignore[assignment,no-redef,import-not-found] __all__ = ['INTEGER', 'UINTEGER', 'FLOAT', 'STRING', 'UNICODE', 'DATE', 'MASTER', 'BINARY', 'SPEC_TYPES', 'READERS', 'Element', 'MasterElement', 'parse', 'parse_element', @@ -231,7 +233,8 @@ def get_matroska_specs(webm_only=False): """ specs = {} - with resource_stream(__name__, 'specs/matroska.xml') as resource: + spec_file = files(__package__).joinpath('specs', 'matroska.xml') + with spec_file.open('rb') as resource: xmldoc = minidom.parse(resource) for element in xmldoc.getElementsByTagName('element'): if not webm_only or element.hasAttribute('webm') and element.getAttribute('webm') == '1': diff --git a/pyproject.toml b/pyproject.toml index b4aec08..c4d8479 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "enzyme" description = "Python video metadata parser" -requires-python = ">=3.8,<3.12" +requires-python = ">=3.8" license = { file = "LICENSE" } keywords = ["parser", "video", "metadata", "mkv"] authors = [{ name = "Antoine Bertin", email = "diaoulael@gmail.com" }] @@ -19,10 +19,14 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Multimedia :: Video", "Topic :: Software Development :: Libraries :: Python Modules", ] dynamic = ["version", "readme"] +dependencies = [ + "importlib_resources>=4.6; python_version=='3.8'" +] [project.optional-dependencies] docs = ["sphinx"] diff --git a/tox.ini b/tox.ini index 036dfa9..5467c13 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{38,39,310,311} +envlist = py{38,39,310,311,312} [testenv] extras = test