qiskit/Makefile

77 lines
2.1 KiB
Makefile
Raw Normal View History

# This code is part of Qiskit.
2017-05-12 00:12:57 +08:00
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
OS := $(shell uname -s)
ifeq ($(OS), Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS), Darwin)
NPROCS := 2
else
NPROCS := 0
endif # $(OS)
ifeq ($(NPROCS), 2)
CONCURRENCY := 2
else ifeq ($(NPROCS), 1)
CONCURRENCY := 1
else ifeq ($(NPROCS), 3)
CONCURRENCY := 3
else ifeq ($(NPROCS), 0)
CONCURRENCY := 0
else
CONCURRENCY := $(shell echo "$(NPROCS) 2" | awk '{printf "%.0f", $$1 / $$2}')
endif
.PHONY: env lint test test_record test_mock test_ci
2017-05-08 21:25:14 +08:00
# Dependencies need to be installed on the Anaconda virtual environment.
2017-05-08 21:25:14 +08:00
env:
if test $(findstring qiskitenv, $(shell conda info --envs | tr '[:upper:]' '[:lower:]')); then \
bash -c "source activate Qiskitenv;pip install -r requirements.txt"; \
else \
conda create -y -n Qiskitenv python=3; \
bash -c "source activate Qiskitenv;pip install -r requirements.txt"; \
fi;
# Ignoring generated ones with .py extension.
2017-05-08 21:25:14 +08:00
lint:
pylint -j 2 -rn qiskit test
style:
pycodestyle --max-line-length=100 qiskit test
2017-05-08 21:25:14 +08:00
# Use the -s (starting directory) flag for "unittest discover" is necessary,
# otherwise the QuantumCircuit header will be modified during the discovery.
2017-05-09 04:17:43 +08:00
test:
python3 -m unittest discover -s test -v
test_mock:
env QISKIT_TESTS=mock_online python3 -m unittest discover -s test -v
test_recording:
-rm test/cassettes/*
env QISKIT_TESTS=rec python3 -m unittest discover -s test -v
test_ci:
echo "Detected $(NPROCS) CPUs running with $(CONCURRENCY) workers"
stestr run --concurrency $(CONCURRENCY)
coverage:
coverage3 run --source qiskit -m unittest discover -s test -q
coverage3 report
coverage_erase:
coverage erase
clean: coverage_erase ;