-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (85 loc) · 3.96 KB
/
Copy pathMakefile
File metadata and controls
100 lines (85 loc) · 3.96 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# makefile for Python workflows library
PYTHON?=python
PIP?=$(PYTHON) -m pip
ECHO?=$(shell which echo) -e
PRINTF?=$(shell which printf)
# Variables required for release and bugfix options
GROUP=WF
PROJECT=hcd
PROJECT_ID=unknown
PACKAGE=hcd
SOURCE_HOST=git.iter.org
# Git bitbucket-like URL
SOURCE_URL=https://$(SOURCE_HOST)/projects/$(GROUP)/repos/$(PROJECT)
# Other variables
SUBDIRS:=
#####################################################
.PHONY: help clean sdist bdist wheel install_package upload_package_to_gitlab install_package_from_gitlab docs tests realclean
help:
@$(ECHO) "Recipes:"
@$(ECHO) " clean - remove all build, test, doc, and Python artifacts"
@$(ECHO) " sdist - build package for source distribution"
@$(ECHO) " bdist - build package for binary distribution"
@$(ECHO) " wheel - build package for binary wheel distribution"
@$(ECHO) " docs - build documentation for package"
@$(ECHO) " realclean - clean and remove build distributions "
@$(ECHO) ""
@$(ECHO) "Environment variables:"
@$(ECHO) " PYTHON - Python binary to use for commands [default: "$(shell grep -e PYTHON?\= Makefile | cut -d\= -f2)"]"
@$(ECHO) " PIP - Pip binary to use for commands [default: "$(shell grep -e PIP?\= Makefile | cut -d\= -f2)"]"
@$(ECHO) " PYTHONTOOLS_EXTRAS - Extras to install [default: "$(shell grep -e PYTHONTOOLS_EXTRAS?\= Makefile | cut -d\= -f2)"]"
# Build a 'sdist' or 'installable source distribution' with setuptools
# This creates a sdist package installable with pip
# On pip install this will re-compile from source compiled components
sdist:
@echo 'Building sdist with PYTHON=$(PYTHON)'
$(PYTHON) setup.py sdist
# Build a 'bdist' or 'installable binary distribution' with setuptools
# This creates a bdist package installable with pip
# This should be pip-installable on the system it was compiled on
# Not recommended to use this! Use wheels instead
bdist:
@echo 'Building bdist with PYTHON=$(PYTHON)'
$(PYTHON) setup.py bdist
# Build a 'wheel' or 'installable universial binary distribution' with setuptools
# This creates a wheel that can be used with pip
wheel:
@echo 'Building wheel with PYTHON=$(PYTHON)'
$(PYTHON) setup.py bdist_wheel
# Build HTML pages
docs:
$(MAKE) -C docs html
# Get the current version.
# The name will be generated from git, i.e.
# imaspy-0.1.dev240+g95f5f13.d20200904.tar.gz
# See https://pypi.org/project/setuptools-scm/
# Falls back to `_PYTHONTOOLS_VERSION` env variable if setup.py can't figure it out
# Falls back to 0.0.0 if _that_ does not exist
VERSION_STRING=$(shell $(PYTHON) setup.py --version)
WHEEL_NAME:=$(PACKAGE)-$(VERSION_STRING)-py3-none-any.whl
SDIST_NAME:=$(PACKAGE)-$(VERSION_STRING).tar.gz
PYTHON_INSTALL_DIR?=install
install_package:
@echo [INFO] Installing version '$(VERSION_STRING)'
@echo [INFO] With extras $(PYTHONTOOLS_EXTRAS)
@echo [INFO] to $(PYTHON_INSTALL_DIR)
@echo [INFO] Assuming generated wheel is '$(WHEEL_NAME)'
@echo [DEBUG] setuptools version=$(shell $(PYTHON) -c "import setuptools; print(setuptools.__version__)")
@echo [DEBUG] setuptools SCM detected version=$(shell $(PYTHON) -c "from setuptools_scm import get_version; print(get_version(root='.'));")
@echo [DEBUG] wheel version=$(shell $(PYTHON) -c "import wheel; print(wheel.__version__)")
PYTHONUSERBASE=$(PYTHON_INSTALL_DIR) pip install dist/$(WHEEL_NAME)[$(PYTHONTOOLS_EXTRAS)] --cache-dir=$(PYTHON_INSTALL_DIR)/pip_cache --user --upgrade
PYTEST?=pytest
COV_FLAGS?=--cov=$(PACKAGE) --cov-report=term --cov-report=xml:./coverage.xml
JUNIT_FLAGS?=--junit-xml=./junit.xml
PYTEST_MARK?=
PYTEST_FLAGS?=-n auto
test:
$(PYTEST) $(PYTEST_FLAGS) $(COV_FLAGS) $(JUNIT_FLAGS) -m "$(PYTEST_MARK)" $(PROJECT)
clean:
@echo 'Cleaning $(PROJECT)...'
$(PYTHON) setup.py clean --all
$(MAKE) -C docs $@
realclean: clean
@echo 'Real cleaning $(PROJECT)...'
rm -f dist/*
$(MAKE) -C docs $@