1- # Test hapi() data read functions using repository code :
1+ # Test in Conda virtual environments (to be deprecated) :
22# make repository-test PYTHON=_PYTHON_ # Test using _PYTHON_ (e.g, python3.6)
33# make repository-test-all # Test on all versions in $(PYTHONVERS) var below
44#
5+ # Test using tox (See also README.md for additional instructions):
6+ # tox
7+ #
58# Beta releases:
6- # 1. Run make repository-test-all
9+ # 1. tox
10+ # 2. make repository-test-all # (To be deprecated)
711# 2. For non-doc/formatting changes, update version in CHANGES.txt.
812# 3. run `make version-update` if version changed in CHANGES.txt.
913# 4. Commit and push
@@ -45,24 +49,30 @@ PYTHON=python3.8
4549PYTHON_VER =$(subst python,,$(PYTHON ) )
4650
4751# Python versions to test
48- PYTHONVERS =python3.13 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5
52+ PYTHONVERS =python3.14 python3. 13 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python3.6
4953
5054# VERSION is updated in "make version-update" step and derived
5155# from CHANGES.txt. Do not edit.
5256VERSION =0.2.7b1
5357SHELL: = /bin/bash
54- # SHELL:= /c/Windows/system32/cmd
5558
5659LONG_TESTS =false
5760
58- CONDA =$(PWD ) /anaconda3
61+ CONDA =$(CURDIR ) /anaconda3
5962
6063ifeq ($(OS ) ,Windows_NT)
61- CONDA=C:/Users/weigel/git/client-python/anaconda3
62- TMP=tmp/
64+ CONDA=$(CURDIR)/anaconda3
6365endif
66+ # TOS1=conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
67+ # TOS2=conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
6468CONDA_ACTIVATE =source $(CONDA ) /etc/profile.d/conda.sh; conda activate
6569
70+ ifeq ($(OS ) ,Windows_NT)
71+ CONDA_RUN=$(CONDA)/Scripts/conda.exe run -n $(PYTHON)
72+ else
73+ CONDA_RUN=$(CONDA_ACTIVATE) $(PYTHON);
74+ endif
75+
6676# ###############################################################################
6777install : $(CONDA ) /envs/$(PYTHON )
6878 $(CONDA_ACTIVATE ) $(PYTHON ) ; pip install --editable .
@@ -73,26 +83,6 @@ install: $(CONDA)/envs/$(PYTHON)
7383test :
7484 make repository-test-all
7585
76- # ###################################################################
77- # Tox notes
78- #
79- # Ideally local tests would use same commands as .tox.ini and .travis.yml.
80- #
81- # To use tox -e short-test, it seems we need to install and activate
82- # each version of python. So using tox locally does not seem to make
83- # things much simpler than `make repository-test`, which installs
84- # conda and virtual enviornments and runs tests.
85- #
86- # However, Travis tests use tox-travis and it seems creation of
87- # virtual environment is done automatically.
88- #
89- # repository-test-all-tox:
90- # tox -e short-test
91- # repository-test-tox:
92- # # Does not work
93- # tox -e py$(subst .,,$(PYTHON_VER)) short-test
94- # ###################################################################
95-
9686# Test contents in repository using different Python versions
9787repository-test-all :
9888 @make clean
@@ -104,63 +94,86 @@ repository-test-all:
10494repository-test :
10595 @make clean
10696 make condaenv PYTHON=$(PYTHON )
107- $(CONDA_ACTIVATE ) $(PYTHON ) ; pip install pytest deepdiff; pip install .
97+ $(CONDA_RUN ) pip install pytest deepdiff
98+ $(CONDA_RUN ) pip install .
10899
109- ifeq (LONG_TESTS,true)
110- $(CONDA_ACTIVATE) $(PYTHON); python -m pytest --tb=short -v -m ' long' hapiclient/ test/test_hapi.py
100+ ifeq ($( LONG_TESTS ) ,true)
101+ $(CONDA_RUN) python -m pytest -m " long" test
111102else
112- $(CONDA_ACTIVATE) $(PYTHON); python -m pytest --tb=short -v -m 'short' hapiclient/ test/test_hapi.py
103+ $(CONDA_RUN) python -m pytest -m "not long" test
113104endif
114-
115- $(CONDA_ACTIVATE) $(PYTHON); python -m pytest -v hapiclient/test/test_chunking.py
116- $(CONDA_ACTIVATE) $(PYTHON); python -m pytest -v hapiclient/test/test_hapitime2datetime.py
117- $(CONDA_ACTIVATE) $(PYTHON); python -m pytest -v hapiclient/test/test_datetime2hapitime.py
118- $(CONDA_ACTIVATE) $(PYTHON); python -m pytest -v hapiclient/test/test_hapitime_reformat.py
119105# ###############################################################################
120106
121107# ###############################################################################
122108# Anaconda install
109+ ifeq ($(OS ) ,Windows_NT)
110+ CONDA_PKG =Miniconda3-latest-Windows-x86_64.exe
111+ CONDA_PKG_PATH =C:/tmp/$(CONDA_PKG )
112+ else
113+ UNAME_S: =$(shell uname -s)
114+ UNAME_M: =$(shell uname -m)
115+
116+ ifeq ($(UNAME_S ) ,Linux)
123117CONDA_PKG =Miniconda3-latest-Linux-x86_64.sh
124- CONDA_PKG_PATH =/tmp/$(CONDA_PKG )
125- ifeq ($(shell uname -s) ,Darwin)
126- CONDA_PKG=Miniconda3-latest-MacOSX-x86_64.sh
127- CONDA_PKG_PATH=/tmp/$(CONDA_PKG)
118+ ifeq ($(UNAME_M ) ,aarch64)
119+ CONDA_PKG =Miniconda3-latest-Linux-aarch64.sh
128120endif
129- ifeq ($(OS ) ,Windows_NT)
130- CONDA_PKG=Miniconda3-latest-Windows-x86_64.exe
131- CONDA_PKG_PATH=C:/tmp/$(CONDA_PKG)
121+ endif
122+
123+ ifeq ($(UNAME_S ) ,Darwin)
124+ CONDA_PKG =Miniconda3-latest-MacOSX-x86_64.sh
125+ ifeq ($(UNAME_M ) ,arm64)
126+ CONDA_PKG =Miniconda3-latest-MacOSX-arm64.sh
127+ endif
128+ endif
129+
130+ CONDA_PKG_PATH =/tmp/$(CONDA_PKG )
132131endif
133132
134133activate :
135134 @echo " On command line enter:"
136135 @echo " $( CONDA_ACTIVATE) $( PYTHON) "
137136
138137condaenv :
139- make $(CONDA ) /envs/$(PYTHON ) PYTHON=$(PYTHON )
138+ $( MAKE ) $(CONDA ) /envs/$(PYTHON ) PYTHON=$(PYTHON )
140139
141140$(CONDA ) /envs/$(PYTHON ) : $(CONDA )
142141ifeq ($(OS ) ,Windows_NT)
143- $(CONDA_ACTIVATE); \
144- $(CONDA)/Scripts/conda \
145- create -y --name $(PYTHON) python=$(PYTHON_VER)
142+ $(CONDA)/Scripts/conda.exe tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
143+ $(CONDA)/Scripts/conda.exe tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
144+ $(CONDA)/Scripts/conda.exe tos accept --override-channels --channel https://repo.anaconda.com/pkgs/msys2
145+ $(CONDA)/Scripts/conda.exe create -y --name $(PYTHON) python=$(PYTHON_VER)
146146else
147147 $(CONDA_ACTIVATE); \
148+ $(CONDA)/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main; \
149+ $(CONDA)/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r; \
148150 $(CONDA)/bin/conda \
149151 create -y --name $(PYTHON) python=$(PYTHON_VER)
150152endif
151153
152- $(CONDA ) : $(CONDA_PKG_PATH )
153154ifeq ($(OS ) ,Windows_NT)
154- # Not working; path is not set
155- # start "$(CONDA_PKG_PATH)" /S /D=$(CONDA)
156- echo "!!! Install miniconda3 into $(CONDA) manually by executing 'start $(PWD)/anaconda3'. Then re-execute make command."
157- exit 1
155+ $(CONDA ) :
156+ @powershell -NoProfile -Command " $$ ErrorActionPreference='Stop'; \
157+ $$ pkg = ' $(CONDA_PKG)' ; \
158+ if ([string]::IsNullOrWhiteSpace($$ pkg)) { $$ pkg = ' Miniconda3-latest-Windows-x86_64.exe' }; \
159+ $$ tempDir = [System.IO.Path]::GetTempPath(); \
160+ if ([string]::IsNullOrWhiteSpace($$ tempDir)) { $$ tempDir = ' C:\\Windows\\Temp' }; \
161+ New-Item -ItemType Directory -Force -Path $$ tempDir | Out-Null; \
162+ $$ installer = Join-Path $$ tempDir $$ pkg; \
163+ $$ url = ' https://repo.anaconda.com/miniconda/' + $$ pkg; \
164+ $$ condaExe = Join-Path ' $(CONDA)' ' Scripts/conda.exe' ; \
165+ if (Test-Path $$ condaExe) { exit 0 }; \
166+ if (! (Test-Path $$ installer)) { Invoke-WebRequest -Uri $$ url -OutFile $$ installer }; \
167+ $$ target = [System.IO.Path]::GetFullPath(' $(CONDA)' ).Replace(' /' ,' \\' ); \
168+ Start-Process -FilePath $$ installer -ArgumentList ' /InstallationType=JustMe' ,' /RegisterPython=0' ,' /AddToPath=0' ,' /S' ,(' /D=' + $$ target) -Wait -NoNewWindow; \
169+ if (! (Test-Path $$ condaExe)) { throw ' Miniconda install failed.' }"
158170else
171+ $(CONDA ) : $(CONDA_PKG_PATH )
159172 test -d anaconda3 || bash $(CONDA_PKG_PATH ) -b -p $(CONDA )
160- endif
161173
162174$(CONDA_PKG_PATH ) :
163- curl https://repo.anaconda.com/miniconda/$(CONDA_PKG ) > $(CONDA_PKG_PATH )
175+ curl -L -o $(CONDA_PKG_PATH ) https://repo.anaconda.com/miniconda/$(CONDA_PKG )
176+ endif
164177# ###############################################################################
165178
166179# ###############################################################################
@@ -265,17 +278,23 @@ test-clean:
265278# ###############################################################################
266279
267280clean :
268- - @find . -name __pycache__ | xargs rm -rf {}
269- - @find . -name * .pyc | xargs rm -rf {}
270- - @find . -name * .DS_Store | xargs rm -rf {}
271- - @find . -type d -name __pycache__ | xargs rm -rf {}
272- - @find . -name * .pyc | xargs rm -rf {}
281+
282+ ifeq ($(OS ) ,Windows_NT)
283+ - @powershell -NoProfile -Command "Get-ChildItem -Path . -Recurse -Directory -Filter '__pycache__' -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue"
284+ - @powershell -NoProfile -Command "Get-ChildItem -Path . -Recurse -File -Include '*.pyc','*.DS_Store' -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue"
285+ - @powershell -NoProfile -Command "Remove-Item -Path '*~' -Force -ErrorAction SilentlyContinue"
286+ - @powershell -NoProfile -Command "Remove-Item -Path '# *#' -Force -ErrorAction SilentlyContinue"
287+ - @powershell -NoProfile -Command "Remove-Item -Path 'env','dist','.pytest_cache','hapiclient.egg-info' -Recurse -Force -ErrorAction SilentlyContinue"
288+ - @powershell -NoProfile -Command "Remove-Item -Path '/c/tools/miniconda3/envs/python3.6/Scripts/wheel.exe*','/c/tools/miniconda3/envs/python3.6/vcruntime140.dll.*' -Force -ErrorAction SilentlyContinue"
289+ else
290+ - @find . -type d -name __pycache__ -exec rm -rf {} +
291+ - @find . -type f -name '*.pyc' -exec rm -f {} +
292+ - @find . -type f -name '*.DS_Store' -exec rm -f {} +
273293 - @rm -f *~
274294 - @rm -f \# *\#
275295 - @rm -rf env
276296 - @rm -rf dist
277297 - @rm -f MANIFEST
278298 - @rm -rf .pytest_cache/
279299 - @rm -rf hapiclient.egg-info/
280- - @rm -rf /c/tools/miniconda3/envs/python3.6/Scripts/wheel.exe*
281- - @rm -rf /c/tools/miniconda3/envs/python3.6/vcruntime140.dll.*
300+ endif
0 commit comments