Skip to content

Commit

Permalink
Import @109242 2022.05.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Wardle committed May 6, 2022
1 parent 50cc6cb commit cce4b99
Show file tree
Hide file tree
Showing 15 changed files with 504 additions and 95 deletions.
43 changes: 24 additions & 19 deletions admin/install_mule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#
# Mule, UM packing extension and UM library installation script
#
# In most cases the modules can be directly installed via the usual
# python setuptools methods. However in some cases this might not be
# In most cases the modules can be directly installed via the usual
# python setuptools methods. However in some cases this might not be
# possible, so this script instead builds all modules to a dummy
# install location in a temporary directory and then copies the
# install location in a temporary directory and then copies the
# results to the chosen destinations.
#
set -eu
Expand Down Expand Up @@ -86,9 +86,9 @@ while [ $# -gt 3 ] ; do
SSTPERT_LIB=$1 ;;
--wafccb_lib) shift
WAFCCB_LIB=$1 ;;
--spiral_lib)
--spiral_lib)
SPIRAL_LIB="build" ;;
--ppibm_lib)
--ppibm_lib)
PPIBM_LIB="build" ;;
--library_lock)
LIBRARY_LOCK="lock" ;;
Expand Down Expand Up @@ -116,8 +116,13 @@ if [ -n "$PPIBM_LIB" ] ; then
MODULE_LIST="$MODULE_LIST um_ppibm"
fi

# A few hardcoded settings
PYTHONEXEC=${PYTHONEXEC:-python2.7}
# Find out the version of the current interpreter, since this is what we
# will be trying to install against
PYTHONVER=$(python -c "from platform import python_version ; print(python_version())")
PYTHONEXEC=python$(cut -d . -f-2 <<< $PYTHONVER)
echo "Installing against Python $PYTHONVER"

# Setup a temporary directory where the install will be initially created
SCRATCHDIR=$(mktemp -d)
SCRATCHLIB=$SCRATCHDIR/lib/$PYTHONEXEC/site-packages

Expand All @@ -129,7 +134,7 @@ if [ ! ${BIN_DEST:0:1} == "/" ] ; then
BIN_DEST=$PWD/$BIN_DEST
fi

# Create install directores - they may already exist but should be
# Create install directores - they may already exist but should be
# empty if they do, also check the modules exist in the cwd
exit=0
for module in $MODULE_LIST ; do
Expand Down Expand Up @@ -176,7 +181,7 @@ if [ -n "$WAFCCB_LIB" ] && [ ! -d $WAFCCB_LIB ] ; then
fi

# Make a temporary directory to hold the installs
mkdir -p $SCRATCHLIB
mkdir -p $SCRATCHLIB
ln -s $SCRATCHDIR/lib $SCRATCHDIR/lib64

# The install command will complain if this directory isn't on the path
Expand All @@ -196,7 +201,7 @@ wc_root=$(pwd)
# use ln -r for this or realpath but since they aren't as common as we'd
# like let's use Python
function pyrelpath(){
$PYTHONEXEC -c "import os.path; print(os.path.relpath(\"$1\",\"$2\"))"
python -c "import os.path; print(os.path.relpath(\"$1\",\"$2\"))"
}

# Packing library first
Expand All @@ -214,7 +219,7 @@ else
fi

echo "Building packing module..."
$PYTHONEXEC setup.py build_ext --inplace \
python setup.py build_ext --inplace \
-I$SHUMLIB/include -L$SHUMLIB/lib -R$rpath

# SSTPert library (if being used)
Expand All @@ -235,7 +240,7 @@ if [ -n "$SSTPERT_LIB" ] ; then
fi

echo "Building sstpert module..."
$PYTHONEXEC setup.py build_ext --inplace \
python setup.py build_ext --inplace \
-I$SSTPERT_LIB/include \
-L$SSTPERT_LIB/lib:$SHUMLIB/lib \
-R$rpath
Expand All @@ -257,7 +262,7 @@ if [ -n "$WAFCCB_LIB" ] ; then
fi

echo "Building wafccb module..."
$PYTHONEXEC setup.py build_ext --inplace \
python setup.py build_ext --inplace \
-I$WAFCCB_LIB/include \
-L$WAFCCB_LIB/lib \
-R$rpath
Expand All @@ -279,7 +284,7 @@ if [ -n "$SPIRAL_LIB" ] ; then
fi

