From bb9b1443efd6e3f4e6be0865303f92b4a1c733f9 Mon Sep 17 00:00:00 2001 From: Ali Asadi <10773383+maliasadi@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:56:22 -0400 Subject: [PATCH] Tidy up make (#634) * Tidy up Makefile * Auto update version * Trigger CI * Update Makefile/help --------- Co-authored-by: Dev version update bot --- Makefile | 62 +++++++++++++++++----------- pennylane_lightning/core/_version.py | 2 +- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index eb9f9557e..24148a59a 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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)" @@ -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) @@ -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) @@ -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) @@ -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: @@ -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 @@ -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: diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 25f4c22d2..d51948129 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.36.0-dev4" +__version__ = "0.36.0-dev5"