diff --git a/.github/workflows/build-conda.yml b/.github/workflows/build-conda.yml new file mode 100644 index 00000000..29ce6526 --- /dev/null +++ b/.github/workflows/build-conda.yml @@ -0,0 +1,54 @@ +name: Build and Test Linux/Windows/MacOSX + +on: + pull_request: + push: + branches: [master] + +jobs: + run: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [ "3.6", "3.7", "3.8", "3.9"] + os: [ubuntu-latest, windows-latest, macos-latest] + platform: [x64, x32] +# debug on a single os/platform/python version +# python-version: [ "3.9"] +# os: [ubuntu-latest] +# platform: [x64] + exclude: + - os: macos-latest + platform: x32 + - os: macos-latest + python-version: "3.6" + - os: windows-latest + python-version: "3.6" + steps: + - uses: actions/checkout@v2 + + - name: Setup Conda + uses: s-weigand/setup-conda@v1 + with: + activate-conda: false + conda-channels: conda-forge + + - name: Python ${{ matrix.python-version }} + shell: bash -l {0} + run: | + conda create --name TEST python=${{ matrix.python-version }} numpy cython pip pytest wheel pyproj eccodes --strict-channel-priority + source activate TEST + pip install -e . --no-deps --force-reinstall + conda info --all + conda list + + - name: Tests + shell: bash -l {0} + run: | + source activate TEST + #if [ "windows-latest" == "${{ matrix.os }}" ]; then + # export ECCODES_DEFINITION_PATH=$CONDA_PREFIX/Library/share/eccodes/definitions + #fi + cd test + python test.py + pytest -vv test_latlons.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d368561..0b6989ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,8 @@ jobs: PROJ_LIB: /usr/share/proj strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + #python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.9"] steps: - uses: actions/checkout@v2 @@ -53,8 +54,8 @@ jobs: python setup.py install - name: Test run: | - export MPLBACKEND=agg cd test + export MPLBACKEND=agg pytest test*py --mpl --mpl-baseline-path=baseline_images # if no mpl/cartopy run this #pytest test.py test_latlons.py diff --git a/Changelog b/Changelog index bb6cf81b..0349eee3 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -version 2.1.4 (not yet released) +version 2.1.4 (git tag v2.1.4rel)( ================================ * move conftest.py to test dir (so tests can be run from there) * add check-manifest test to github actions workflow. @@ -7,6 +7,7 @@ version 2.1.4 (not yet released) * add windows and macos x tests. * make sure gribmessage.__repr__ doesn't fail is shapeOfTheEarth parameter is missing (issue #177). +* move private eccodes dir inside 'share', so `import eccodes` doesn't import an empty package. version 2.1.3 (git tag v2.1.3rel) ================================ diff --git a/setup.py b/setup.py index 3c50a970..7578e338 100644 --- a/setup.py +++ b/setup.py @@ -31,16 +31,19 @@ def extract_version(CYTHON_FNAME): def package_files(directory): + owd = os.getcwd() + os.chdir(os.path.join('src','pygrib')) paths = [] for (path, directories, filenames) in os.walk(directory): for filename in filenames: - paths.append(os.path.join("..", path, filename)) + paths.append(os.path.join(path, filename)) + os.chdir(owd) return paths - -package_data = {} if os.environ.get("PYGRIB_WHEEL") is not None: - package_data[""] = package_files("eccodes") + package_data={'':package_files('share')} +else: + package_data={} cmdclass = {"build_ext": NumpyBuildExtCommand} diff --git a/src/pygrib/_pygrib.pyx b/src/pygrib/_pygrib.pyx index 864ac1eb..425d308a 100644 --- a/src/pygrib/_pygrib.pyx +++ b/src/pygrib/_pygrib.pyx @@ -262,14 +262,16 @@ def set_definitions_path(object eccodes_definition_path): if 'ECCODES_DEFINITION_PATH' in os.environ: _eccodes_datadir = os.environ['ECCODES_DEFINITION_PATH'] else: - _tmp_path = os.path.join('eccodes','definitions') - _definitions_path = os.path.join(os.path.join(os.path.dirname(__file__),'..'),_tmp_path) + # definitions at level of package dir + _tmp_path = os.path.join('share','eccodes','definitions') + _definitions_path = os.path.join(os.path.dirname(__file__),_tmp_path) # if definitions path exists inside pygrib installation (as it does when installed # via a binary wheel) tell eccodes to use internal eccodes definitions. if os.path.isdir(_definitions_path): _eccodes_datadir = os.sep.join([_definitions_path]) else: _eccodes_datadir = None + if _eccodes_datadir is not None: set_definitions_path(_eccodes_datadir) diff --git a/eccodes/template.3.32769.def b/src/pygrib/share/eccodes/template.3.32769.def similarity index 100% rename from eccodes/template.3.32769.def rename to src/pygrib/share/eccodes/template.3.32769.def diff --git a/test/test_gaussian.py b/test/test_gaussian.py index 8accf574..078f93a6 100644 --- a/test/test_gaussian.py +++ b/test/test_gaussian.py @@ -19,7 +19,7 @@ def test_gaussian(): fig = plt.figure() ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=0)) - ax.coastlines() + ax.coastlines(zorder=2) ax.contourf(lons,lats,data,15) # plot location of every 4th grid point plt.scatter(lons[::4,::4].ravel(),lats[::4,::4].ravel(),1,marker='o',color='k',zorder=10) diff --git a/test/test_reglatlon.py b/test/test_reglatlon.py index 9784c5e7..bfd11a40 100644 --- a/test/test_reglatlon.py +++ b/test/test_reglatlon.py @@ -22,7 +22,7 @@ def test_reglatlon1(): fig = plt.figure() ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=0)) - ax.coastlines() + ax.coastlines(zorder=2) ax.contourf(lons,lats,data,15,cmap=plt.cm.hot_r) plt.title('%s Global Lat/Lon Grid' % grb.name) return fig @@ -31,7 +31,7 @@ def test_reglatlon1(): def test_reglatlon2(): fig = plt.figure() ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=0)) - ax.coastlines() + ax.coastlines(zorder=2) ax.contourf(lons,lats,data2,15) plt.title('%s Global Lat/Lon Grid' % grb2.name) return fig @@ -44,7 +44,7 @@ def test_reglatlon3(): fig = plt.figure() ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=0)) ax.set_extent([lon1,lon2,lat1,lat2],crs=ccrs.PlateCarree()) - ax.coastlines() + ax.coastlines(zorder=2) ax.contourf(lonsubset,latsubset,datsubset,15,cmap=plt.cm.hot_r) plt.title('%s Regional Lat/Lon Grid' % grb.name) return fig