From 13b646dc72ba8a3210616f1cbb6da64a5ec4f786 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 22 Jan 2025 19:54:46 +0000 Subject: [PATCH 1/7] Updated supported Python versions --- .github/workflows/tests.yml | 2 +- setup.cfg | 2 ++ tox.ini | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4ea7760..00156f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "pypy-3.7"] + python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13", "pypy-3.7"] env: PYTHON: ${{ matrix.python-version }} diff --git a/setup.cfg b/setup.cfg index 81907d5..b84de09 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,6 +23,8 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 keywords = parser parsers parsing monad combinators [options] diff --git a/tox.ini b/tox.ini index 58f5f14..d7c0a17 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py37,py38,py39,py310,py311,pypy37,check-manifest,isort-check,flake8-check +envlist = py37,py38,py39,py310,py311,py312,py313,pypy37,check-manifest,isort-check,flake8-check [testenv] deps = -r tests/requirements-tests.txt From 541500f742c56ee40c037aa41ee13486312ea003 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 22 Jan 2025 19:57:23 +0000 Subject: [PATCH 2/7] Dropped support for Pytohn 3.7/3.8 --- .github/workflows/tests.yml | 2 +- docs/history.rst | 4 ++++ setup.cfg | 2 -- tox.ini | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 00156f2..3795f46 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13", "pypy-3.7"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.7"] env: PYTHON: ${{ matrix.python-version }} diff --git a/docs/history.rst b/docs/history.rst index c76447f..41cc515 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -4,6 +4,10 @@ History and release notes .. currentmodule:: parsy +2.2 - unreleased +---------------- +* Dropped support for Python 3.7, 3.8 which are past EOL + 2.1 - 2023-02-22 ---------------- diff --git a/setup.cfg b/setup.cfg index b84de09..7da0718 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,8 +18,6 @@ classifiers = Topic :: Text Processing License :: OSI Approved :: MIT License 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 diff --git a/tox.ini b/tox.ini index d7c0a17..857d236 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py37,py38,py39,py310,py311,py312,py313,pypy37,check-manifest,isort-check,flake8-check +envlist = py39,py310,py311,py312,py313,pypy37,check-manifest,isort-check,flake8-check [testenv] deps = -r tests/requirements-tests.txt From d9d318063fe5c8b7abee3b4fd8796b0a77f3ef61 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 22 Jan 2025 20:30:35 +0000 Subject: [PATCH 3/7] Switched to uv for packaging --- .flake8 | 4 ++ .github/workflows/tests.yml | 4 -- .python-version | 1 + docs/contributing.rst | 47 +++++++++++++++++------ pyproject.toml | 68 +++++++++++++++++++++++++++++++++- release.sh | 9 +++-- setup.cfg | 39 ------------------- setup.py | 3 -- tests/requirements-linters.txt | 1 - tox.ini | 17 ++++----- 10 files changed, 119 insertions(+), 74 deletions(-) create mode 100644 .flake8 create mode 100644 .python-version delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..26bda2a --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +exclude = .tox,.git,docs,dist,build,todo,.venv +ignore = E731,E221,W503,E741,E203 +max-line-length = 119 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3795f46..4aad638 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -71,10 +71,6 @@ jobs: run: | flake8 --version flake8 - - name: Run check-manifest - if: failure() || success() - run: | - check-manifest - uses: psf/black@stable with: version: "22.3.0" diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/docs/contributing.rst b/docs/contributing.rst index 18370a6..57a8689 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -8,20 +8,38 @@ contribute by making a fork, and submitting a PR on `GitHub We have a high standard in terms of quality. All contributions will need to be fully covered by unit tests and documentation. -To run the test suite:: +To get started you’ll need to: + +- Check out the repo using git, ``cd`` into the directory. + +- Set up a venv for development. We use `uv `_ and + recommend you do the same. With uv, the setup instructions are:: + + uv sync + + This will use your default Python version. If you want to use a different + Python version, instead of the above do this e.g.:: + + uv python install 3.10 + uv venv --python 3.10 + uv sync + +- Activate the venv:: + + source .venv/bin/activate + + (Alternatively, you can add ``uv run`` before most of the commands below) + +- Get test suite running:: - pip install pytest pytest -To run the test suite on all supported Python versions, and code quality checks, -first install the various Python versions, then:: +- Run tests against all versions:: - pip install tox tox -To build the docs, do:: +- To build the docs, do:: - pip install sphinx cd docs make html @@ -31,12 +49,19 @@ including `flake8 `_, `isort `_. These are most easily add by using `pre-commit `_: -* Install pre-commit globally e.g. ``pipx install pre-commit`` if you already - have `pipx `_. +- Install `pre-commit `_ in the repo:: + + pre-commit install + + This will add Git hooks to run linters when committing, which ensures our style + (black) and other things. + + Now all the linters will run when you commit changes. + +- You can also manually run these linters using:: -* Do ``pre-commit install`` in the repo. + pre-commit run --all --all-files -Now all the linters will run when you commit changes. When writing documentation, please keep in mind Daniele Procida's `great article on documentation `_. To summarise, diff --git a/pyproject.toml b/pyproject.toml index a5bfe50..328cec1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,75 @@ +[project] +name = "parsy" +description = "Easy-to-use parser combinators, for parsing in pure Python" +license = {text = "MIT"} +authors = [ + { name = "Jeanine Adkisson", email = "jneen@jneen.net" } +] +maintainers = [ + { name = "Luke Plant", email = "luke@lukeplant.me.uk" } +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Compilers", + "Topic :: Software Development :: Interpreters", + "Topic :: Text Processing", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = ["parser", "parsers", "parsing", "monad", "combinators"] +urls = {Homepage = "https://github.com/python-parsy/parsy"} + +requires-python = ">=3.9" +dependencies = [] + +dynamic = ["version"] + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[tool.setuptools.dynamic] +version = {attr = "parsy.__version__"} + +[build-system] +requires = ["setuptools>=61.2"] +build-backend = "setuptools.build_meta" + +[dependency-groups] +dev = [ + "pre-commit>=4.1.0", + "pytest>=8.3.4", + "tox-uv>=1.20.1", + "tox>=4.24.1", + "pytest-cov>=6.0.0", +] + +[tool.setuptools] +package-dir = {"" = "src"} +include-package-data = false + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + [tool.black] line-length = 119 -# required-version = '22.1.0' # see https://github.com/psf/black/issues/2493 target-version = ['py310'] [tool.isort] line_length = 119 profile = "black" default_section = "THIRDPARTY" -skip = [".tox", ".git", "docs", "dist", "build" , "todo"] +skip = [".tox", ".git", "docs", "dist", "build" , "todo", ".venv"] known_first_party = "parsy" + +[tool.flake8] +exclude = [".tox", ".git", "docs", "dist", "build", "todo"] +ignore = ["E731", "E221", "W503", "E741", "E203" ] +max-line-length = 119 diff --git a/release.sh b/release.sh index 7cb7440..49d7d0d 100755 --- a/release.sh +++ b/release.sh @@ -6,11 +6,12 @@ pre-commit run --all --all-files || exit 1 umask 000 rm -rf build dist git ls-tree --full-tree --name-only -r HEAD | xargs chmod ugo+r -python setup.py sdist || exit 1 -python setup.py bdist_wheel || exit 1 -VERSION=$(python setup.py --version) || exit 1 -twine upload dist/parsy-$VERSION-py3-none-any.whl dist/parsy-$VERSION.tar.gz || exit 1 +uv build --sdist --wheel || exit 1 +uv publish || exit 1 + +VERSION=$(uv pip show parsy | grep 'Version: ' | cut -f 2 -d ' ' | tr -d '\n') || exit 1 + git tag v$VERSION || exit 1 git push || exit 1 git push --tags || exit 1 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7da0718..0000000 --- a/setup.cfg +++ /dev/null @@ -1,39 +0,0 @@ -[metadata] -name = parsy -version = attr: parsy.__version__ -description = Easy-to-use parser combinators, for parsing in pure Python -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Jeanine Adkisson -author_email = jneen@jneen.net -maintainer = Luke Plant -maintainer_email = L.Plant.98@cantab.net -url = https://github.com/python-parsy/parsy -license = MIT -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Topic :: Software Development :: Compilers - Topic :: Software Development :: Interpreters - Topic :: Text Processing - License :: OSI Approved :: MIT License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3.13 -keywords = parser parsers parsing monad combinators - -[options] -python_requires = >=3.7 -packages = find: -package_dir = =src - -[options.packages.find] -where = src - -[flake8] -exclude = .tox,.git,docs,dist,build,todo -ignore = E731,E221,W503,E741,E203 -max-line-length = 119 diff --git a/setup.py b/setup.py deleted file mode 100755 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/tests/requirements-linters.txt b/tests/requirements-linters.txt index 59a333a..585afca 100644 --- a/tests/requirements-linters.txt +++ b/tests/requirements-linters.txt @@ -1,3 +1,2 @@ isort==5.4.2 flake8==3.8.3 -check-manifest diff --git a/tox.ini b/tox.ini index 857d236..878faa2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,19 @@ [tox] -envlist = py39,py310,py311,py312,py313,pypy37,check-manifest,isort-check,flake8-check +envlist = py39,py310,py311,py312,py313,pypy37,isort-check,flake8-check [testenv] -deps = -r tests/requirements-tests.txt commands = pytest - -[testenv:check-manifest] -basepython = python3.9 -deps = -r tests/requirements-check-manifest.txt -commands = check-manifest +allowlist_externals = ["pytest"] +deps = -e . + pytest [testenv:isort-check] -# isort configurations are located in setup.cfg +# isort configurations are located in pyproject.toml basepython = python3.9 -deps = -r tests/requirements-isort.txt +deps = -r tests/requirements-linters.txt commands = isort -c {toxinidir} [testenv:flake8-check] basepython = python3.9 -deps = -r tests/requirements-flake8.txt +deps = -r tests/requirements-linters.txt commands = flake8 From 4ca5d52b5ce6377a9fdf179e8a6e1581ac165c65 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 22 Jan 2025 20:32:16 +0000 Subject: [PATCH 4/7] Test PyPy 3.9 instead of 3.7 --- .github/workflows/tests.yml | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4aad638..72ceab6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.7"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.9"] env: PYTHON: ${{ matrix.python-version }} diff --git a/tox.ini b/tox.ini index 878faa2..ff23963 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py39,py310,py311,py312,py313,pypy37,isort-check,flake8-check +envlist = py39,py310,py311,py312,py313,pypy39,isort-check,flake8-check [testenv] commands = pytest From 87efc806918a0246dde8a8dbba83819ce8ea65b3 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 22 Jan 2025 20:53:31 +0000 Subject: [PATCH 5/7] Fix workflows for uv packaging --- .github/workflows/tests.yml | 50 +++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 72ceab6..9598491 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,23 +21,19 @@ jobs: PYTHON: ${{ matrix.python-version }} steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} with uv + uses: drivendataorg/setup-python-uv-action@v1.0.0 with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('tests/requirements-tests.txt') }} - - name: Install deps + cache: 'packages' + + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r tests/requirements-tests.txt - python setup.py develop --no-deps + uv sync - name: Run tests run: | - pytest --cov=./ --cov-report=xml + uv run pytest --cov=./ --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: @@ -49,28 +45,28 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.9" - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} with uv + uses: drivendataorg/setup-python-uv-action@v1.0.0 with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements-linters.txt') }} - - name: Install deps + python-version: ${{ matrix.python-version }} + cache: 'packages' + + - name: Install dependencies + run: | + uv sync + - name: Install linter deps run: | - python -m pip install --upgrade pip - pip install -r tests/requirements-linters.txt + uv pip install -r tests/requirements-linters.txt - name: Run isort run: | - isort --version - isort -c . + uv run isort --version + uv run isort -c . - name: Run flake8 if: failure() || success() run: | - flake8 --version - flake8 + uv run flake8 --version + uv run flake8 - uses: psf/black@stable with: version: "22.3.0" From 72322da84c21ec6e1a17f81857b260b18d98fea0 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 22 Jan 2025 20:58:16 +0000 Subject: [PATCH 6/7] Fix RTD conf --- .readthedocs.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 320701f..d94cb3b 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,11 +1,15 @@ version: 2 build: - image: latest + os: "ubuntu-22.04" + tools: + python: "3.11" python: - version: 3.8 install: - requirements: docs/requirements.txt - - method: setuptools + - method: pip path: . + +sphinx: + configuration: docs/conf.py From d532c847f0269cf2fd6304e2ee0052fa22ff2347 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 22 Jan 2025 21:01:45 +0000 Subject: [PATCH 7/7] Switch linters CI to use pre-commit command line Using pre-commit-uv for fast installation --- .github/workflows/tests.yml | 22 ++++------------------ .pre-commit-config.yaml | 15 +++++++-------- pyproject.toml | 1 + 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9598491..fe12c75 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,31 +43,17 @@ jobs: linters: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} with uv + - name: Set up Python 3.10 with uv uses: drivendataorg/setup-python-uv-action@v1.0.0 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" cache: 'packages' - name: Install dependencies run: | uv sync - - name: Install linter deps + - name: Run pre-commit checks run: | - uv pip install -r tests/requirements-linters.txt - - name: Run isort - run: | - uv run isort --version - uv run isort -c . - - name: Run flake8 - if: failure() || success() - run: | - uv run flake8 --version - uv run flake8 - - uses: psf/black@stable - with: - version: "22.3.0" - if: failure() || success() + uv run pre-commit run --all --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 99bfc08..1a2e2d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,37 +8,36 @@ repos: rev: 3.8.4 hooks: - id: flake8 - language_version: python3.9 + language_version: python3.10 - repo: https://github.com/pre-commit/mirrors-isort rev: v5.6.4 hooks: - id: isort - language_version: python3.9 + language_version: python3.10 - repo: https://github.com/ikamensh/flynt/ rev: '0.69' hooks: - id: flynt - language_version: python3.9 + language_version: python3.10 - repo: https://github.com/asottile/pyupgrade rev: v2.26.0 hooks: - id: pyupgrade entry: pyupgrade --py3-plus --py36-plus --py37-plus --keep-runtime-typing - language_version: python3.9 + language_version: python3.10 - repo: https://github.com/myint/autoflake rev: 'v1.4' hooks: - id: autoflake args: ['--remove-all-unused-imports', '-i'] - language_version: python3.9 + language_version: python3.10 - repo: https://github.com/pre-commit/mirrors-autopep8 rev: 'v1.5.7' hooks: - id: autopep8 - language_version: python3.9 + language_version: python3.10 - repo: https://github.com/psf/black rev: 22.3.0 hooks: - id: black - language_version: python3 - language_version: python3.9 + language_version: python3.10 diff --git a/pyproject.toml b/pyproject.toml index 328cec1..ee46168 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ dev = [ "tox-uv>=1.20.1", "tox>=4.24.1", "pytest-cov>=6.0.0", + "pre-commit-uv>=4.1.4", ] [tool.setuptools]