Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3f9f9d2
New requirements directory.
trexfeathers Sep 29, 2020
21a7621
CI-specific conda environment files, in line with SciTools/iris#3812.
trexfeathers Sep 29, 2020
7f50e64
iris-grib.yml symlink file to aid in developer env setup.
trexfeathers Sep 29, 2020
b6a5183
PyPi improvements in line with SciTools/iris#3812.
trexfeathers Sep 29, 2020
92422d9
Test against latest Iris instead of latest Iris release.
trexfeathers Sep 29, 2020
e588c43
Added setup requirements.
trexfeathers Sep 30, 2020
45718b6
Enable testing against latest OR released Iris.
trexfeathers Sep 30, 2020
e3dcbc8
Requirements readthedocs symlink.
trexfeathers Sep 30, 2020
d4cf33d
Travis consistent double quotes.
trexfeathers Sep 30, 2020
64eedb7
Corrected setup README link.
trexfeathers Sep 30, 2020
0a63bb0
Iris location fix.
trexfeathers Sep 30, 2020
adc972f
Iris location fix.
trexfeathers Sep 30, 2020
75389f0
Iris location env variable $.
trexfeathers Sep 30, 2020
9d695a2
Iris dir env variable $.
trexfeathers Sep 30, 2020
b626247
Travis Iris location subdirectory.
trexfeathers Sep 30, 2020
e52eadf
Correct iris-grib directory.
trexfeathers Sep 30, 2020
c27c22f
Add debug to travis.
pp-mo Sep 30, 2020
7508a2e
fix
pp-mo Sep 30, 2020
df1d0ba
more paths, less debug
pp-mo Sep 30, 2020
f72d903
Fix 'setup.py test' operation.
pp-mo Sep 30, 2020
7765478
Avoid cd error in iris-grib install section.
pp-mo Sep 30, 2020
e9c0c83
Debug build dir.
pp-mo Sep 30, 2020
af99e06
More debug.
pp-mo Sep 30, 2020
1c838c6
Fix typo in travis.yml.
pp-mo Sep 30, 2020
d4889e0
Fix iris test-data path in site.cfg, and remove unused docs path.
pp-mo Sep 30, 2020
9821c2b
Debug iris-test-data and site.cfg.
pp-mo Sep 30, 2020
76f1529
Fix iris-test-data path.
pp-mo Sep 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 93 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,128 @@ dist: xenial

env:
matrix:
- PYTHON_VERSION=3.6
- PYTHON_VERSION=3.7
- PYTHON_VERSION=36 LIMIT_TO_RELEASED_IRIS=false
- PYTHON_VERSION=36 LIMIT_TO_RELEASED_IRIS=true
- PYTHON_VERSION=37 LIMIT_TO_RELEASED_IRIS=false
- PYTHON_VERSION=37 LIMIT_TO_RELEASED_IRIS=true

