Skip to content

Commit

Permalink
Merge pull request #7 from SWxTREC/windows_testing
Browse files Browse the repository at this point in the history
TST: Adding Windows GitHub Actions CI
  • Loading branch information
greglucas authored Sep 1, 2021
2 parents 6f8bff6 + 12b49bd commit 668f34f
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 11 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
os: [windows-latest, ubuntu-latest, macos-latest]
env:
FC: gfortran-9
F90: gfortran-9
CC: gcc-9
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v2

# Only on the Windows runner
- name: Add Windows environment settings
if: startsWith(matrix.os, 'windows')
run: |
echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
echo "FC=gfortran" >> $GITHUB_ENV
echo "F90=gfortran" >> $GITHUB_ENV
echo "CC=gcc" >> $GITHUB_ENV
- uses: actions/setup-python@v2
name: Install Python
with:
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,32 @@ jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
env:
FC: gfortran-9
F90: gfortran-9
CC: gcc-9
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v2

# Only on the Windows runner
- name: Add Windows environment settings
if: startsWith(matrix.os, 'windows')
run: |
echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
echo "FC=gfortran" >> $GITHUB_ENV
echo "F90=gfortran" >> $GITHUB_ENV
echo "CC=gcc" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -39,7 +53,9 @@ jobs:
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
pip install .
- name: Install pymsis
run: pip install -v .

- name: Lint with flake8
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/download_mirror.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This is only for CI downloading/testing."""
import os
import tarfile
import urllib.request

Expand All @@ -10,13 +11,13 @@

with urllib.request.urlopen(SOURCE_FILE) as stream:
tf = tarfile.open(fileobj=stream, mode="r|gz")
tf.extractall(path='src/msis2/')
tf.extractall(path=os.path.join('src', 'msis2', ''))

# MSIS-00 fortran file
MSIS00_FILE = ("https://gist.githubusercontent.com/greglucas/"
"6a545a4ccbfdb93290a96ad13a0b6f81/"
"raw/2c1f5d899d7b42392a6b19a041d2cc213589a5f1/"
"NRLMSISE-00.FOR")
with urllib.request.urlopen(MSIS00_FILE) as response:
with open('src/msis00/NRLMSISE-00.FOR', 'wb') as f:
with open(os.path.join('src', 'msis00', 'NRLMSISE-00.FOR'), 'wb') as f:
f.write(response.read())
26 changes: 25 additions & 1 deletion pymsis/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
__version__ = "0.2.0"
import os
__version__ = "0.2.1"

# If we are on Windows, Python 3.8+ then we need to add a DLL search path
# The libraries are located relative to this init file.
if os.name == 'nt':
pymsis_dir = None
pymsis_dir_libs = None
try:
# add folder to Windows DLL search paths
pymsis_dir = os.path.abspath(os.path.dirname(__file__))
pymsis_dir_libs = os.path.join(pymsis_dir, '.libs')
try:
# This was added in Python 3.8, so we can default to this
# once we only support 3.8+
os.add_dll_directory(pymsis_dir)
# Additionally, we need the .libs directory which has gfortran
os.add_dll_directory(pymsis_dir_libs)
except Exception:
pass
os.environ['PATH'] = (f"{pymsis_dir};{pymsis_dir_libs};"
f"{os.environ['PATH']}")
except Exception:
pass
del pymsis_dir, pymsis_dir_libs
3 changes: 2 additions & 1 deletion pymsis/msis.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,5 @@ def create_input(dates, lons, lats, alts, f107s, f107as, aps):
f107s[indices[:, 0]], f107as[indices[:, 0]]], -1)
# ap has 7 components, so we need to concatenate it onto the
# arrays rather than stack
return shape, np.concatenate([arr, aps[indices[:, 0], :]], axis=1)
return shape, np.concatenate([arr, aps[indices[:, 0], :]], axis=1,
dtype=np.float32)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
requires = [
"setuptools>=42",
"wheel",
"oldest-supported-numpy"
"numpy"
]

build-backend = "setuptools.build_meta"
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

# If you want to get some additional speed from compile-time options you can
# add extra compile-time flags. e.g., '-march=native', '-ffast-math'
# NOTE: -O1 seems to be required on Windows+Py39 CI systems, so we are setting
# that for everyone for now, but it should be investigated later.
ext_msis2 = Extension(name='pymsis.msis2f',
sources=msis2_sources,
extra_f90_compile_args=['-std=legacy'])
extra_f90_compile_args=['-std=legacy', '-O1'])

msis00_sources = [os.path.join('src', 'msis00', 'msis00.F90'),
os.path.join('src', 'msis00', 'NRLMSISE-00.FOR')]
Expand All @@ -38,7 +40,7 @@

requirements = ['numpy']

with open("README.rst", "r") as f:
with open("README.rst", "r", encoding='utf8', errors="ignore") as f:
long_description = f.read()

setup(
Expand Down
1 change: 0 additions & 1 deletion src/msis2/msis2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ subroutine pymsiscalc(day, utsec, lon, lat, z, sflux, sfluxavg, ap, output, n)
sflux(i), ap(i, :), output(i, 11), output(i, 1:10))
enddo

return
end subroutine pymsiscalc

0 comments on commit 668f34f

Please sign in to comment.