Skip to content

Commit

Permalink
Switched project to uv for testing/packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
spookylukey committed Dec 25, 2024
1 parent ab77a96 commit cc8b204
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 77 deletions.
50 changes: 36 additions & 14 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.astral.sh/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 <https://pre-commit.com/>`_ 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 <https://pre-commit.com/>`_ 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.
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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",
]
11 changes: 5 additions & 6 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 0 additions & 48 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

10 changes: 4 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cc8b204

Please sign in to comment.