11# Development:
22# Test repository code:
3- # make repository-test # Test using $(PYTHON)
4- # make repository-test-fast # Test w/o installing anaconda3 in .. (run after repository-test)
5- # make repository-test-all # Test on all versions in $(PYTHONVERS)
3+ #
4+ # Test a single version of Python and Matplotlib; install anaconda3 & create env if needed.
5+ # make repository-test-single PYTHON=3.8 MATPLOTLIB=3.6
6+ #
7+ # Run tests that require visual inspection
8+ # make repository-test-single-visual PYTHON=3.8 MATPLOTLIB=3.6
9+ #
10+ # Test a single version of Python and all values of Matplotlib; create conda env if needed.
11+ # make repository-test PYTHON=3.8
12+ #
13+ # Remove ./anaconda3 and run all tests (all combos of Python/Matplotlib)
14+ # make repository-test-all
615#
716# Making a local package:
817# 1. Update CHANGES.txt to have a new version line
9- # 2. make package
10- # 3. make package-test-all
18+ # 2. make package-test PYTHON=3.8 MATPLOTLIB=3.5 # (Probably don't need to test all combos)
19+ #
20+ # Test https://colab.research.google.com/github/hapi-server/client-python-notebooks/blob/master/hapi_demo.ipynb#examples
21+ #
1122#
1223# Upload package to pypi.org test starting with uploaded package:
1324# 1. make release
2435# is now in a pre-release state.
2536
2637# https://matplotlib.org/stable/devel/min_dep_policy.html
27- PYTHON =python3.5
28- MATPLOTLIBS =3.0
29- PYTHON_VER = $( subst python,, $( PYTHON ) )
38+ ifeq ( $( PYTHON ) ,3.5)
39+ MATPLOTLIBS=3.0
40+ endif
3041
31- PYTHON =python3.6
32- MATPLOTLIBS =3.0 3.1 3.2 3.3
33- PYTHON_VER =$(subst python,,$(PYTHON ) )
42+ ifeq ($(PYTHON ) ,3.6)
43+ MATPLOTLIBS=3.2 3.1 3.0
44+ endif
45+
46+ ifeq ($(PYTHON ) ,3.7)
47+ MATPLOTLIBS=3.5 3.4 3.3 3.2 3.1 3.0
48+ endif
3449
35- # Default Python version to use for tests
36- PYTHON =python3.7
37- MATPLOTLIBS =3.4 3.5
38- PYTHON_VER =$(subst python,,$(PYTHON ) )
50+ ifeq ($(PYTHON ) ,3.8)
51+ # 3.0 fails on OS-X with
52+ # "The C/C++ header for freetype2 (ft2build.h)
53+ # could not be found. You may need to install the
54+ # development package.""
55+ MATPLOTLIBS=3.6 3.5 3.4 3.3 3.2 3.1
56+ endif
57+
58+ ifeq ($(PYTHON ) ,3.9)
59+ # 3.0-3.3 fail on OS-X with error: fatal error: 'ft2build.h' file not found
60+ MATPLOTLIBS=3.6 3.5 3.4
61+ endif
3962
4063# Python versions to test
41- # TODO: Use tox.
42- PYTHONVERS =python3.8 python3.7 python3.6 python3.5
64+ PYTHONS =3.9 3.8 3.7 3.6 3.5
4365
4466# VERSION is updated in "make version-update" step and derived
4567# from CHANGES.txt. Do not edit.
46- VERSION =0.2.2b1
68+ VERSION =0.2.2
4769SHELL: = /bin/bash
4870
4971LONG_TESTS =false
@@ -58,76 +80,59 @@ ifeq ($(TRAVIS_OS_NAME),windows)
5880 CONDA=/c/tools/miniconda3
5981endif
6082
61-
6283CONDA_ACTIVATE =source $(CONDA ) /etc/profile.d/conda.sh; conda activate
6384
6485# ifeq ($(shell uname -s),MINGW64_NT-10.0-18362)
6586ifeq ($(TRAVIS_OS_NAME ) ,windows)
6687 CONDA_ACTIVATE=source $(CONDA)/Scripts/activate; conda activate
6788endif
6889
69-
7090URL =https://upload.pypi.org/
7191REP =pypi
7292
73- pythonw =$(PYTHON )
74-
93+ pythonw =python$(PYTHON )
7594# ifeq ($(shell uname -s),MINGW64_NT-10.0-18362)
7695ifeq ($(TRAVIS_OS_NAME ) ,windows)
7796 pythonw=python
7897endif
79-
8098ifeq ($(UNAME_S ) ,Darwin)
8199 # Use pythonw instead of python. On OS-X, this prevents "need to install
82100 # python as a framework" error. The following finds the path to the binary
83101 # of $(PYTHON) and replaces it with pythonw, e.g.,
84102 # /opt/anaconda3/envs/python3.6/bin/python3.6
85103 # ->
86104 # /opt/anaconda3/envs/python3.6/bin/pythonw
87- a=$(shell source activate $(PYTHON); which $(PYTHON))
88- pythonw=$(subst bin/$(PYTHON),bin/pythonw,$(a))
105+ # a=$(shell source activate python- $(PYTHON)-matplotlib-$(MATPLOTLIB) ; which python $(PYTHON))
106+ # pythonw=$(subst bin/python $(PYTHON),bin/pythonw,$(a))
89107endif
90108
91-
92109# ###############################################################################
93110# Test contents in repository using different python versions
94111test :
95112 make repository-test-all
96113
97114repository-test-all :
98115 - rm -rf $(CONDA )
99- @ for version in $( PYTHONVERS ) ; do \
116+ @ for version in $( PYTHONS ) ; do \
100117 make repository-test PYTHON=$$ version ; \
101118 done
102119
103- repository-test-single :
104- make condaenv PYTHON=$(PYTHON )
105- $(CONDA_ACTIVATE ) $(PYTHON ) && pip install matplotlib==" $( MATPLOTLIB) .*"
106- @ $(CONDA_ACTIVATE ) $(PYTHON ) && $(PYTHON ) setup.py develop | grep " Best"
107- # Not sure why the following is needed, but I get pytest install errors otherwise.
108- @ $(CONDA_ACTIVATE ) $(PYTHON ) && pip install pytest pillow; pip install .
109- $(CONDA_ACTIVATE ) $(PYTHON ) && $(PYTHON ) -m pytest -rx -rP -v test/test_hapiplot.py
110-
111- repository-test-fast :
112- $(foreach MATPLOTLIB, $(MATPLOTLIBS ) , \
113- make repository-test-single MATPLOTLIB=$(MATPLOTLIB ) PYTHON=$(PYTHON ) ; )
114-
115120repository-test :
116- @make clean
117- rm -rf anaconda3
118121 $(foreach MATPLOTLIB, $(MATPLOTLIBS ) , \
119122 make repository-test-single MATPLOTLIB=$(MATPLOTLIB ) PYTHON=$(PYTHON ) ; )
120123
124+ repository-test-single :
125+ make anaconda3/envs/python-$(PYTHON ) -matplotlib-$(MATPLOTLIB ) MATPLOTLIB=$(MATPLOTLIB ) PYTHON=$(PYTHON )
126+ $(CONDA_ACTIVATE ) python-$(PYTHON ) -matplotlib-$(MATPLOTLIB ) && python$(PYTHON ) -m pytest -rx -rP -v test/test_hapiplot.py
127+
121128# These require visual inspection.
122- repository-test-other :
129+ repository-test-single-visual :
123130 # Run using pythonw instead of python only so plot windows always work
124131 # for programs called from command line. This is needed for (at least)
125132 # OS-X, Python 3.5, and matplotlib instaled from pip.
126- $(CONDA_ACTIVATE ) $(PYTHON ) ; $(pythonw ) hapiplot_demo.py
127- $(CONDA_ACTIVATE ) $(PYTHON ) ; $(pythonw ) test/test_hapiplot_visual.py
128-
129- # $(CONDA_ACTIVATE) $(PYTHON); $(PYTHON) hapiclient/autoplot/autoplot_test.py
130- # $(CONDA_ACTIVATE) $(PYTHON); $(PYTHON) hapiclient/gallery/gallery_test.py
133+ make anaconda3/envs/python-$(PYTHON ) -matplotlib-$(MATPLOTLIB ) MATPLOTLIB=$(MATPLOTLIB ) PYTHON=$(PYTHON )
134+ $(CONDA_ACTIVATE ) python-$(PYTHON ) -matplotlib-$(MATPLOTLIB ) ; $(pythonw ) hapiplot_demo.py
135+ $(CONDA_ACTIVATE ) python-$(PYTHON ) -matplotlib-$(MATPLOTLIB ) ; $(pythonw ) test/test_hapiplot_visual.py
131136 # jupyter-notebook ../client-python-notebooks/hapi_demo.ipynb
132137# ###############################################################################
133138
@@ -138,19 +143,23 @@ ifeq ($(shell uname -s),Darwin)
138143 CONDA_PKG=Miniconda3-latest-MacOSX-x86_64.sh
139144endif
140145
141- condaenv : ./anaconda3
142- # ifeq ($(shell uname -s),MINGW64_NT-10.0-18362)
146+ anaconda3/envs/python-$(PYTHON ) -matplotlib-$(MATPLOTLIB ) : anaconda3
143147ifeq ($(TRAVIS_OS_NAME ) ,windows)
144148 cp $(CONDA)/Library/bin/libcrypto-1_1-x64.* $(CONDA)/DLLs/
145149 cp $(CONDA)/Library/bin/libssl-1_1-x64.* $(CONDA)/DLLs/
146- $(CONDA)/Scripts/conda create -y --name $(PYTHON) python=$(PYTHON_VER )
150+ $(CONDA)/Scripts/conda create -y --name python- $(PYTHON)-matplotlib-$(MATPLOTLIB) python=$(PYTHON )
147151else
148152 $(CONDA_ACTIVATE); \
149- $(CONDA)/bin/conda create -y --name $(PYTHON) python=$(PYTHON_VER )
153+ $(CONDA)/bin/conda create -y --name python- $(PYTHON)-matplotlib-$(MATPLOTLIB) python=$(PYTHON )
150154endif
155+ $(CONDA_ACTIVATE) python-$(PYTHON)-matplotlib-$(MATPLOTLIB) && pip install matplotlib=="$(MATPLOTLIB).*"
156+ @ $(CONDA_ACTIVATE) python-$(PYTHON)-matplotlib-$(MATPLOTLIB) && python$(PYTHON) setup.py develop | grep "Best"
157+ # Not sure why the install of pytest is needed given it is in setup.py, but I get pytest install errors otherwise.
158+ # Note that pillow==8 is needed for Python 3.6. Ideally this would be set in setup.py.
159+ # @ $(CONDA_ACTIVATE) python-$(PYTHON)-matplotlib-$(MATPLOTLIB) && pip install pytest; pip install .
151160
152- ./ anaconda3 : /tmp/$(CONDA_PKG )
153- bash /tmp/$(CONDA_PKG ) -b -p $(CONDA )
161+ anaconda3 : /tmp/$(CONDA_PKG )
162+ test -d anaconda3 || bash /tmp/$(CONDA_PKG ) -b -p $(CONDA )
154163
155164/tmp/$(CONDA_PKG ) :
156165 curl https://repo.anaconda.com/miniconda/$(CONDA_PKG ) > /tmp/$(CONDA_PKG )
@@ -160,6 +169,7 @@ endif
160169venv-test :
161170 cp hapiplot_demo.py /tmp # TODO: Explain why needed.
162171 source env-$(PYTHON ) /bin/activate && \
172+ pip install pytest ipython && \
163173 pip uninstall -y hapiplot && \
164174 pip install --pre ' $(PACKAGE)' \
165175 --index-url $(URL ) /simple \
@@ -175,15 +185,10 @@ package:
175185 make version-update
176186 python setup.py sdist
177187
178- package-test-all :
179- @ for version in $( PYTHONVERS) ; do \
180- make repository-test-plots PYTHON=$$ version ; \
181- done
182-
183188env-$(PYTHON ) :
184- $(CONDA_ACTIVATE ) $(PYTHON ) ; \
189+ $(CONDA_ACTIVATE ) python- $(PYTHON ) -matplotlib- $( MATPLOTLIB ); \
185190 conda install -y virtualenv; \
186- $(PYTHON ) -m virtualenv env-$(PYTHON )
191+ python $(PYTHON ) -m virtualenv env-$(PYTHON )
187192
188193package-test :
189194 make package
@@ -205,13 +210,13 @@ release-upload:
205210 && echo Uploaded to $(subst upload.,,$(URL ) ) /project/hapiplot/
206211
207212release-test-all :
208- @ for version in $( PYTHONVERS ) ; do \
213+ @ for version in $( PYTHONS ) ; do \
209214 make release-test PYTHON=$$ version ; \
210215 done
211216
212217release-test :
213218 rm -rf env
214- $(CONDA_ACTIVATE ) $(PYTHON ) ; pip install virtualenv; $(PYTHON ) -m virtualenv env
219+ $(CONDA_ACTIVATE ) $(PYTHON ) -matplotlib- $( MATPLOTLIB ) ; pip install virtualenv; python $(PYTHON ) -m virtualenv env
215220 make venv-test PACKAGE=' hapiplot==$(VERSION)'
216221# ###############################################################################
217222
@@ -231,7 +236,7 @@ version-tag:
231236# Install package in local directory (symlinks made to local dir)
232237install-local :
233238 # python setup.py -e .
234- $(CONDA_ACTIVATE ) $(PYTHON ) ; pip install --editable .
239+ $(CONDA_ACTIVATE ) $(PYTHON ) -matplotlib- $( MATPLOTLIB ) ; pip install --editable .
235240
236241install :
237242 pip install ' hapiplot==$(VERSION)' --index-url $(URL ) /simple
0 commit comments