Skip to content

Commit c538fcf

Browse files
bash: remove rose_init
1 parent d7d8439 commit c538fcf

File tree

13 files changed

+39
-120
lines changed

13 files changed

+39
-120
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
*.swp
33
etc/rose.conf
44
etc/opt
5-
lib/bash/rose_init_site
65
doc
76
venv
87
metomi_rose.egg-info

bin/rose

+10-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@
3737
if ${ROSE_DEBUG:-false}; then
3838
set -x
3939
fi
40-
# shellcheck source=lib/bash/rose_init
41-
# shellcheck source=lib/bash/rose_usage
42-
. rose_init
43-
rose_init
40+
set -eu
41+
42+
ROSE_NS=$(basename "$0")
43+
ROSE_LIB="$(dirname "$(python3 -c "import metomi.rose; print(metomi.rose.__file__)")")"
44+
ROSE_HOME_BIN=$(dirname "$(command -v rose)")
45+
ROSE_VERSION="$(python3 -c "import metomi.rose; print(metomi.rose.__version__)")"
46+
export ROSE_NS ROSE_LIB ROSE_HOME_BIN ROSE_VERSION
4447

4548
# Print actual command of a command alias
4649
get_alias() {
@@ -49,6 +52,7 @@ get_alias() {
4952
"$ROSE_HOME_BIN/$ROSE_NS-$NAME"
5053
}
5154

55+
5256
# Print help for a given utility
5357
help_util() {
5458
local NAME=$1
@@ -118,6 +122,8 @@ help|h|?|--help|-h)
118122
if (($# == 0)); then
119123
{
120124
print_version
125+
# shellcheck source=../metomi/rose/etc/lib/bash/rose_usage
126+
. "$(rose resource lib/bash/rose_usage)"
121127
rose_usage
122128
echo
123129
echo "$ROSE_NS provides the following utilities:"

bin/rose-mpi-launch

+11-7
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,13 @@
112112
# DIAGNOSTICS
113113
# Return 0 on success, 1 or exit code of the launcher program on failure.
114114
#-------------------------------------------------------------------------------
115-
# shellcheck source=lib/bash/rose_init
116-
. rose_init
117-
rose_init rose_log
115+
set -eu
116+
# shellcheck source=../metomi/rose/etc/lib/bash/rose_log
117+
. "$(rose resource lib/bash/rose_log)"
118+
# shellcheck source=../metomi/rose/etc/lib/bash/rose_usage
119+
. "$(rose resource lib/bash/rose_usage)"
120+
121+
ROSE_CMD="${ROSE_NS}-${ROSE_UTIL}"
118122

119123
# ------------------------------------------------------------------------------
120124
ROSE_COMMAND=
@@ -201,7 +205,7 @@ else
201205
fi
202206

203207
ROSE_LAUNCHER_LIST=${ROSE_LAUNCHER_LIST:-$( \
204-
rose config --default= "$ROSE_NS" launcher-list)}
208+
rose config --default= "$ROSE_CMD" launcher-list)}
205209
export NPROC=${NPROC:-1}
206210

207211
#-------------------------------------------------------------------------------
@@ -245,7 +249,7 @@ if [[ -n $ROSE_COMMAND_FILE ]]; then
245249
fi
246250
ROSE_LAUNCHER_FILEOPTS=${ROSE_LAUNCHER_FILEOPTS:-$( \
247251
rose config --default= \
248-
"$ROSE_NS" "launcher-fileopts.$ROSE_LAUNCHER_BASE")}
252+
"$ROSE_CMD" "launcher-fileopts.$ROSE_LAUNCHER_BASE")}
249253
eval "info 2 exec $ROSE_LAUNCHER $ROSE_LAUNCHER_FILEOPTS $*"
250254
eval "exec $ROSE_LAUNCHER $ROSE_LAUNCHER_FILEOPTS $*"
251255
else
@@ -256,9 +260,9 @@ else
256260
fi
257261
# Options
258262
ROSE_LAUNCHER_PREOPTS=${ROSE_LAUNCHER_PREOPTS:-$(rose config -E \
259-
--default= "$ROSE_NS" "launcher-preopts.$ROSE_LAUNCHER_BASE")}
263+
--default= "$ROSE_CMD" "launcher-preopts.$ROSE_LAUNCHER_BASE")}
260264
ROSE_LAUNCHER_POSTOPTS=${ROSE_LAUNCHER_POSTOPTS:-$(rose config -E \
261-
--default= "$ROSE_NS" "launcher-postopts.$ROSE_LAUNCHER_BASE")}
265+
--default= "$ROSE_CMD" "launcher-postopts.$ROSE_LAUNCHER_BASE")}
262266
else
263267
ROSE_LAUNCH_INNER=
264268
ROSE_LAUNCHER_PREOPTS=

