Makefile 1.76 KB
Newer Older
Michal Horejsek's avatar
Draft  
Michal Horejsek committed
1 2 3

.PHONY: all prepare-dev test lint run-py2 run-py3 build clean

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.
TWISTD_CMD=-c "from twisted.scripts.twistd import run; run()"
Michal Horejsek's avatar
Michal Horejsek committed
6
TWISTD_RUN_ARGS=-l haas.log --pidfile haas.pid haas_proxy -d 42
Michal Horejsek's avatar
Michal Horejsek committed
7

Michal Horejsek's avatar
Draft  
Michal Horejsek committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21
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
FPM_CMD_PY3=${FPM_CMD} --python-bin /usr/bin/python3 --python-package-name-prefix python3

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


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

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

test:
34 35
	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
Draft  
Michal Horejsek committed
36 37

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

Michal Horejsek's avatar
Michal Horejsek committed
40
run-py2: run-kill
Michal Horejsek's avatar
Michal Horejsek committed
41
	sudo python2 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
Michal Horejsek's avatar
Michal Horejsek committed
42
run-py3: run-kill
Michal Horejsek's avatar
Michal Horejsek committed
43
	sudo python3 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
Michal Horejsek's avatar
Michal Horejsek committed
44 45
run-kill:
	kill `cat haas.pid` >/dev/null || true
Michal Horejsek's avatar
Draft  
Michal Horejsek committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

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
	${FPM_CMD} -t tar setup.py

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