diff --git a/docs/contributing.rst b/docs/contributing.rst index fdfe516..4b6ef13 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -4,31 +4,53 @@ Contributing If you want to contribute to pyastgrep, great! You'll need to: +- Check out the repo using git, ``cd`` into the directory. -Get test suite running:: +- Set up a venv for development. We use `uv `_ and + recommend you do the same. With uv, the setup instructions are:: - pip install -r requirements-test.txt - pytest + uv sync -Run tests against all versions:: + This will use your default Python version. If you want to use a different + Python version, instead of the above do this e.g.:: - pip install tox - tox + uv python install 3.10 + uv venv --python 3.10 + uv sync -Please install `pre-commit `_ in the repo:: +- Activate the venv:: - pre-commit install + source .venv/bin/activate -This will add Git hooks to run linters when committing, which ensures our style -(black) and other things. + (Alternatively, you can add ``uv run`` before most of the commands below) -You can manually run these linters using:: +- Get test suite running:: - pre-commit run --all --all-files + pytest -Run mypy (we only expect it to pass on Python 3.10):: +- Run tests against all versions:: + + tox + +- Please 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. + + You can manually run these linters using:: + + pre-commit run --all --all-files + +- Optionally, run mypy:: + + mypy . + + We only expect it to pass on Python 3.11, which you can check by doing:: + + tox -e mypy - mypy . Bug fixes and other changes can be submitted using pull requests on GitHub. For large changes, it’s worth opening an issue first to discuss the approach. diff --git a/pyproject.toml b/pyproject.toml index 7646e95..31b35d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,59 @@ +[project] +name = "pyastgrep" +description = "A search/query tool for Python abstract syntax trees" +license = {text = "MIT"} +authors = [{name = "Luke Plant"}] +keywords = ["xpath xml ast asts syntax query css grep"] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", +] +urls = {Homepage = "https://github.com/spookylukey/pyastgrep"} +requires-python = ">=3.8" +dependencies = [ + "lxml>=3.3.5", + "elementpath", + "astpretty", + "pathspec", + "cssselect>=1.2", + 'backports.strenum; python_version < "3.11"', +] +dynamic = ["version"] + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[project.scripts] +pyastgrep = "pyastgrep.cli:main" +pyastdump = "pyastgrep.dump:main" + +[build-system] +requires = ["setuptools>=61.2"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +package-dir = {"" = "src"} +include-package-data = false + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + +[tool.setuptools.dynamic] +version = {attr = "pyastgrep.__version__"} + + [tool.black] line-length = 120 # required-version = '22.1.0' # see https://github.com/psf/black/issues/2493 @@ -39,3 +95,12 @@ disallow_incomplete_defs = false module = "tests.*" disallow_untyped_defs = false disallow_incomplete_defs = false + +[tool.uv] +dev-dependencies = [ + "mypy>=1.11.2", + "pre-commit>=3.5.0", + "pytest>=8.3.3", + "tox-uv>=1.13.1", + "tox>=4.21.2", +] diff --git a/release.sh b/release.sh index 0e95176..867682d 100755 --- a/release.sh +++ b/release.sh @@ -4,16 +4,15 @@ pre-commit run --all --all-files || exit 1 pytest || 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 -NAME=$(python setup.py --name) || exit -VERSION=$(python setup.py --version) || exit 1 -twine upload dist/$NAME-$VERSION-py3-none-any.whl dist/$NAME-$VERSION.tar.gz || exit 1 +uv build --sdist --wheel || exit 1 +uv publish || exit 1 + +VERSION=$(uv pip show pyastgrep | grep 'Version: ' | cut -f 2 -d ' ' | tr -d '\n') || exit 1 + git tag $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 902b4d5..0000000 --- a/setup.cfg +++ /dev/null @@ -1,48 +0,0 @@ -[metadata] -name = pyastgrep -version = attr: pyastgrep.__version__ -description = A query tool for Python abstract syntax trees -long_description = file: README.rst -long_description_content_type = text/x-rst -license = MIT -author = Luke Plant -url = https://github.com/spookylukey/pyastgrep -keywords = xpath xml ast asts syntax query css grep -classifiers = - Development Status :: 4 - Beta - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Intended Audience :: Developers - Operating System :: OS Independent - License :: OSI Approved :: MIT License - Natural Language :: English - -[options] -packages = find: -package_dir = =src -python_requires = >=3.8 -install_requires = - lxml>=3.3.5 - elementpath - astpretty - pathspec - cssselect>=1.2 - backports.strenum; python_version < "3.11" - -[options.entry_points] -console_scripts = - pyastgrep = pyastgrep.cli:main - pyastdump = pyastgrep.dump:main - - -[options.packages.find] -where = src - -[flake8] -#ignore = E501,E731,E126,W504,W503,E203 -max-line-length = 120 diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/tox.ini b/tox.ini index 5caacaf..251b4a0 100644 --- a/tox.ini +++ b/tox.ini @@ -3,14 +3,12 @@ envlist = py38, py39, py310, py311, py312, mypy [testenv] - commands = pytest -deps = - -r requirements-test.txt - -e . - +allowlist_externals = ["pytest"] +deps = -e . + pytest [testenv:mypy] -commands = mypy --exclude=build . +commands = mypy --exclude=build --exclude=dist . basepython = python3.11