Skip to content

Commit

Permalink
Tidy up make (#634)
Browse files Browse the repository at this point in the history
* Tidy up Makefile

* Auto update version

* Trigger CI

* Update Makefile/help

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
maliasadi and github-actions[bot] authored Mar 12, 2024
1 parent 958bc36 commit bb9b144
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
62 changes: 37 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
PYTHON3 := $(shell which python3 2>/dev/null)

PYTHON := python3
COVERAGE := --cov=pennylane_lightning --cov-report term-missing --cov-report=html:coverage_html_report
TESTRUNNER := -m pytest tests --tb=short

PL_BACKEND?="$(if $(backend:-=),$(backend),lightning_qubit)"
PL_BACKEND ?= "$(if $(backend:-=),$(backend),lightning_qubit)"

ifdef check
CHECK := --check
Expand All @@ -30,22 +28,19 @@ help:
@echo " docs to generate documents"
@echo " clean to delete all temporary, cache, and build files"
@echo " clean-docs to delete all built documentation"
@echo " test to run the test suite"
@echo " test-cpp [backend=?] to run the C++ test suite (requires CMake)"
@echo " Default: lightning_qubit"
@echo " test-cpp [verbose=1] to run the C++ test suite (requires CMake)"
@echo " use with 'verbose=1' for building with verbose flag"
@echo " test-cpp [target=?] to run a specific C++ test target (requires CMake)."
@echo " coverage-cpp [backend=?] to generate a coverage report for python interface"
@echo " Default: lightning_qubit"
@echo " test-python [device=?] to run the Python test suite"
@echo " Default: lightning.qubit"
@echo " coverage [device=?] to generate a coverage report for python interface"
@echo " Default: lightning.qubit"
@echo " coverage-cpp [backend=?] to generate a coverage report for C++ interface"
@echo " Default: lightning_qubit"
@echo " format [check=1] to apply C++ and Python formatter;"
@echo " use with 'check=1' to check instead of modify (requires black and clang-format)"
@echo " format [version=?] to apply C++ and Python formatter;"
@echo " use with 'version={version}' to check or modify with clang-format-{version} instead of clang-format"
@echo " check-tidy [backend=?] to build PennyLane-Lightning with ENABLE_CLANG_TIDY=ON (requires clang-tidy & CMake)"
@echo " Default: lightning_qubit"
@echo " check-tidy [verbose=1] to build PennyLane-Lightning with ENABLE_CLANG_TIDY=ON (requires clang-tidy & CMake)"
Expand All @@ -55,15 +50,16 @@ help:
@echo " docker-push [target=?] to push a Docker image to the PennyLaneAI Docker Hub repo"
@echo " docker-all to build and push Docker images for all PennyLane-Lightning targets"

.PHONY : clean
.PHONY: clean
clean:
find . -type d -name '__pycache__' -exec rm -r {} \+
rm -rf build Build BuildTests BuildTidy BuildGBench
rm -rf build Build BuildTests BuildTidy
rm -rf build_*
rm -rf .coverage coverage_html_report/
rm -rf pennylane_lightning/*_ops*
rm -rf *.egg-info

.PHONY : test-builtin test-suite test-python test-cpp coverage coverage-cpp
.PHONY: coverage coverage-cpp
coverage:
@echo "Generating coverage report for $(if $(device:-=),$(device),lightning.qubit) device:"
$(PYTHON) $(TESTRUNNER) $(COVERAGE)
Expand All @@ -73,16 +69,19 @@ coverage:
coverage-cpp:
@echo "Generating cpp coverage report in BuildCov/out for $(PL_BACKEND) backend"
rm -rf ./BuildCov
cmake -BBuildCov -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DENABLE_COVERAGE=ON -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
cmake -BBuildCov -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTS=ON \
-DENABLE_COVERAGE=ON \
-DPL_BACKEND=$(PL_BACKEND) \
$(OPTIONS)
cmake --build ./BuildCov
cd ./BuildCov; for file in *runner ; do ./$file; done; \
lcov --directory . -b ../pennylane_lightning/core/src --capture --output-file coverage.info; \
genhtml coverage.info --output-directory out

build:
rm -rf ./Build
cmake -BBuild -G Ninja -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
cmake --build ./Build $(VERBOSE)
.PHONY: test-python test-builtin test-suite test-cpp
test-python: test-builtin test-suite

test-builtin:
PL_DEVICE=$(if $(device:-=),$(device),lightning.qubit) $(PYTHON) -I $(TESTRUNNER)
Expand All @@ -91,11 +90,14 @@ test-suite:
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --skip-ops --shots=20000
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --shots=None --skip-ops

test-python: test-builtin test-suite

test-cpp:
rm -rf ./BuildTests
cmake -BBuildTests -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
cmake -BBuildTests -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTS=ON \
-DENABLE_WARNINGS=ON \
-DPL_BACKEND=$(PL_BACKEND) \
$(OPTIONS)
ifdef target
cmake --build ./BuildTests $(VERBOSE) --target $(target)
./BuildTests/$(target)
Expand All @@ -104,7 +106,7 @@ else
cmake --build ./BuildTests $(VERBOSE) --target test
endif

.PHONY: format format-cpp
.PHONY: format format-cpp format-python
format: format-cpp format-python

format-cpp:
Expand All @@ -117,21 +119,27 @@ format-python:
.PHONY: check-tidy
check-tidy:
rm -rf ./BuildTidy
cmake -BBuildTidy -DENABLE_CLANG_TIDY=ON -DBUILD_TESTS=ON -DENABLE_WARNINGS=ON -DCLANG_TIDY_BINARY=clang-tidy -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
cmake -BBuildTidy -G Ninja \
-DENABLE_CLANG_TIDY=ON \
-DBUILD_TESTS=ON \
-DENABLE_WARNINGS=ON \
-DCLANG_TIDY_BINARY=clang-tidy \
-DPL_BACKEND=$(PL_BACKEND) \
$(OPTIONS)
ifdef target
cmake --build ./BuildTidy $(VERBOSE) --target $(target)
else
cmake --build ./BuildTidy $(VERBOSE)
endif

.PHONY : docs clean-docs
docs:
$(MAKE) -C doc html

.PHONY : clean-docs
clean-docs:
$(MAKE) -C doc clean

.PHONY : docker
.PHONY : docker-build docker-push docker-all
ifdef target
TARGET := $(target)
else
Expand All @@ -140,10 +148,14 @@ endif
ifdef version
VERSION := $(version)
else
VERSION := v0.34.0
VERSION := v0.35.0
endif

docker-build:
docker build -f docker/Dockerfile --tag=pennylaneai/pennylane:$(VERSION)-$(TARGET) --target wheel-$(TARGET) --build-arg='LIGHTNING_VERSION=$(VERSION)' .
docker build -f docker/Dockerfile \
--tag=pennylaneai/pennylane:$(VERSION)-$(TARGET) \
--target wheel-$(TARGET) \
--build-arg='LIGHTNING_VERSION=$(VERSION)' .
docker-push:
docker push pennylaneai/pennylane:$(VERSION)-$(TARGET)
docker-build-all:
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.36.0-dev4"
__version__ = "0.36.0-dev5"

0 comments on commit bb9b144

Please sign in to comment.