-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
242 lines (203 loc) · 7.52 KB
/
Copy pathMakefile
File metadata and controls
242 lines (203 loc) · 7.52 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
239
240
241
242
# 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.
PACKAGE_NAME=hapiplotserver
# Default Python version to use for tests
PYTHON=python3.7
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.1.4
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
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
install-server:
make condaenv PYTHON=python3.7; \
source anaconda3/etc/profile.d/conda.sh; conda activate; \
conda activate python3.7; \
pip install -e .; \
cd ../client-python && pip install -e .; \
cd ../plot-python && pip install -e .;
################################################################################
# Test contents in repository using different python versions
.PHONY: test
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)
pip uninstall -y hapiclient hapiplot hapiplotserver
$(CONDA_ACTIVATE) $(PYTHON); $(PYTHON) setup.py develop | grep "Best"
#$(CONDA_ACTIVATE) $(PYTHON); pip install pytest
$(CONDA_ACTIVATE) $(PYTHON); pip install --no-cache-dir -e .
bash hapiplotserver/test/test_hapiplotserver.sh
$(CONDA_ACTIVATE) $(PYTHON) && $(PYTHON) hapiplotserver/test/test_commandline.py
repository-test-other:
$(CONDA_ACTIVATE) $(PYTHON) && $(PYTHON) hapiplotserver/test/test_hapiplotserver.py
################################################################################
################################################################################
# Anaconda
CONDA_PKG=Miniconda3-latest-Linux-x86_64.sh
ifeq ($(shell uname -s),Darwin)
CONDA_PKG=Miniconda3-latest-MacOSX-x86_64.sh
endif
ifeq ($(shell uname -s),Linux)
CONDA_PKG=Miniconda3-latest-Linux-$(shell uname -m).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): $(CONDA)
$(CONDA_ACTIVATE); \
$(CONDA)/bin/conda create -y --name $(PYTHON) python=$(PYTHON_VER)
$(CONDA): /tmp/$(CONDA_PKG)
bash /tmp/$(CONDA_PKG) -u -b -p $(CONDA)
/tmp/$(CONDA_PKG):
curl https://repo.anaconda.com/miniconda/$(CONDA_PKG) > /tmp/$(CONDA_PKG)
################################################################################
################################################################################
venv-test:
source env-$(PYTHON)/bin/activate && \
pip uninstall -y hapiclient hapiplot hapiplotserver && \
pip install --no-cache-dir --pre '$(PACKAGE)' \
--index-url $(URL)/simple \
--extra-index-url https://pypi.org/simple && \
env-$(PYTHON)/bin/python hapiplotserver/test/test_commandline.py && \
env-$(PYTHON)/bin/python hapiplotserver/test/test_commandline.py
################################################################################
################################################################################
# Packaging
package:
make clean
make version-update
python setup.py sdist
package-test-all:
@ for version in $(PYTHONVERS) ; do \
make repository-test 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/$(PACKAGE_NAME)-$(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/$(PACKAGE_NAME)-$(VERSION).tar.gz \
&& echo Uploaded to $(subst upload.,,$(URL))/project/$(PACKAGE_NAME)/
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='$(PACKAGE_NAME)==$(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 '$(PACKAGE_NAME)==$(VERSION)' --index-url $(URL)/simple
conda list | grep $(PACKAGE_NAME)
pip list | grep $(PACKAGE_NAME)
################################################################################
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 $(PACKAGE_NAME).egg-info/