diff --git a/.appveyor.yml b/.appveyor.yml index 8b4cb86..c96fd63 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,6 +5,7 @@ image: stack: python 3 environment: + MINGW_DIR: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin PY_DIR: C:\Python37-x64 clone_depth: 3 @@ -12,9 +13,15 @@ clone_depth: 3 build: off init: +- cmd: set PATH=%MINGW_DIR%;%PATH% - cmd: set PATH=%PY_DIR%;%PY_DIR%\Scripts;%PATH% +- cmd: set CC=gcc -install: pip install -e .[tests,io] +install: +- cmd: mingw32-make -C rnxcmp +- sh: make -C rnxcmp + +- pip install -e .[tests,io] test_script: pytest -xrsv diff --git a/README.md b/README.md index 6827e50..8e5d27c 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,22 @@ If you need to use `.crx` Hatanaka compressed RINEX, compile the `crx2rnx` code make install -C rnxcmp ``` +#### Windows +Windows as usual is more difficult to compile code on. +For optional Hatanaka converter, here are some tips. + +> cc -O2 source/rnx2crx.c -o rnx2crx +process_begin: CreateProcess(NULL, cc -O2 source/rnx2crx.c -o rnx2crx, ...) failed. +make (e=2): The system cannot find the file specified. + +Assuming you have +[installed MinGW compiler on Windows](https://www.scivision.co/windows-gcc-gfortran-cmake-make-install/): +```posh +set CC=gcc +mingw32-make -C rnxcmp +``` + + ## Usage The simplest command-line use is through the top-level `ReadRinex` script. diff --git a/georinex/io.py b/georinex/io.py index decd667..2d59a85 100644 --- a/georinex/io.py +++ b/georinex/io.py @@ -58,12 +58,15 @@ def _opencrx(f: TextIO) -> str: Nbytes is used to read first line. """ exe = './crx2rnx' + shell = False if os.name == 'nt': exe = exe[2:] + shell = True + try: In = f.read() ret = subprocess.check_output([exe, '-'], input=In, - universal_newlines=True, cwd=R/'rnxcmp') + universal_newlines=True, cwd=R/'rnxcmp', shell=shell) except FileNotFoundError as e: raise FileNotFoundError(f'trouble converting Hatanka file, did you compile the crx2rnx program? {e}') diff --git a/setup.cfg b/setup.cfg index 5ef89ec..8071c3c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = georinex -version = 1.6.2 +version = 1.6.3 author = Michael Hirsch, Ph.D. description = Python RINEX 2/3 NAV/OBS reader with speed and simplicity. url = https://github.com/scivision/georinex diff --git a/tests/test_hatanaka.py b/tests/test_hatanaka.py index 28df63a..8617a9d 100644 --- a/tests/test_hatanaka.py +++ b/tests/test_hatanaka.py @@ -4,17 +4,26 @@ from pathlib import Path import georinex as gr from datetime import datetime -R = Path(__file__).parent +import os -try: - # capture_output is py >= 3.7 - ret = subprocess.run(['crx2rnx', '-h'], stderr=subprocess.PIPE, universal_newlines=True) # -h returncode == 1 +R = Path(__file__).parent +Rexe = Path(__file__).resolve().parents[1] / 'rnxcmp' +exe = './crx2rnx' +shell = False +if os.name == 'nt': + exe = exe[2:] + shell = True + +try: # capture_output is py >= 3.7 + ret = subprocess.run([exe, '-h'], stderr=subprocess.PIPE, + universal_newlines=True, cwd=Rexe, shell=shell) # -h returncode == 1 nocrx = False if ret.stderr.startswith('Usage') else True -except (FileNotFoundError, PermissionError): +except (FileNotFoundError, PermissionError) as e: + print(e) nocrx = True -@pytest.mark.skipif(nocrx, reason='crx2rnx not found') +@pytest.mark.skipif(nocrx, reason=f'crx2rnx not found in {Rexe}') @pytest.mark.timeout(30) def test_obs3(): fn = R / 'CEBR00ESP_R_20182000000_01D_30S_MO.crx.gz' diff --git a/tests/test_nav2.py b/tests/test_nav2.py index 6200f19..8b44473 100644 --- a/tests/test_nav2.py +++ b/tests/test_nav2.py @@ -10,6 +10,8 @@ def test_time(): + pytest.importorskip('unlzw') + times = gr.gettime(R/'ab422100.18n.Z').values.astype('datetime64[us]').astype(datetime) assert times[0] == datetime(2018, 7, 29, 1, 59, 44) @@ -17,6 +19,8 @@ def test_time(): def test_data(): + pytest.importorskip('unlzw') + nav = gr.load(R/'ab422100.18n.Z') nav0 = nav.sel(time='2018-07-29T03:59:44').dropna(dim='sv', how='all') @@ -43,6 +47,8 @@ def test_mangled(): def test_tlim(): + pytest.importorskip('unlzw') + nav = gr.load(R/'ceda2100.18e.Z', tlim=('2018-07-29T11', '2018-07-29T12')) times = nav.time.values.astype('datetime64[us]').astype(datetime) @@ -57,6 +63,8 @@ def test_tlim(): def test_galileo(): + pytest.importorskip('unlzw') + nav = gr.load(R/'ceda2100.18e.Z') E18 = nav.sel(sv='E18').dropna(dim='time', how='all') @@ -72,6 +80,8 @@ def test_galileo(): def test_gps(): + pytest.importorskip('unlzw') + nav = gr.load(R/'brdc2800.15n.Z') times = nav.time.values.astype('datetime64[us]').astype(datetime).tolist() diff --git a/tests/test_nav3.py b/tests/test_nav3.py index be2f979..7c8fad9 100644 --- a/tests/test_nav3.py +++ b/tests/test_nav3.py @@ -33,6 +33,8 @@ def test_tlim(): def test_qzss(): """./ReadRinex.py -q tests/qzss3.14n -o r3qzss.nc """ + pytest.importorskip('netCDF4') + truth = gr.load(R/'r3qzss.nc') nav = gr.load(R/'qzss3.14n') assert nav.equals(truth)