forked from cvxgrp/cvxportfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (57 loc) · 1.93 KB
/
Makefile
File metadata and controls
71 lines (57 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# This Makefile is used to automate some development tasks.
# Ideally this logic would be in pyproject.toml but it appears
# easier to do it this way for now.
PYTHON = python
PROJECT = cvxportfolio
TESTS = $(PROJECT)/tests
BUILDDIR = build
ENVDIR = env
BINDIR = $(ENVDIR)/bin
EXTRA_SCRIPTS = bumpversion.py run_examples.py
EXAMPLES = examples/*.py
ifeq ($(OS), Windows_NT)
BINDIR=$(ENVDIR)/Scripts
endif
.PHONY: env clean update test lint docs opendocs coverage fix release examples
env:
$(PYTHON) -m venv $(ENVDIR)
$(BINDIR)/python -m pip install --editable .
$(BINDIR)/python -m pip install -r requirements.txt
clean:
-rm -rf $(BUILDDIR)/*
-rm -rf $(PROJECT).egg*
-rm -rf $(ENVDIR)/*
update: clean env
test:
$(BINDIR)/coverage run -m $(PROJECT).tests
$(BINDIR)/coverage report
$(BINDIR)/coverage xml
$(BINDIR)/diff-cover coverage.xml --config-file pyproject.toml
# disabled for now, we need to change pickle as default on-disk cache
# $(BINDIR)/bandit $(PROJECT)/*.py $(PROJECT)/tests/*.py
lint:
$(BINDIR)/pylint $(PROJECT)
docs:
$(BINDIR)/sphinx-build -E docs $(BUILDDIR)
opendocs: docs
open build/index.html
coverage:
$(BINDIR)/coverage html --fail-under=0 # overwrite pyproject.toml default
open htmlcov/index.html
fix:
# selected among many code auto-fixers, tweaked in pyproject.toml
$(BINDIR)/autopep8 -i $(PROJECT)/*.py $(TESTS)/*.py
$(BINDIR)/isort $(PROJECT)/*.py $(TESTS)/*.py
# this is the best found for the purpose
$(BINDIR)/docformatter --in-place $(PROJECT)/*.py $(TESTS)/*.py
release: update lint test
$(BINDIR)/python bumpversion.py
git push --no-verify
$(BINDIR)/python -m build
$(BINDIR)/twine check dist/*
$(BINDIR)/twine upload --skip-existing dist/*
examples:
for example in hello_world case_shiller dow30_example; \
do env CVXPORTFOLIO_SAVE_PLOTS=1 $(BINDIR)/python examples/"$$example".py > docs/_static/"$$example"_output.txt; \
done
mv *.png docs/_static/