bin/rose-tutorial

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
# Make a copy of one of the tutorial SUITE in the cylc-run directory.
3131
#
3232
#-------------------------------------------------------------------------------
33-
# shellcheck source=lib/bash/rose_init
34-
. rose_init
33+
set -eu
3534
mkdir -p "$HOME/cylc-run"
3635

3736
usage () {
@@ -86,7 +85,7 @@ fi
8685

8786
# Copy files.
8887
echo -n "Copying tutorial files to ${DIRECTORY} ... "
89-
rose_init 'rose_log'
88+
9089
mkdir -p "$(dirname "${DIRECTORY}")"
9190
if run rsync -rLptgoD "${ROSE_HOME}/etc/tutorial/$1/" "${DIRECTORY}" \
9291
--exclude='.validate'; then

etc/bin/rose-test-battery

+2-7
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,9 @@
4848
# SEE ALSO
4949
# * `prove(1)`
5050
#-------------------------------------------------------------------------------
51-
# shellcheck source=lib/bash/rose_init
52-
# shellcheck source=lib/bash/rose_log
53-
. rose_init
54-
. rose_log
55-
5651
set -eu
57-
58-
rose_init
52+
# shellcheck source=../../metomi/rose/etc/lib/bash/rose_log
53+
. "$(rose resource lib/bash/rose_log)"
5954

6055
# Move to folder in which prove command should be run.
6156
TESTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

lib/bash/rose_init

-55
This file was deleted.

lib/bash/rose_init_site.example

-30
This file was deleted.

lib/bash/rose_log metomi/rose/etc/lib/bash/rose_log

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# rose_log
2222
#
2323
# SYNOPSIS
24-
# . $ROSE_HOME/lib/bash/rose_log
24+
# . rose_log
2525
# info 1 "Hello world"
2626
# info 2 "Hello world"
2727
# echo "Hello world" | out

lib/bash/rose_usage metomi/rose/etc/lib/bash/rose_usage

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# rose_usage
2222
#
2323
# SYNOPSIS
24-
# . $ROSE_HOME/lib/bash/rose_usage
24+
# . $rose_usage
2525
# rose_usage [CODE]
2626
#
2727
# DESCRIPTION

metomi/rose/opt_parse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""Common option parser for Rose command utilities."""
1818

1919
from optparse import OptionParser
20-
import metomi.rose.resource
20+
import metomi.rose.resource
2121

2222

2323
class RoseOptionParser(OptionParser):

metomi/rose/resource.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, namespace=None, util=None, paths=None):
8080
self.namespace = namespace
8181
self.util = util
8282
if paths:
83-
self.paths = list(paths)
83+
self.paths = list(map(Path, paths))
8484
else:
8585
self.paths = [
8686
(ROSE_INSTALL_ROOT / 'etc') / self.get_util_name("-"),

setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ def find_version(*file_paths):
8484
version=find_version("metomi", "rose", "__init__.py"),
8585

8686
# Options
87-
scripts=glob(join("bin", "*"))
88-
+ glob(join("sbin", "*"))
89-
+ glob(join("lib", "bash", "*")),
87+
scripts=(
88+
glob(join("bin", "*"))
89+
+ glob(join("sbin", "*"))
90+
),
9091
install_requires=INSTALL_REQUIRES,
9192
extras_require=EXTRAS_REQUIRE,
9293
tests_require=TESTS_REQUIRE,

sphinx/api/rose-bash-library.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
Rose Bash Library
22
=================
33

4-
The Rose bash library lives in ``lib/bash/``. To import a module, load the file
5-
into your script. E.g. To load ``rose_usage``, you would do::
4+
Rose includes some bash modules, they can be located by running::
65

7-
. lib/bash/rose_usage
6+
$ rose resource lib/bash
7+
8+
These modules can be invoked like so::
9+
10+
. "$(rose resource lib/bash/rose_log)"
811

912
The modules are:
1013

11-
``rose_init``
12-
Called by ``rose`` on initialisation. This is not meant to be for general
13-
use.
1414
``rose_log``
1515
Provide functions to print log messages.
1616
``rose_usage``

0 commit comments

Comments
 (0)