xref: /openbmc/qemu/python/Makefile (revision 762c280d)
1QEMU_VENV_DIR=.dev-venv
2QEMU_TOX_EXTRA_ARGS ?=
3
4.PHONY: help
5help:
6	@echo "python packaging help:"
7	@echo ""
8	@echo "make check-pipenv:"
9	@echo "    Run tests in pipenv's virtual environment."
10	@echo "    These tests use the oldest dependencies."
11	@echo "    Requires: Python 3.6 and pipenv."
12	@echo "    Hint (Fedora): 'sudo dnf install python3.6 pipenv'"
13	@echo ""
14	@echo "make check-tox:"
15	@echo "    Run tests against multiple python versions."
16	@echo "    These tests use the newest dependencies."
17	@echo "    Requires: Python 3.6 - 3.10, and tox."
18	@echo "    Hint (Fedora): 'sudo dnf install python3-tox python3.10'"
19	@echo "    The variable QEMU_TOX_EXTRA_ARGS can be use to pass extra"
20	@echo "    arguments to tox".
21	@echo ""
22	@echo "make check-dev:"
23	@echo "    Run tests in a venv against your default python3 version."
24	@echo "    These tests use the newest dependencies."
25	@echo "    Requires: Python 3.x"
26	@echo ""
27	@echo "make check:"
28	@echo "    Run tests in your *current environment*."
29	@echo "    Performs no environment setup of any kind."
30	@echo ""
31	@echo "make develop:"
32	@echo "    Install deps needed for for 'make check',"
33	@echo "    and install the qemu package in editable mode."
34	@echo "    (Can be used in or outside of a venv.)"
35	@echo ""
36	@echo "make pipenv"
37	@echo "    Creates pipenv's virtual environment (.venv)"
38	@echo ""
39	@echo "make dev-venv"
40	@echo "    Creates a simple venv for check-dev. ($(QEMU_VENV_DIR))"
41	@echo ""
42	@echo "make clean:"
43	@echo "    Remove package build output."
44	@echo ""
45	@echo "make distclean:"
46	@echo "    remove pipenv/venv files, qemu package forwarder,"
47	@echo "    built distribution files, and everything from 'make clean'."
48	@echo ""
49	@echo -e "Have a nice day ^_^\n"
50
51.PHONY: pipenv
52pipenv: .venv
53.venv: Pipfile.lock
54	@PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --keep-outdated
55	rm -f pyproject.toml
56	@touch .venv
57
58.PHONY: check-pipenv
59check-pipenv: pipenv
60	@pipenv run make check
61
62.PHONY: dev-venv
63dev-venv: $(QEMU_VENV_DIR) $(QEMU_VENV_DIR)/bin/activate
64$(QEMU_VENV_DIR) $(QEMU_VENV_DIR)/bin/activate: setup.cfg
65	@echo "VENV $(QEMU_VENV_DIR)"
66	@python3 -m venv $(QEMU_VENV_DIR)
67	@(							\
68		echo "ACTIVATE $(QEMU_VENV_DIR)";		\
69		. $(QEMU_VENV_DIR)/bin/activate;		\
70		echo "INSTALL qemu[devel] $(QEMU_VENV_DIR)";	\
71		pip install --disable-pip-version-check		\
72			"setuptools<60.0.0" 1>/dev/null;	\
73		make develop 1>/dev/null;			\
74	)
75	@touch $(QEMU_VENV_DIR)
76
77.PHONY: check-dev
78check-dev: dev-venv
79	@(							\
80		echo "ACTIVATE $(QEMU_VENV_DIR)";		\
81		. $(QEMU_VENV_DIR)/bin/activate;		\
82		make check;					\
83	)
84
85.PHONY: develop
86develop:
87	pip3 install --disable-pip-version-check -e .[devel]
88
89.PHONY: check
90check:
91	@avocado --config avocado.cfg run tests/
92
93.PHONY: check-tox
94check-tox:
95	@tox $(QEMU_TOX_EXTRA_ARGS)
96
97.PHONY: check-coverage
98check-coverage:
99	@coverage run -m avocado --config avocado.cfg run tests/*.py
100	@coverage combine
101	@coverage html
102	@coverage report
103
104.PHONY: clean
105clean:
106	python3 setup.py clean --all
107	rm -f pyproject.toml
108
109.PHONY: distclean
110distclean: clean
111	rm -rf qemu.egg-info/ .venv/ .tox/ $(QEMU_VENV_DIR) dist/
112	rm -f .coverage .coverage.*
113	rm -rf htmlcov/
114