Skip to content

Commit 03f8c6c

Browse files
author
Mauko Quiroga
committed
Document Makefile
Merge pull request #1036 from openfisca/doc-make
2 parents 6b3e1d3 + ed8f82a commit 03f8c6c

3 files changed

Lines changed: 44 additions & 33 deletions

File tree

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- run:
2121
name: Install dependencies
2222
command: |
23-
make install
23+
make install.build
2424
# pip install --editable git+https://github.com/openfisca/country-template.git@BRANCH_NAME#egg=OpenFisca-Country-Template # use a specific branch of OpenFisca-Country-Template
2525
# pip install --editable git+https://github.com/openfisca/extension-template.git@BRANCH_NAME#egg=OpenFisca-Extension-Template # use a specific branch of OpenFisca-Extension-Template
2626
@@ -107,7 +107,7 @@ jobs:
107107
name: Upload a Python package to Pypi
108108
command: |
109109
source /tmp/venv/openfisca_core/bin/activate
110-
.circleci/publish-python-package.sh
110+
twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD
111111
112112
- run:
113113
name: Publish a git tag

.circleci/publish-python-package.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

Makefile

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,49 @@
1-
all: test
1+
doc = sed -n "/^$1/ { x ; p ; } ; s/\#\#/[⚙]/ ; s/\./.../ ; x" ${MAKEFILE_LIST}
22

3-
uninstall:
4-
pip freeze | grep -v "^-e" | xargs pip uninstall -y
3+
## Same as `make test`.
4+
all: test
55

6+
## Install project dependencies.
67
install:
7-
pip install --upgrade pip twine wheel
8-
pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver
9-
10-
clean:
11-
rm -rf build dist
12-
find . -name '*.pyc' -exec rm \{\} \;
13-
14-
check-syntax-errors:
15-
python -m compileall -q .
16-
17-
check-types:
18-
mypy openfisca_core && mypy openfisca_web_api
19-
20-
check-style:
21-
@# Do not analyse .gitignored files.
22-
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
23-
flake8 `git ls-files | grep "\.py$$"`
24-
25-
format-style:
26-
@# Do not analyse .gitignored files.
27-
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
28-
autopep8 `git ls-files | grep "\.py$$"`
8+
@$(call doc,$@:)
9+
@pip install --upgrade pip setuptools wheel
10+
@pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver
2911

12+
## Recreate a clean slate locally.
13+
uninstall:
14+
@## Trying out packages, building openfisca, etc., can make tests fail.
15+
@## This task uninstalls everything, including packages in editable mode.
16+
@$(call doc,$@:)
17+
pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y
18+
19+
## Delete builds and compiled python files.
20+
clean: \
21+
$(shell ls -d * | grep "build\|dist") \
22+
$(shell find . -name "*.pyc")
23+
@$(call doc,$@:)
24+
@rm -rf $?
25+
26+
## Run linters to check for syntax and style errors.
27+
check-style: $(shell git ls-files "*.py")
28+
@$(call doc,$@:)
29+
@flake8 $?
30+
31+
## Run code formatters to correct style errors.
32+
format-style: $(shell git ls-files "*.py")
33+
@$(call doc,$@:)
34+
@autopep8 $?
35+
36+
## Run static type checkers for type errors.
37+
check-types: openfisca_core openfisca_web_api
38+
@$(call doc,$@:)
39+
@mypy $?
40+
41+
## Run openfisca-core tests.
3042
test: clean check-syntax-errors check-style check-types
31-
env PYTEST_ADDOPTS="$$PYTEST_ADDOPTS --cov=openfisca_core" pytest
43+
@$(call doc,$@:)
44+
@PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov=openfisca_core" pytest
3245

46+
## Serve the openfisca Web API.
3347
api:
34-
openfisca serve --country-package openfisca_country_template --extensions openfisca_extension_template
48+
@$(call doc,$@:)
49+
@openfisca serve --country-package openfisca_country_template --extensions openfisca_extension_template

0 commit comments

Comments
 (0)