Makefile 1.95 KB
Newer Older
Michal Horejsek's avatar
Michal Horejsek committed
1

Michal Horejsek's avatar
Michal Horejsek committed
2 3
.PHONY: all prepare-dev test lint run-py2 run-py3 release build clean
SHELL=/bin/bash
Michal Horejsek's avatar
Michal Horejsek committed
4

5
# Normally it would be just twistd but it runs always with Python 2 in this moment.
6 7
TWISTD_CMD=-m haas_proxy
TWISTD_RUN_ARGS=-l haas.log -n haas_proxy -d ${DEVICE_TOKEN}
8

Michal Horejsek's avatar
Michal Horejsek committed
9 10
FPM_CMD=fpm -f -d sshpass -m 'haas@nic.cz' -s python
FPM_CMD_PY2=${FPM_CMD} --python-bin /usr/bin/python2 --python-package-name-prefix python
11
FPM_CMD_PY3=${FPM_CMD} --python-bin /usr/bin/python3 --python-package-name-prefix python3 --python-install-lib /usr/lib/python3/dist-packages
Michal Horejsek's avatar
Michal Horejsek committed
12 13 14 15 16 17 18 19 20 21 22

all:
	@echo "make prepare-dev"
	@echo "make test"
	@echo "make lint"
	@echo "make run"
	@echo "make build"
	@echo "make clean"


prepare-dev:
23
	@# lib*-dev and cffi for building cryptography, dependency of twisted.
24
	apt-get install -y python python-dev python-pip python3 python3-dev python3-pip sshpass libffi-dev libssl-dev
25 26
	python2 -m pip install -U cffi
	python3 -m pip install -U cffi
27 28
	python2 -m pip install -e .[test]
	python3 -m pip install -e .[test]
Michal Horejsek's avatar
Michal Horejsek committed
29 30

    # Build dependencies
Michal Horejsek's avatar
Michal Horejsek committed
31
	apt-get install -y ruby ruby-dev rubygems build-essential rpm
Michal Horejsek's avatar
Michal Horejsek committed
32 33 34
	gem install --no-ri --no-rdoc fpm

test:
35 36
	if [ `which python2` ]; then python2 -m pytest test_haas_proxy.py; fi
	if [ `which python3` ]; then python3 -m pytest test_haas_proxy.py; fi
Michal Horejsek's avatar
Michal Horejsek committed
37 38

lint:
39
	python3 -m pylint --rcfile=pylintrc haas_proxy haas_proxy/twisted/plugins/haas_proxy_plugin.py
Michal Horejsek's avatar
Michal Horejsek committed
40

41
run-py2:
Michal Horejsek's avatar
Michal Horejsek committed
42
	python2 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
43
run-py3:
Michal Horejsek's avatar
Michal Horejsek committed
44
	python3 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
Michal Horejsek's avatar
Michal Horejsek committed
45

Michal Horejsek's avatar
Michal Horejsek committed
46 47 48 49 50 51
release: build
	rm -rf release
	mkdir release
	mv *deb *rpm *tar.gz release
	cd release; for f in `ls`; do md5sum "$${f}" > "$${f}.checksum"; done

52 53 54
upload:
	python3 setup.py register sdist upload

Michal Horejsek's avatar
Michal Horejsek committed
55 56 57 58 59 60 61 62 63 64
build:
	# Debian packages
	${FPM_CMD_PY2} -t deb setup.py
	${FPM_CMD_PY3} -t deb setup.py

	# Red Hat packages
	${FPM_CMD_PY2} -t rpm setup.py
	${FPM_CMD_PY3} -t rpm setup.py

    # Just archive, no deps
Michal Horejsek's avatar
Michal Horejsek committed
65
	python setup.py sdist --formats=gztar --dist-dir .
Michal Horejsek's avatar
Michal Horejsek committed
66 67 68

clean:
	python setup.py clean
Michal Horejsek's avatar
Michal Horejsek committed
69
	rm -rf *.deb *.rpm *.tar