1- OK := "$$(tput setaf 2 ) ✓ $$(tput sgr0 ) "
2- PASS := "$$(tput setaf 3 ) ✓ $$(tput sgr0 ) "
3- WORKING := "$$(tput setaf 5 ) [⚙] $$(tput sgr0 ) "
4- OPTIONS := "$$(tput setaf 6 ) [ℹ] $$(tput sgr0 ) "
1+ OK := "$$(tput setaf 2 ) [✓] $$(tput sgr0 ) "
2+ KO := "$$(tput setaf 1 ) [!] $$(tput sgr0 ) "
3+ PASS := "$$(tput setaf 3 ) [~] $$(tput sgr0 ) "
4+ WORKING := "$$(tput setaf 5 ) [⚙]$$(tput sgr0 ) "
5+ OPTIONS := "$$(tput setaf 6 ) [ℹ]$$(tput sgr0 ) "
56COUNTRY_TEMPLATE := openfisca_country_template
67EXTENSION_TEMPLATE := openfisca_extension_template
7- PYTHON_PACKAGES_PATH := $( shell python -c "import sysconfig; print(sysconfig.get_paths() [\"purelib\"])")
8+ PYTHON_PACKAGES_PATH := $$( python -c "import sysconfig; print(sysconfig.get_paths( ) [\"purelib\"])")
89COUNTRY_TEMPLATE_TESTS := ${PYTHON_PACKAGES_PATH}/${COUNTRY_TEMPLATE}/tests
910EXTENSION_TEMPLATE_TESTS := ${PYTHON_PACKAGES_PATH}/${EXTENSION_TEMPLATE}/tests
1011
@@ -49,38 +50,35 @@ help:
4950
5051# # Uninstall project dependencies.
5152uninstall :
52- @printf ${WORKING}
53- @echo " Uninstalling dependencies..."
53+ @echo " ${WORKING} Uninstalling dependencies..."
5454 @pip freeze | grep -v " ^-e" | xargs pip uninstall -y
5555
5656# # Install project dependencies.
5757install :
58- @printf ${WORKING}
59- @echo " Installing dependencies..."
58+ @echo " ${WORKING} Installing dependencies..."
6059 @pip install --upgrade pip twine wheel
6160 @pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver
6261
6362# # Delete builds and compiled python files.
6463clean :: ;
6564
6665clean :: $(shell find . -name "* .pyc")
67- @printf ${WORKING}
68- @printf " Deleting compiled files..."
66+ @printf " ${WORKING} Deleting compiled files..."
6967 @[ ! -z " $? " ] \
70- && { rm -f $? && echo ${OK} ; } \
68+ && rm -f $? \
69+ && echo ${OK} \
7170 || echo ${PASS}
7271
7372clean :: $(shell ls -d * | grep "build\|dist")
74- @printf ${WORKING}
75- @printf " Deleting builds..."
73+ @printf " ${WORKING} Deleting builds..."
7674 @[ ! -z " $? " ] \
77- && { rm -rf $? && echo ${OK} ; } \
75+ && rm -rf $? \
76+ && echo ${OK} \
7877 || echo ${PASS}
7978
8079# # Compile python files to check for syntax errors.
8180check-syntax-errors :
82- @printf ${WORKING}
83- @printf " Compiling python files..."
81+ @printf " ${WORKING} Compiling python files..."
8482 @python -m compileall -q .
8583 @echo ${OK}
8684
@@ -89,29 +87,28 @@ check-style: $(shell git ls-files | grep "\.py$$")
8987 @# # Do not analyse .gitignored files.
9088 @# # `make` needs `$$` to output `$`.
9189 @# # See http://stackoverflow.com/questions/2382764.
92- @printf ${WORKING}
93- @printf " Running linters..."
90+ @printf " ${WORKING} Running linters..."
9491 @flake8 $? & > /tmp/result; echo $$? > /tmp/status;
9592 @[ $$ (< /tmp/status) -eq 0 ] \
9693 && echo ${OK} \
97- || { echo " \n$$ (cat /tmp/result)" && exit $$ (< /tmp/status) ; }
94+ || echo " ${KO} \n$$ (</tmp/result)" \
95+ && exit $$(</tmp/status )
9896
9997# # Run static type checkers for type errors.
10098check-types : $(shell ls -d * | grep "openfisca_")
101- @printf ${WORKING}
102- @printf " Running static type checkers..."
99+ @printf " ${WORKING} Running static type checkers..."
103100 @mypy $? & > /tmp/result; echo $$? > /tmp/status;
104101 @[ $$ (< /tmp/status) -eq 0 ] \
105102 && echo ${OK} \
106- || { echo " \n$$ (cat /tmp/result)" && exit $$ (< /tmp/status) ; }
103+ || echo " ${KO} \n$$ (</tmp/result)" \
104+ && exit $$(</tmp/status )
107105
108106# # Run code formatters to correct style errors.
109107format-style : $(shell git ls-files | grep "\.py$$")
110108 @# # Do not analyse .gitignored files.
111109 @# # `make` needs `$$` to output `$`.
112110 @# # See http://stackoverflow.com/questions/2382764.
113- @printf ${WORKING}
114- @printf " Running code formatters..."
111+ @printf " ${WORKING} Running code formatters..."
115112 @autopep8 $?
116113 @echo ${OK}
117114
@@ -129,23 +126,20 @@ test:: clean check-syntax-errors check-style check-types
129126 @# # make test pytest_args="--exitfirst" openfisca_args="--performance"
130127
131128test ::
132- @printf ${WORKING}
133- @echo " Running openfisca-core tests..."
134- @[ ! -z " ${pytest_args} " ] && printf ${OPTIONS} && echo " pytest arguments: ${pytest_args} " ; :
129+ @echo " ${WORKING} Running openfisca-core tests..."
130+ @[ ! -z " ${pytest_args} " ] && echo " ${OPTIONS} pytest arguments: ${pytest_args} " ; :
135131 @PYTEST_ADDOPTS=" $$ PYTEST_ADDOPTS ${pytest_args} " pytest
136132
137133test ::
138- @printf ${WORKING}
139- @echo " Running country-template tests..."
140- @[ ! -z " ${pytest_args} " ] && printf ${OPTIONS} && echo " pytest arguments: ${pytest_args} " ; :
141- @[ ! -z " ${openfisca_args} " ] && printf ${OPTIONS} && echo " openfisca arguments: ${openfisca_args} " ; :
134+ @echo " ${WORKING} Running country-template tests..."
135+ @[ ! -z " ${pytest_args} " ] && echo " ${OPTIONS} pytest arguments: ${pytest_args} " ; :
136+ @[ ! -z " ${openfisca_args} " ] && echo " ${OPTIONS} openfisca arguments: ${openfisca_args} " ; :
142137 @PYTEST_ADDOPTS=" $$ PYTEST_ADDOPTS ${pytest_args} " openfisca test ${COUNTRY_TEMPLATE_TESTS} --country-package ${COUNTRY_TEMPLATE} ${openfisca_args}
143138
144139test ::
145- @printf ${WORKING}
146- @echo " Running extension-template tests..."
147- @[ ! -z " ${pytest_args} " ] && printf ${OPTIONS} && echo " pytest arguments: ${pytest_args} " ; :
148- @[ ! -z " ${openfisca_args} " ] && printf ${OPTIONS} && echo " openfisca arguments: ${openfisca_args} " ; :
140+ @echo " ${WORKING} Running extension-template tests..."
141+ @[ ! -z " ${pytest_args} " ] && echo " ${OPTIONS} pytest arguments: ${pytest_args} " ; :
142+ @[ ! -z " ${openfisca_args} " ] && echo " ${OPTIONS} openfisca arguments: ${openfisca_args} " ; :
149143 @PYTEST_ADDOPTS=" $$ PYTEST_ADDOPTS ${pytest_args} " openfisca test ${EXTENSION_TEMPLATE_TESTS} --country-package ${COUNTRY_TEMPLATE} --extensions ${EXTENSION_TEMPLATE} ${openfisca_args}
150144
151145# # Serve the OpenFisca Web API.
@@ -160,10 +154,9 @@ serve::
160154 @# # make serve gunicorn_args="--workers 1"
161155 @# # make serve openfisca_args="--welcome-message 'Hola :)'"
162156 @# # make serve gunicorn_args="--workers 1" openfisca_args="--welcome-message 'Hola :)'"
163- @printf ${WORKING}
164- @echo " Serving the OpenFisca Web API..."
165- @[ ! -z " ${gunicorn_args} " ] && printf ${OPTIONS} && echo " gunicorn arguments: ${gunicorn_args} " ; :
166- @[ ! -z " ${openfisca_args} " ] && printf ${OPTIONS} && echo " openfisca arguments: ${openfisca_args} " ; :
157+ @echo " ${WORKING} Serving the OpenFisca Web API..."
158+ @[ ! -z " ${gunicorn_args} " ] && echo " ${OPTIONS} gunicorn arguments: ${gunicorn_args} " ; :
159+ @[ ! -z " ${openfisca_args} " ] && echo " ${OPTIONS} openfisca arguments: ${openfisca_args} " ; :
167160 @openfisca serve --country-package ${COUNTRY_TEMPLATE} --extensions ${EXTENSION_TEMPLATE} ${gunicorn_args} ${openfisca_args}
168161
169162api : serve
0 commit comments