Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: use ruff linting/formatting #178

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
- uses: astral-sh/ruff-action@v3
with:
args: "check --exclude ./test/generator/"
- uses: haskell-actions/setup@v2
with:
ghc-version: '9.6'
cabal-version: latest
- run: sudo apt install x11-apps libxcb1-dev libxcb-render0-dev
- run: git clone https://gitlab.freedesktop.org/xorg/proto/xcbproto.git proto && cd proto && git checkout ${{ matrix.xcbver }}
- run: make -j XCBDIR=./proto/src check
- run: make XCBDIR=./proto/src check
23 changes: 7 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
AUTOPEP8=autopep8 --in-place --aggressive --aggressive

XCBDIR?=$(shell pkg-config --variable=xcbincludedir xcb-proto)
ifneq ($(XCBDIR),$(shell pkg-config --variable=xcbincludedir xcb-proto))
XCBVER=$(shell sed -e '1,/AC_INIT/d' $(XCBDIR)/../configure.ac | head -n 1 | tr -d ,[:blank:])
else
XCBVER=$(shell pkg-config --modversion xcb-proto)
endif
NCPUS=$(shell nproc)
PARALLEL=$(shell which parallel)
CABAL=flock xcffib.cabal cabal
GEN=$(CABAL) new-run --minimize-conflict-set -j$(NCPUS) exe:xcffibgen --
VENV=xcffib_venv
PYTHON=$(VENV)/bin/python3
FLAKE=$(VENV)/bin/flake8

GENERATOR_FILES=$(shell find . -path ./test -prune -false -o -name \*.hs)
HANDWRITTEN_MODULE_FILES=$(shell find ./module -name \*.py)

GENERATED_TESTS_DIR=./test/generator/

# you should have xcb-proto installed to run this
xcffib: xcffib.cabal $(GENERATOR_FILES) $(HANDWRITTEN_MODULE_FILES)
$(GEN) --input $(XCBDIR) --output ./xcffib
ruff format ./xcffib
cp ./module/*py ./xcffib/
touch ./xcffib/py.typed
sed -i "s/__xcb_proto_version__ = .*/__xcb_proto_version__ = \"${XCBVER}\"/" xcffib/__init__.py

.PHONY: xcffib-fmt
xcffib-fmt: module/*.py
ifeq (${PARALLEL},)
$(AUTOPEP8) ./xcffib/*.py
else
find ./xcffib/*.py | parallel -j $(NCPUS) $(AUTOPEP8) '{}'
endif

dist-newstyle:
$(CABAL) new-configure --enable-tests

Expand All @@ -52,13 +43,15 @@ valgrind: xcffib
valgrind --leak-check=full --show-leak-kinds=definite $(PYTHON) -m pytest -v

newtests:
$(GEN) --input ./test/generator/ --output ./test/generator/
$(GEN) --input $(GENERATED_TESTS_DIR) --output $(GENERATED_TESTS_DIR)
git diff test

# These are all split out so make -j3 check goes as fast as possible.
.PHONY: lint
lint: $(VENV)
$(FLAKE) --config=./test/flake8.cfg ./module
ruff check --exclude $(GENERATED_TESTS_DIR) --exclude ./proto
$(CABAL) check
$(PYTHON) -m compileall xcffib

.PHONY: htests
htests:
Expand All @@ -74,8 +67,6 @@ check-mode-%: xcffib requirements.txt
./test/test_mode.sh $*

check: xcffib htests lint check-mode-api check-mode-abi
$(CABAL) check
$(PYTHON) -m compileall xcffib

# make release ver=0.99.99
release: xcffib
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# xcffib [![Build Status](https://github.com/tych0/xcffib/workflows/ci/badge.svg)](https://github.com/tych0/xcffib/actions)
# xcffib [![Build Status](https://github.com/tych0/xcffib/workflows/ci/badge.svg?branch=master)](https://github.com/tych0/xcffib/actions)

`xcffib` is the XCB binding for Python.

Expand Down
Loading