<commit_before>TEMPDIR := $(shell mktemp -t tmp.XXXXXX -d)

builddeb:
	sudo apt-get install build-essential
	cp -R debian/DEBIAN/ $(TEMPDIR)
	mkdir -p $(TEMPDIR)/usr/bin
	mkdir -p $(TEMPDIR)/usr/share/doc/email2pdf
	cp email2pdf $(TEMPDIR)/usr/bin
	cp README* $(TEMPDIR)/usr/share/doc/email2pdf
	cp LICENSE* $(TEMPDIR)/usr/share/doc/email2pdf
	cp getmailrc.sample $(TEMPDIR)/usr/share/doc/email2pdf
	fakeroot chmod -R u=rwX,go=rX $(TEMPDIR)
	fakeroot chmod -R u+x $(TEMPDIR)/usr/bin
	fakeroot dpkg-deb --build $(TEMPDIR) .

buildpdfminer3k:
	docker build -t "andrewferrier/pdfminer3k" docker/pdfminer3kdeb
	docker run -i -v ${PWD}:/pdfminer3k andrewferrier/pdfminer3k sh -c 'cp /tmp/python3-pdfminer3k*.deb /pdfminer3k'

builddocker: buildpdfminer3k
	docker build -t andrewferrier/email2pdf .

rundocker_interactive: builddocker
	docker run -i -t andrewferrier/email2pdf /sbin/my_init -- bash -l

rundocker_unittest: builddocker
	docker run -i -t andrewferrier/email2pdf /sbin/my_init -- bash -c 'cd /tmp/email2pdf && make unittest'

unittest:
	python3 -m unittest discover

unittest_test:
	python3 -m unittest discover -f -v

stylecheck:
	flake8 --max-line-length=132 .
<commit_msg>Run style tests in Docker container too.<commit_after>TEMPDIR := $(shell mktemp -t tmp.XXXXXX -d)
FLAKE8 := $(shell which flake8)

builddeb:
	sudo apt-get install build-essential
	cp -R debian/DEBIAN/ $(TEMPDIR)
	mkdir -p $(TEMPDIR)/usr/bin
	mkdir -p $(TEMPDIR)/usr/share/doc/email2pdf
	cp email2pdf $(TEMPDIR)/usr/bin
	cp README* $(TEMPDIR)/usr/share/doc/email2pdf
	cp LICENSE* $(TEMPDIR)/usr/share/doc/email2pdf
	cp getmailrc.sample $(TEMPDIR)/usr/share/doc/email2pdf
	fakeroot chmod -R u=rwX,go=rX $(TEMPDIR)
	fakeroot chmod -R u+x $(TEMPDIR)/usr/bin
	fakeroot dpkg-deb --build $(TEMPDIR) .

buildpdfminer3k:
	docker build -t "andrewferrier/pdfminer3k" docker/pdfminer3kdeb
	docker run -i -v ${PWD}:/pdfminer3k andrewferrier/pdfminer3k sh -c 'cp /tmp/python3-pdfminer3k*.deb /pdfminer3k'

builddocker: buildpdfminer3k
	docker build -t andrewferrier/email2pdf .

rundocker_interactive: builddocker
	docker run -i -t andrewferrier/email2pdf /sbin/my_init -- bash -l

rundocker_testing: builddocker
	docker run -i -t andrewferrier/email2pdf /sbin/my_init -- bash -c 'cd /tmp/email2pdf && make unittest && make stylecheck'

unittest:
	python3 -m unittest discover

unittest_test:
	python3 -m unittest discover -f -v

stylecheck:
	# Debian version is badly packaged, make sure we are using Python 3.
	/usr/bin/env python3 $(FLAKE8) --max-line-length=132 .

{'fraction_non_alphanumeric': 0.12337406385494679, 'fraction_numerical': 0.020496649586125345, 'mean_word_length': 4.222222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5019596', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1010, 'n_words': 244}