echo "Building spiral search module..."
$PYTHONEXEC setup.py build_ext --inplace \
python setup.py build_ext --inplace \
-I$SHUMLIB/include \
-L$SHUMLIB/lib \
-R$rpath
Expand All @@ -301,7 +306,7 @@ if [ -n "$PPIBM_LIB" ] ; then
fi

echo "Building ppibm module..."
$PYTHONEXEC setup.py build_ext --inplace \
python setup.py build_ext --inplace \
-I$SHUMLIB/include \
-L$SHUMLIB/lib \
-R$rpath
Expand All @@ -316,7 +321,7 @@ function install(){
cd $wc_root/$module

echo "Installing $module module to $SCRATCHDIR"
$PYTHONEXEC setup.py install --prefix $SCRATCHDIR
python setup.py install --prefix $SCRATCHDIR
}

for module in $MODULE_LIST ; do
Expand All @@ -336,7 +341,7 @@ function unpack_and_copy(){
unzip_dir=$SCRATCHLIB/${module}_unzipped_egg
unzip $egg -d $unzip_dir
egg=$unzip_dir
fi
fi

destdir=$LIB_DEST/$module
echo "Installing $module to $destdir"
Expand All @@ -346,7 +351,7 @@ function unpack_and_copy(){
# For the execs, also copy these to the bin directory
if [ $module == "um_utils" ] || [ $module == "um_sstpert" ] ; then
echo "Installing $module execs and info to $BIN_DEST/"
cp -vr $egg/EGG-INFO $BIN_DEST/$module.egg-info
cp -vr $egg/EGG-INFO $BIN_DEST/$module.egg-info
cp -vr $SCRATCHDIR/bin/* $BIN_DEST/
fi
}
Expand All @@ -364,7 +369,7 @@ function cleanup(){
cd $wc_root/$module

echo "Cleaning $module module"
$PYTHONEXEC setup.py clean
python setup.py clean
}

for module in $MODULE_LIST ; do
Expand Down
2 changes: 1 addition & 1 deletion mule/LICENCE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!-------------------------------------------------------------------------------!
! (C) Crown Copyright 2020, Met Office. All rights reserved. !
! (C) Crown Copyright 2022, Met Office. All rights reserved. !
! !
! Redistribution and use in source and binary forms, with or without !
! modification, are permitted provided that the following conditions are met: !
Expand Down
6 changes: 3 additions & 3 deletions mule/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@

# General information about the project.
project = u'Mule'
copyright = u'2020, UM Systems Team'
copyright = u'2022, UM Systems Team'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2020.01.1'
version = '2022.05.1'
# The full version, including alpha/beta/rc tags.
release = '2020.01.1'
release = '2022.05.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion mule/lib/mule/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from contextlib import contextmanager
from mule.stashmaster import STASHmaster

__version__ = "2020.01.1"
__version__ = "2022.05.1"

# UM fixed length header names and positions
_UM_FIXED_LENGTH_HEADER = [
Expand Down
3 changes: 2 additions & 1 deletion mule/lib/mule/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def _wgdos_pack_field(data, mdi, acc):
packed byte data.
"""
data_bytes = mo_pack.compress_wgdos(data.astype("f4"), acc, mdi)
data_buffer = mo_pack.compress_wgdos(data.astype("f4"), acc, mdi)
data_bytes = data_buffer.tobytes()
return data_bytes

except ImportError as err:
Expand Down
25 changes: 11 additions & 14 deletions um_packing/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,23 @@ def run(self):
elif os.path.isdir(cleanpath[0]):
shutil.rmtree(cleanpath[0])


setuptools.setup(
name='um_packing',
version='2020.01.1',
version='2022.05.1',
description='Unified Model packing library extension',
author='UM Systems Team',
url='https://code.metoffice.gov.uk/trac/um',
cmdclass={'clean': CleanCommand},
package_dir={'': 'lib'},
packages=['um_packing',
'um_packing.tests'],
features={
'packing': setuptools.Feature(
"SHUMlib Packing library",
standard=True,
ext_modules=[
setuptools.Extension(
'um_packing.um_packing',
['lib/um_packing/um_packing.c'],
include_dirs=[np.get_include()],
libraries=["shum_byteswap",
"shum_wgdos_packing",
"shum_string_conv",
"shum_constants"])])})
ext_modules=[
setuptools.Extension(
'um_packing.um_packing',
['lib/um_packing/um_packing.c'],
include_dirs=[np.get_include()],
libraries=["shum_byteswap",
"shum_wgdos_packing",
"shum_string_conv",
"shum_constants"])])
22 changes: 9 additions & 13 deletions um_ppibm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,18 @@ def run(self):

setuptools.setup(
name='um_ppibm',
version='2020.01.1',
version='2022.05.1',
description='Unified Model pp conversion utility with IBM number format',
author='UM Systems Team',
url='https://code.metoffice.gov.uk/trac/um',
cmdclass={'clean': CleanCommand},
package_dir={'': 'lib'},
packages=['um_ppibm', ],
features={
'ieee2ibm32': setuptools.Feature(
"SHUMlib IBM conversion routine",
standard=True,
ext_modules=[
setuptools.Extension(
'um_ppibm.um_ieee2ibm32',
['lib/um_ppibm/um_ieee2ibm32.c'],
include_dirs=[np.get_include()],
libraries=["shum_string_conv",
"shum_byteswap",
"shum_data_conv"])])})
ext_modules=[
setuptools.Extension(
'um_ppibm.um_ieee2ibm32',
['lib/um_ppibm/um_ieee2ibm32.c'],
include_dirs=[np.get_include()],
libraries=["shum_string_conv",
"shum_byteswap",
"shum_data_conv"])])
25 changes: 11 additions & 14 deletions um_spiral_search/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,23 @@ def run(self):
elif os.path.isdir(cleanpath[0]):
shutil.rmtree(cleanpath[0])


setuptools.setup(
name='um_spiral_search',
version='2020.01.1',
version='2022.05.1',
description='Unified Model Spiral Search extension',
author='UM Systems Team',
url='https://code.metoffice.gov.uk/trac/um',
cmdclass={'clean': CleanCommand},
package_dir={'': 'lib'},
packages=['um_spiral_search',
'um_spiral_search.tests'],
features={
'spiralsearch': setuptools.Feature(
"UM Spiral Search library",
standard=True,
ext_modules=[
setuptools.Extension(
'um_spiral_search.um_spiral_search',
['lib/um_spiral_search/um_spiral_search.c'],
include_dirs=[np.get_include()],
libraries=["shum_spiral_search",
"shum_string_conv",
"shum_constants"])
])})
ext_modules=[
setuptools.Extension(
'um_spiral_search.um_spiral_search',
['lib/um_spiral_search/um_spiral_search.c'],
include_dirs=[np.get_include()],
libraries=["shum_spiral_search",
"shum_string_conv",
"shum_constants"])
])
24 changes: 10 additions & 14 deletions um_sstpert/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,24 @@ def run(self):
elif os.path.isdir(cleanpath[0]):
shutil.rmtree(cleanpath[0])


setuptools.setup(
name='um_sstpert',
version='2020.01.1',
version='2022.05.1',
description='Unified Model SST-perturbation extension and utility',
author='UM Systems Team',
url='https://code.metoffice.gov.uk/trac/um',
cmdclass={'clean': CleanCommand},
package_dir={'': 'lib'},
packages=['um_sstpert'],
features={
'sstpert': setuptools.Feature(
"UM SST-pert library (requires UM Licence)",
standard=True,
ext_modules=[
setuptools.Extension(
'um_sstpert.um_sstpert',
['lib/um_sstpert/um_sstpert.c'],
include_dirs=[np.get_include()],
libraries=["um_sstpert",
"shum_string_conv",
"shum_constants"])
])},
ext_modules=[
setuptools.Extension(
'um_sstpert.um_sstpert',
['lib/um_sstpert/um_sstpert.c'],
include_dirs=[np.get_include()],
libraries=["um_sstpert",
"shum_string_conv",
"shum_constants"])],
entry_points={
'console_scripts': [
'mule-sstpert = um_sstpert:_main',
Expand Down
2 changes: 1 addition & 1 deletion um_utils/docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This is the documentation for the UM utilities, which use the Mule API.
um_utils/version
um_utils/unpack
um_utils/convpp
um_utils/editmask

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

Loading

0 comments on commit cce4b99

Please sign in to comment.