diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dca4ea9..1da2396 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,10 +32,16 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install build + pip install flake8 + pip install pytest + + - name: Build package + run: | + python -m build - name: Lint run: | - pip install flake8 # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide @@ -43,8 +49,6 @@ jobs: - name: Test run: | - pip install -e . - pip install pytest pytest --doctest-modules --doctest-glob='*.rst' --junitxml=junit/test-results-${{ matrix.python-version }}.xml - name: Upload pytest test results diff --git a/.gitignore b/.gitignore index a93118a..913309e 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ coverage.xml .hypothesis/ .pytest_cache/ cover/ +junit/ # Translations *.mo diff --git a/HISTORY.md b/HISTORY.md index 4f235f5..b1ccc45 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,13 @@ Nothing yet :) +# 1.0.3 + +- PR #46 Code optimization for unified diff parsing (Thanks, @babenek) +- Package using build module and pyproject.toml +- Support up to 3.11 +- Drop support up to 3.6 + # 1.0.2 - Support up to 3.9 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cd427c0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,35 @@ +[project] +name = "whatthepatch" +version = "1.0.3" +maintainers = [{ name = "Christopher S. Corley", email = "cscorley@gmail.com" }] +requires-python = ">=3.7" +readme = "README.rst" +description = "A patch parsing and application library." +keywords = ["patch", "diff", "parser"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Version Control", + "Topic :: Software Development", + "Topic :: Text Processing", +] + +[project.urls] +"Homepage" = "https://github.com/cscorley/whatthepatch" +"Bug Tracker" = "https://github.com/cscorley/whatthepatch/issues" + +[build-system] +requires = ["setuptools>=65.0.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2a9acf1..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 406c1c4..0000000 --- a/setup.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- - -try: - from setuptools import setup -except ImportError: - from distutils.core import setup - - -with open("README.rst") as f: - readme = f.read() - -setup( - name="whatthepatch", - version="1.0.2", - author="Christopher S. Corley", - author_email="cscorley@gmail.com", - description="A patch parsing and application library.", - long_description=readme, - url="https://github.com/cscorley/whatthepatch", - license="MIT", - packages=["whatthepatch"], - include_package_data=True, - keywords=["patch", "diff", "parser"], - classifiers=[ - "Operating System :: OS Independent", - "License :: OSI Approved :: MIT License", - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "Topic :: Software Development", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: Version Control", - "Topic :: Text Processing", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - ], -) diff --git a/whatthepatch/__init__.py b/src/whatthepatch/__init__.py similarity index 100% rename from whatthepatch/__init__.py rename to src/whatthepatch/__init__.py diff --git a/whatthepatch/apply.py b/src/whatthepatch/apply.py similarity index 97% rename from whatthepatch/apply.py rename to src/whatthepatch/apply.py index 4e05cdd..372548e 100644 --- a/whatthepatch/apply.py +++ b/src/whatthepatch/apply.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import os.path import subprocess import tempfile -import os.path from . import patch -from .exceptions import SubprocessException, HunkApplyException -from .snippets import which, remove +from .exceptions import HunkApplyException, SubprocessException +from .snippets import remove, which def apply_patch(diffs): diff --git a/whatthepatch/exceptions.py b/src/whatthepatch/exceptions.py similarity index 100% rename from whatthepatch/exceptions.py rename to src/whatthepatch/exceptions.py diff --git a/whatthepatch/patch.py b/src/whatthepatch/patch.py similarity index 99% rename from whatthepatch/patch.py rename to src/whatthepatch/patch.py index c928a78..50e0e5c 100644 --- a/whatthepatch/patch.py +++ b/src/whatthepatch/patch.py @@ -3,8 +3,8 @@ import re from collections import namedtuple -from .snippets import split_by_regex, findall_regex from . import exceptions +from .snippets import findall_regex, split_by_regex header = namedtuple( "header", diff --git a/whatthepatch/snippets.py b/src/whatthepatch/snippets.py similarity index 100% rename from whatthepatch/snippets.py rename to src/whatthepatch/snippets.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_apply.py b/tests/test_apply.py index 4a31b7a..ddd7646 100644 --- a/tests/test_apply.py +++ b/tests/test_apply.py @@ -1,17 +1,17 @@ # -*- coding: utf-8 -*- -import whatthepatch as wtp -from whatthepatch import exceptions -from whatthepatch.snippets import which - -import pytest import unittest from unittest.case import SkipTest +import pytest + +from src.whatthepatch import apply_diff, exceptions, parse_patch +from src.whatthepatch.snippets import which + def _apply(src, diff_text, reverse=False, use_patch=False): - diff = next(wtp.parse_patch(diff_text)) - return wtp.apply.apply_diff(diff, src, reverse, use_patch) + diff = next(parse_patch(diff_text)) + return apply_diff(diff, src, reverse, use_patch) def _apply_r(src, diff_text, reverse=True, use_patch=False): diff --git a/tests/test_patch.py b/tests/test_patch.py index 49e72fc..dff1304 100644 --- a/tests/test_patch.py +++ b/tests/test_patch.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -import whatthepatch as wtp -from whatthepatch.patch import Change, diffobj, header as headerobj - - +import os import time import unittest -import os + +from src import whatthepatch as wtp +from src.whatthepatch.patch import Change, diffobj +from src.whatthepatch.patch import header as headerobj module_path = os.path.dirname(__file__)