Debian Codegraph @

Makefile

raw symbols SCIP
1 MAKEFILE_PATH := $(realpath $(firstword $(MAKEFILE_LIST)))
2 GIT_ROOT := $(shell dirname $(MAKEFILE_PATH))
3 VENV_ROOT := $(GIT_ROOT)/.venv
4
5 PACKAGE_NAME := sure
6 MAIN_CLI_NAME := sure
7 REQUIREMENTS_FILE := development.txt
8
9 PACKAGE_PATH := $(GIT_ROOT)/$(PACKAGE_NAME)
10 REQUIREMENTS_PATH := $(GIT_ROOT)/$(REQUIREMENTS_FILE)
11 MAIN_CLI_PATH := $(VENV_ROOT)/bin/$(MAIN_CLI_NAME)
12 export VENV ?= $(VENV_ROOT)
13
14 OSNAME := $(shell uname)
15 ifeq ($(OSNAME), Linux)
16 OPEN_COMMAND := gnome-open
17 else
18 OPEN_COMMAND := open
19 endif
20 export SURE_NO_COLORS := true
21
22 ######################################################################
23 # Phony targets (only exist for typing convenience and don't represent
24 # real paths as Makefile expects)
25 ######################################################################
26
27 # default target when running `make` without arguments
28 all: | $(MAIN_CLI_PATH)
29
30 # creates virtualenv
31 venv: | $(VENV)
32
33 # updates pip and setuptools to their latest version
34 develop: | $(VENV)/bin/python $(VENV)/bin/pip
35
36 # installs the requirements and the package dependencies
37 setup: | $(MAIN_CLI_PATH)
38
39 # Convenience target to ensure that the venv exists and all
40 # requirements are installed
41 dependencies:
42 @rm -f $(MAIN_CLI_PATH) # remove MAIN_CLI_PATH to trigger pip install
43 $(MAKE) develop setup
44
45 docs:
46 @(cd docs && make html)
47 $(OPEN_COMMAND) docs/build/html/index.html
48
49 test tests: clean | $(VENV)/bin/pytest # $(VENV)/bin/nosetests # @$(VENV)/bin/nosetests --rednose --immediate -vv --with-coverage --cover-package=sure
50 @$(VENV)/bin/pytest -vv --cov=sure
51
52 # run main command-line tool
53 run: | $(MAIN_CLI_PATH)
54 @$(MAIN_CLI_PATH) --help
55
56 # Pushes release of this package to pypi
57 push-release: dist # pushes distribution tarballs of the current version
58 $(VENV)/bin/twine upload dist/*.tar.gz
59
60 # Prepares release of this package prior to pushing to pypi
61 build-release:
62 $(VENV)/bin/python setup.py build sdist
63 $(VENV)/bin/twine check dist/*.tar.gz
64
65 # Convenience target that runs all tests then builds and pushes a release to pypi
66 release: tests
67 @./.release
68 $(MAKE) build-release
69 $(MAKE) push-release
70
71 # Convenience target to delete the virtualenv
72 clean:
73 @rm -rf .coverage
74
75 # Convenience target to format code with black with PEP8's default
76 # 80 character limit per line
77 black: | $(VENV)/bin/black
78 @$(VENV)/bin/black -l 80 $(PACKAGE_PATH) tests
79
80 ##############################################################
81 # Real targets (only run target if its file has been "made" by
82 # Makefile yet)
83 ##############################################################
84
85 # creates virtual env if necessary and installs pip and setuptools
86 $(VENV): | $(REQUIREMENTS_PATH) # creates $(VENV) folder if does not exist
87 echo "Creating virtualenv in $(VENV_ROOT)" && python3 -mvenv $(VENV)
88
89 # installs pip and setuptools in their latest version, creates virtualenv if necessary
90 $(VENV)/bin/python $(VENV)/bin/pip: # installs latest pip
91 @test -e $(VENV)/bin/python || $(MAKE) $(VENV)
92 @test -e $(VENV)/bin/pip || $(MAKE) $(VENV)
93 @echo "Installing latest version of pip and setuptools"
94 @$(VENV)/bin/pip install -U pip setuptools
95
96 # installs latest version of the "black" code formatting tool
97 $(VENV)/bin/black: | $(VENV)/bin/pip
98 $(VENV)/bin/pip install -U black
99
100 # installs this package in "edit" mode after ensuring its requirements are installed
101
102 $(VENV)/bin/nosetests $(VENV)/bin/pytest $(MAIN_CLI_PATH): | $(VENV) $(VENV)/bin/pip $(VENV)/bin/python $(REQUIREMENTS_PATH)
103 $(VENV)/bin/pip install -r $(REQUIREMENTS_PATH)
104 $(VENV)/bin/pip install -e .
105
106 # ensure that REQUIREMENTS_PATH exists
107 $(REQUIREMENTS_PATH):
108 @echo "The requirements file $(REQUIREMENTS_PATH) does not exist"
109 @echo ""
110 @echo "To fix this issue:"
111 @echo " edit the variable REQUIREMENTS_NAME inside of the file:"
112 @echo " $(MAKEFILE_PATH)."
113 @echo ""
114 @exit 1
115
116 ###############################################################
117 # Declare all target names that exist for convenience and don't
118 # represent real paths, which is what Make expects by default:
119 ###############################################################
120
121 .PHONY: \
122 all \
123 black \
124 build-release \
125 clean \
126 dependencies \
127 develop \
128 push-release \
129 release \
130 setup \
131 run \
132 test \
133 tests \
134 docs