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 4ea7760..fe12c75 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,29 +15,25 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "pypy-3.7"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.9"] env: 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: @@ -47,35 +43,17 @@ jobs: linters: 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 3.10 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 - run: | - python -m pip install --upgrade pip - pip install -r tests/requirements-linters.txt - - name: Run isort - run: | - isort --version - isort -c . - - name: Run flake8 - if: failure() || success() + python-version: "3.10" + cache: 'packages' + + - name: Install dependencies run: | - flake8 --version - flake8 - - name: Run check-manifest - if: failure() || success() + uv sync + - name: Run pre-commit checks run: | - check-manifest - - 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/.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/.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 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/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/pyproject.toml b/pyproject.toml index a5bfe50..ee46168 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,76 @@ +[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", + "pre-commit-uv>=4.1.4", +] + +[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 81907d5..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.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 -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 58f5f14..ff23963 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,19 @@ [tox] -envlist = py37,py38,py39,py310,py311,pypy37,check-manifest,isort-check,flake8-check +envlist = py39,py310,py311,py312,py313,pypy39,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