<commit_before>INSTALL	:= install
DESTDIR	:= /
PREFIX	:= /usr
PACKAGE := duo_openvpn_mozilla
VERSION := 1.1.0
.DEFAULT: test
.PHONY: test coverage coveragereport pyinstall pep8 pylint pythonrpm pluginrpm rpm deb pypi install clean
TEST_FLAGS_FOR_SUITE := -m unittest discover -v -f -s test

# Testing is deliberately verbose because we will skip tests based on the
# capabilities of the user being tested's device
test:
	# If you are seeing a lot of skips, consider editing the deep_testing flags in your conf file.
	python -B $(TEST_FLAGS_FOR_SUITE)

coverage:
	coverage run $(TEST_FLAGS_FOR_SUITE)
	@rm -f $(PACKAGE)/*.pyc test/*.pyc

coveragereport:
	coverage report -m $(PACKAGE)/*.py test/*.py


pyinstall:
	./setup.py install

pep8:
	@find ./* `git submodule --quiet foreach 'echo -n "-path ./$$path -prune -o "'` -type f -name '*.py' -exec pep8 --show-source --max-line-length=100 {} \;

pylint:
	@find ./* `git submodule --quiet foreach 'echo -n "-path ./$$path -prune -o "'` -type f -name '*.py' -exec pylint -r no --disable=locally-disabled --rcfile=/dev/null {} \;

pythonrpm:
	fpm -s python -t rpm --rpm-dist "$$(rpmbuild -E '%{?dist}' | sed -e 's#^\.##')" --iteration 1 setup.py
	@rm -rf build $(PACKAGE).egg-info

# FIXME: summary  description   git?
pluginrpm:
	$(MAKE) DESTDIR=./tmp install
	fpm -s dir -t rpm --rpm-dist "$$(rpmbuild -E '%{?dist}' | sed -e 's#^\.##')" \
    -d python-duo-openvpn-mozilla -d openvpn_defer_auth \
    -n duo_openvpn-mozilla -v $(VERSION) \
    --url https://github.com/mozilla-it/duo_openvpn \
    -a noarch -C tmp usr
	@rm -rf ./tmp

rpm: pythonrpm pluginrpm

deb:<commit_msg>Update Makefile to modern requirements<commit_after>INSTALL	:= install
DESTDIR	:= /
PREFIX	:= /usr
PACKAGE := duo_openvpn_mozilla
VERSION := 1.1.0
.DEFAULT: test
.PHONY: test coverage coveragereport pyinstall pep8 pylint pythonrpm pluginrpm rpm pythonrpm pythonrpm2 pythonrpm3 deb pypi install clean
TEST_FLAGS_FOR_SUITE := -m unittest discover -v -f -s test

PLAIN_PYTHON = $(shell which python 2>/dev/null)
PYTHON3 = $(shell which python3 2>/dev/null)
ifneq (, $(PYTHON3))
  PYTHON_BIN = $(PYTHON3)
  RPM_MAKE_TARGET = pythonrpm3
endif
ifneq (, $(PLAIN_PYTHON))
  PYTHON_BIN = $(PLAIN_PYTHON)
  RPM_MAKE_TARGET = pythonrpm2
endif

COVERAGE2 = $(shell which coverage 2>/dev/null)
COVERAGE3 = $(shell which coverage-3 2>/dev/null)
ifneq (, $(COVERAGE2))
  COVERAGE = $(COVERAGE2)
endif
ifneq (, $(COVERAGE3))
  COVERAGE = $(COVERAGE3)
endif

# Testing is deliberately verbose because we will skip tests based on the
# capabilities of the user being tested's device
test:
	# If you are seeing a lot of skips, consider editing the deep_testing flags in your conf file.
	python -B $(TEST_FLAGS_FOR_SUITE)

coverage:
	$(COVERAGE) run $(TEST_FLAGS_FOR_SUITE)
	@rm -rf test/__pycache__
	@rm -f $(PACKAGE)/*.pyc test/*.pyc

coveragereport:
	$(COVERAGE) report -m duo_openvpn.py $(PACKAGE)/*.py test/*.py

pyinstall:
	./setup.py install

pep8:
	@find ./* `git submodule --quiet foreach 'echo -n "-path ./$$path -prune -o "'` -type f -name '*.py' -exec pep8 --show-source --max-line-length=100 {} \;

pylint:
	@find ./$(PACKAGE) -path ./test -prune -o -type f -name '*.py' -exec pylint -r no --disable=useless-object-inheritance,superfluous-parens --rcfile=/dev/null {} \;
	@find ./test -type f -name '*.py' -exec pylint -r no --disable=useless-object-inheritance,protected-access,locally-disabled,inconsistent-return-statements --rcfile=/dev/null {} \;

pythonrpm:  $(RPM_MAKE_TARGET)

pythonrpm2:
	fpm -s python -t rpm --python-bin $(PYTHON_BIN) --rpm-dist "$$(rpmbuild -E '%{?dist}' | sed -e 's#^\.##')" --iteration 1 setup.py
	@rm -rf build $(PACKAGE).egg-info

pythonrpm3:
	fpm -s python -t rpm --python-bin $(PYTHON_BIN) --python-package-name-prefix python3 --rpm-dist "$$(rpmbuild -E '%{?dist}' | sed -e 's#^\.##')" --iteration 1 setup.py
	@rm -rf build $(PACKAGE).egg-info

# FIXME: summary  description   git?
pluginrpm:
	$(MAKE) DESTDIR=./tmp install
	fpm -s dir -t rpm --rpm-dist "$$(rpmbuild -E '%{?dist}' | sed -e 's#^\.##')" \
    -d python-duo-openvpn-mozilla -d openvpn_defer_auth \
    -n duo_openvpn-mozilla -v $(VERSION) \
    --url https://github.com/mozilla-it/duo_openvpn \
    -a noarch -C tmp usr
	@rm -rf ./tmp

rpm: pythonrpm pluginrpm

deb:
{'fraction_non_alphanumeric': 0.15993462526266636, 'fraction_numerical': 0.010039691804809714, 'mean_word_length': 3.5237592397043294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6548548', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1596, 'n_words': 477}