install:
- >
echo "==== STARTING TRAVIS.TML ====";
echo " path \$HOME=$HOME";
echo " path cwd=$(pwd)";
echo " path \$TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR";
echo "";
echo "ls \$TRAVIS_BUILD_DIR :";
ls -1ld $TRAVIS_BUILD_DIR/*;
echo "";

# - set -x;

# Download iris-test-data
# -----------------------------------
- >
export IRIS_TEST_DATA_REF="https://github.com/SciTools/iris-test-data/archive/master.zip";
export IRIS_TEST_DATA_DOWNLOAD="${HOME}/iris-test-data";
mkdir ${IRIS_TEST_DATA_DOWNLOAD};
wget -O ${IRIS_TEST_DATA_DOWNLOAD}/iris-test-data.zip ${IRIS_TEST_DATA_REF};
unzip -q ${IRIS_TEST_DATA_DOWNLOAD}/iris-test-data.zip -d ${IRIS_TEST_DATA_DOWNLOAD};
export IRIS_TEST_DATA_PATH=${IRIS_TEST_DATA_DOWNLOAD}/iris-test-data-master/test_data

# Install miniconda
# -----------------
- >
echo "Installing miniconda";
export CONDA_BASE="https://repo.continuum.io/miniconda/Miniconda";
if [[ "${PYTHON_VERSION}" == 2* ]]; then
wget --quiet ${CONDA_BASE}2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget --quiet ${CONDA_BASE}3-latest-Linux-x86_64.sh -O miniconda.sh;
fi;
wget --quiet ${CONDA_BASE}3-latest-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -p ${HOME}/miniconda;
export PATH="${HOME}/miniconda/bin:${PATH}";

# Configure the test environment
# ------------------------------
# Create the test environment
# ---------------------------
- >
echo "Configuring testing environment";
echo "Creating testing environment";
conda config --set always_yes yes --set changeps1 no;
conda config --set show_channel_urls True;
conda config --add channels conda-forge;
conda update --quiet conda;
ENV_NAME='test-environment';
conda create --quiet -n ${ENV_NAME} python=${PYTHON_VERSION} mock filelock pep8;

# Get environment spec.
- >
export ENV_NAME="iris-grib-dev";
export ENV_FILE="${TRAVIS_BUILD_DIR}/requirements/ci/py${PYTHON_VERSION}.yml";

# Optionally download latest Iris from repo,
# and replace the Iris dependency with Iris' underlying dependencies.
- >
if [[ "${LIMIT_TO_RELEASED_IRIS}" == false ]]; then
IRIS_REF="https://github.com/SciTools/iris/archive/master.zip";
export IRIS_LOCATION="${HOME}/iris";
mkdir ${IRIS_LOCATION};
wget -O ${IRIS_LOCATION}/iris.zip ${IRIS_REF};
unzip -q ${IRIS_LOCATION}/iris.zip -d ${IRIS_LOCATION};

IRIS_ENV_FILE="${IRIS_LOCATION}/iris-master/requirements/ci/py${PYTHON_VERSION}.yml";
sed -i "/- iris/d" ${ENV_FILE};
echo "# IRIS DEPENDENCIES." >> ${ENV_FILE};
sed -ne "/dependencies:/,$ p" ${IRIS_ENV_FILE} | sed "1d" >> ${ENV_FILE};
fi;

# Create environment.
- >
conda env create --quiet --file=${ENV_FILE};
source activate ${ENV_NAME};

# Customise the test environment
# ------------------------------
# Check installation of eccodes.
- python -m eccodes selfcheck;

# Install pip, then coveralls.
- conda install --quiet pip;
- pip install coveralls;

# Output environment debug info.
- >
conda env update -n ${ENV_NAME} --quiet --file environment.yml;
# Check installation of eccodes.
python -m eccodes selfcheck;
conda list -n ${ENV_NAME};
conda info -a;

# Download and install iris-test-data
# -----------------------------------
# Configure Iris
# --------------
- echo "Configuring Iris";

# Optionally install latest Iris from downloaded source.
- >
export IRIS_TEST_DATA_REF="https://github.com/SciTools/iris-test-data/archive/master.zip";
export IRIS_TEST_DATA_LOCATION="${HOME}/iris-test-data";
mkdir ${IRIS_TEST_DATA_LOCATION};
wget -O ${IRIS_TEST_DATA_LOCATION}/iris-test-data.zip ${IRIS_TEST_DATA_REF};
unzip -q ${IRIS_TEST_DATA_LOCATION}/iris-test-data.zip -d ${IRIS_TEST_DATA_LOCATION};
if [[ "${LIMIT_TO_RELEASED_IRIS}" == false ]]; then
cd ${IRIS_LOCATION}/iris-master;
python setup.py --quiet install;
fi;

# Locate iris installation
# ------------------------
# Locate Iris installation.
- export IRIS_DIR=$(python -c "import iris; import os.path; print(os.path.dirname(iris.__file__))")

# Poke site.cfg to reference iris-test-data
# Set iris config paths.
- >
export PREFIX="${HOME}/miniconda/envs/${ENV_NAME}";
SITE_CFG="${IRIS_DIR}/etc/site.cfg";
echo "[Resources]" > ${SITE_CFG};
echo "test_data_dir = ${IRIS_TEST_DATA_LOCATION}/iris-test-data-master/test_data" >> ${SITE_CFG};
echo "test_data_dir = ${IRIS_TEST_DATA_PATH}" >> ${SITE_CFG};
echo "[System]" >> ${SITE_CFG};
echo "udunits2_path = ${PREFIX}/lib/libudunits2.so" >> ${SITE_CFG};
echo "";
echo "SITE.CFG CONTENT:";
cat ${SITE_CFG};
echo "";
echo "TEST DATA DIR : $\IRIS_TEST_DATA_PATH=${IRIS_TEST_DATA_PATH}";
echo "Content : ls -1ld \$IRIS_TEST_DATA_PATH/* : ";
ls -1ld ${IRIS_TEST_DATA_PATH}/*;
echo "";

# Install iris-grib itself
# ------------------------
- pip install . --no-deps

# Install coveralls for test coverage
# -----------------------------------
- pip install coveralls
- >
echo "Installing Iris-grib.";
cd ${TRAVIS_BUILD_DIR};
ls -1ld *;
pip install . --no-deps;

# Summarise the environment
# -------------------------
Expand Down
7 changes: 0 additions & 7 deletions environment.yml

This file was deleted.

2 changes: 1 addition & 1 deletion readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
conda:
file: environment.yml
file: requirements/ci/readthedocs.yml
3 changes: 3 additions & 0 deletions requirements/all.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Optional dependencies.

mo_pack
1 change: 1 addition & 0 deletions requirements/ci/iris-grib.yml
22 changes: 22 additions & 0 deletions requirements/ci/py36.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: iris-grib-dev

channels:
- conda-forge

dependencies:
- python=3.6

# Setup dependencies.
- setuptools

# Core dependencies.
- iris>=2.4
- python-eccodes

# Optional dependencies.
- mo_pack

# Test dependencies.
- mock
- filelock
- pep8
22 changes: 22 additions & 0 deletions requirements/ci/py37.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: iris-grib-dev

channels:
- conda-forge

dependencies:
- python=3.7

# Setup dependencies.
- setuptools

# Core dependencies.
- iris>=2.4
- python-eccodes

# Optional dependencies.
- mo_pack

# Test dependencies.
- mock
- filelock
- pep8
1 change: 1 addition & 0 deletions requirements/ci/readthedocs.yml
4 changes: 4 additions & 0 deletions requirements/core.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Core dependencies.

scitools-iris>=2.4
eccodes-python
4 changes: 4 additions & 0 deletions requirements/setup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Dependencies necessary to run setup.py of iris-grib
# ---------------------------------------------------

setuptools
5 changes: 5 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Test dependencies.

mock
filelock
pep8
78 changes: 47 additions & 31 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,59 @@

import os
import os.path
import sys
from setuptools import setup
import textwrap


name = 'iris_grib'


LONG_DESCRIPTION = textwrap.dedent("""
Iris loading of GRIB files
==========================

With this package, iris is able to load GRIB files:

```
my_data = iris.load(path_to_grib_file)
```
""")


here = os.path.abspath(os.path.dirname(__file__))
pkg_root = os.path.join(here, name)
NAME = 'iris_grib'
PYPI_NAME = 'iris-grib'
PACKAGE_DIR = os.path.abspath(os.path.dirname(__file__))
PACKAGE_ROOT = os.path.join(PACKAGE_DIR, NAME)

packages = []
for d, _, _ in os.walk(os.path.join(here, name)):
for d, _, _ in os.walk(os.path.join(PACKAGE_DIR, NAME)):
if os.path.exists(os.path.join(d, '__init__.py')):
packages.append(d[len(here)+1:].replace(os.path.sep, '.'))
packages.append(d[len(PACKAGE_DIR) + 1:].replace(os.path.sep, '.'))


def pip_requirements(*args):
requirements = []
for name in args:
fname = os.path.join(
PACKAGE_DIR, "requirements", "{}.txt".format(name)
)
if not os.path.exists(fname):
emsg = (
f"Unable to find the {name!r} requirements file at {fname!r}"
)
raise RuntimeError(emsg)
with open(fname, "r") as fh:
for line in fh:
line = line.strip()
if not line or line.startswith("#"):
continue
requirements.append(line)
return requirements


def extract_version():
version = None
fdir = os.path.dirname(__file__)
fnme = os.path.join(fdir, 'iris_grib', '__init__.py')
with open(fnme) as fd:
for line in fd:
fname = os.path.join(PACKAGE_DIR, 'iris_grib', '__init__.py')
with open(fname) as fi:
for line in fi:
if (line.startswith('__version__')):
_, version = line.split('=')
version = version.strip()[1:-1] # Remove quotation characters
version = version.strip()[1:-1] # Remove quotations
break
return version


def long_description():
fname = os.path.join(PACKAGE_DIR, "README.rst")
with open(fname, "rb") as fi:
result = fi.read().decode("utf-8")
return result


def file_walk_relative(top, remove=''):
"""
Returns a generator of files from the top of the tree, removing
Expand All @@ -58,13 +69,14 @@ def file_walk_relative(top, remove=''):


setup_args = dict(
name = name,
name = PYPI_NAME,
version = extract_version(),
packages = packages,
package_data = {'iris_grib': list(file_walk_relative('iris_grib/tests/results',
remove='iris_grib/'))},
description = "GRIB loading for Iris",
long_description = LONG_DESCRIPTION,
long_description = long_description(),
long_description_content_type = "text/x-rst",
url = 'https://github.com/SciTools/iris-grib',
author = 'UK Met Office',
author_email = 'scitools-iris@googlegroups.com',
Expand All @@ -78,10 +90,14 @@ def file_walk_relative(top, remove=''):
'Programming Language :: Python :: 3 :: Only',
],
# NOTE: The Python 3 bindings to eccodes (eccodes-python) is available on
# PyPI, but the user is required to install eccodes itself manually. See
# PyPI, but the user is required to install eccodes itself manually. See
# ECMWF ecCodes installation documentation for more information.
install_requires=['scitools-iris>=2.4.*'] + ['eccodes-python'],
test_suite = 'iris_grib.tests',
install_requires=pip_requirements("setup", "core"),
test_suite = f'{NAME}.tests',
extras_require={
"all": pip_requirements("all"),
"test": pip_requirements("test"),
},
)


Expand Down