-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
238 lines (200 loc) · 7.54 KB
/
Makefile
File metadata and controls
238 lines (200 loc) · 7.54 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Default Python version to use for tests
PYTHON=python3.6
PYTHON_VER=$(subst python,,$(PYTHON))
# Python versions to test
# TODO: Use tox.
PYTHONVERS=python3.8 python3.7 python3.6
# VERSION is updated in "make version-update" step and derived
# from CHANGES.txt. Do not edit.
VERSION=0.0.1b4
SHELL:= /bin/bash
LONG_TESTS=false
# Location to install Anaconda. Important: This directory is removed when
# make test is executed.
CONDA=./anaconda3
# ifeq ($(shell uname -s),MINGW64_NT-10.0-18362)
ifeq ($(TRAVIS_OS_NAME),windows)
# CONDA=/c/tools/anaconda3
CONDA=/c/tools/miniconda3
endif
CONDA_ACTIVATE=source $(CONDA)/etc/profile.d/conda.sh; conda activate
# ifeq ($(shell uname -s),MINGW64_NT-10.0-18362)
ifeq ($(TRAVIS_OS_NAME),windows)
CONDA_ACTIVATE=source $(CONDA)/Scripts/activate; conda activate
endif
# Development:
# Test repository code:
# make repository-test # Test using $(PYTHON)
# make repository-test-all # Test on all versions in $(PYTHONVERS)
#
# Making a local package:
# 1. Update CHANGES.txt to have a new version line
# 2. make package
# 3. make package-test-all
#
# Upload package to pypi.org test starting with uploaded package:
# 1. make release
# 2. Wait ~5 minutes and execute
# 3. make release-test-all
# (Will fail until new version is available at pypi.org for pip install.
# Sometimes takes ~5 minutes even though web page is immediately
# updated.)
# 4. After package is finalized, create new version number in CHANGES.txt ending
# with "b0" in setup.py and then run
# make version-update
# git commit -a -m "Update version for next release"
# This will update the version information in the repository to indicate it
# is now in a pre-release state.
URL=https://upload.pypi.org/
REP=pypi
pythonw=$(PYTHON)
# ifeq ($(shell uname -s),MINGW64_NT-10.0-18362)
ifeq ($(TRAVIS_OS_NAME),windows)
pythonw=python
endif
ifeq ($(UNAME_S),Darwin)
# Use pythonw instead of python. On OS-X, this prevents "need to install
# python as a framework" error. The following finds the path to the binary
# of $(PYTHON) and replaces it with pythonw, e.g.,
# /opt/anaconda3/envs/python3.6/bin/python3.6
# ->
# /opt/anaconda3/envs/python3.6/bin/pythonw
a=$(shell source activate $(PYTHON); which $(PYTHON))
pythonw=$(subst bin/$(PYTHON),bin/pythonw,$(a))
endif
################################################################################
# Test contents in repository using different python versions
test:
make repository-test-all
repository-test-all:
- rm -rf $(CONDA)
@ for version in $(PYTHONVERS) ; do \
make repository-test PYTHON=$$version ; \
done
# These require visual inspection.
repository-test:
@make clean
- conda remove --name $(PYTHON) --all -y
make condaenv PYTHON=$(PYTHON)
$(CONDA_ACTIVATE) $(PYTHON); $(PYTHON) setup.py develop | grep "Best"
$(CONDA_ACTIVATE) $(PYTHON); pip install pytest pillow; pip install .
$(CONDA_ACTIVATE) $(PYTHON); python -m pytest -rx -rP -v test/test_hapiplot.py
repository-test-other:
# Run using pythonw instead of python only so plot windows always work
# for programs called from command line. This is needed for (at least)
# OS-X, Python 3.5, and matplotlib instaled from pip.
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) hapiplot_demo.py
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) test/test_hapiplot_visual.py
#$(CONDA_ACTIVATE) $(PYTHON); $(PYTHON) hapiclient/autoplot/autoplot_test.py
#$(CONDA_ACTIVATE) $(PYTHON); $(PYTHON) hapiclient/gallery/gallery_test.py
#jupyter-notebook ../client-python-notebooks/hapi_demo.ipynb
################################################################################
################################################################################
# Anaconda
CONDA_PKG=Miniconda3-latest-Linux-x86_64.sh
ifeq ($(shell uname -s),Darwin)
CONDA_PKG=Miniconda3-latest-MacOSX-x86_64.sh
endif
condaenv:
# ifeq ($(shell uname -s),MINGW64_NT-10.0-18362)
ifeq ($(TRAVIS_OS_NAME),windows)
cp $(CONDA)/Library/bin/libcrypto-1_1-x64.* $(CONDA)/DLLs/
cp $(CONDA)/Library/bin/libssl-1_1-x64.* $(CONDA)/DLLs/
$(CONDA)/Scripts/conda create -y --name $(PYTHON) python=$(PYTHON_VER)
else
make $(CONDA)/envs/$(PYTHON) PYTHON=$(PYTHON)
endif
$(CONDA)/envs/$(PYTHON): ./anaconda3
$(CONDA_ACTIVATE); \
$(CONDA)/bin/conda create -y --name $(PYTHON) python=$(PYTHON_VER)
./anaconda3: /tmp/$(CONDA_PKG)
bash /tmp/$(CONDA_PKG) -b -p $(CONDA)
/tmp/$(CONDA_PKG):
curl https://repo.anaconda.com/miniconda/$(CONDA_PKG) > /tmp/$(CONDA_PKG)
################################################################################
################################################################################
venv-test:
cp hapiplot_demo.py /tmp # TODO: Explain why needed.
source env-$(PYTHON)/bin/activate && \
pip install pytest && \
pip uninstall -y hapiplot && \
pip install --pre '$(PACKAGE)' \
--index-url $(URL)/simple \
--extra-index-url https://pypi.org/simple && \
env-$(PYTHON)/bin/pytest -v test/test_hapiplot.py && \
env-$(PYTHON)/bin/ipython /tmp/hapiplot_demo.py
################################################################################
################################################################################
# Packaging
package:
make clean
make version-update
python setup.py sdist
package-test-all:
@ for version in $(PYTHONVERS) ; do \
make repository-test-plots PYTHON=$$version ; \
done
env-$(PYTHON):
$(CONDA_ACTIVATE) $(PYTHON); \
conda install -y virtualenv; \
$(PYTHON) -m virtualenv env-$(PYTHON)
package-test:
make package
make env-$(PYTHON)
make venv-test PACKAGE='dist/hapiplot-$(VERSION).tar.gz'
################################################################################
################################################################################
release:
make package
make version-tag
make release-upload
release-upload:
pip install twine
echo "rweigel, t1p"
twine upload \
-r $(REP) dist/hapiplot-$(VERSION).tar.gz \
&& echo Uploaded to $(subst upload.,,$(URL))/project/hapiplot/
release-test-all:
@ for version in $(PYTHONVERS) ; do \
make release-test PYTHON=$$version ; \
done
release-test:
rm -rf env
$(CONDA_ACTIVATE) $(PYTHON); pip install virtualenv; $(PYTHON) -m virtualenv env
make venv-test PACKAGE='hapiplot==$(VERSION)'
################################################################################
################################################################################
# Update version based on content of CHANGES.txt
version-update:
python misc/version.py
version-tag:
git commit -a -m "Last $(VERSION) commit"
git push
git tag -a v$(VERSION) -m "Version "$(VERSION)
git push --tags
################################################################################
################################################################################
# Install package in local directory (symlinks made to local dir)
install-local:
#python setup.py -e .
$(CONDA_ACTIVATE) $(PYTHON); pip install --editable .
install:
pip install 'hapiplot==$(VERSION)' --index-url $(URL)/simple
conda list | grep hapiplot
pip list | grep hapiplot
################################################################################
clean:
- @find . -name __pycache__ | xargs rm -rf {}
- @find . -name *.pyc | xargs rm -rf {}
- @find . -name *.DS_Store | xargs rm -rf {}
- @find . -type d -name __pycache__ | xargs rm -rf {}
- @find . -name *.pyc | xargs rm -rf {}
- @rm -f *~
- @rm -f \#*\#
- @rm -rf env
- @rm -rf dist
- @rm -f MANIFEST
- @rm -rf .pytest_cache/
- @rm -rf hapiclient.egg-info/
- @rm -rf /c/tools/Anaconda3/envs/python3.6/Scripts/wheel.exe*
- @rm -rf /c/tools/Anaconda3/envs/python3.6/vcruntime140.dll.*