Skip to content

Commit dc2460b

Browse files
committed
Canonical use of environment variables
1 parent 1c17f88 commit dc2460b

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

.github/workflows/cd-wheel.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ jobs:
164164
bash {project}/cibw-patch-cmd.sh
165165
CIBW_TEST_COMMAND: >-
166166
bash {project}/cibw-check-mpi.sh
167-
CIBW_ENVIRONMENT_PASS: >-
168-
MPINAME RELEASE
169167
CIBW_ENVIRONMENT_LINUX: >-
170168
SOURCE="/project/package/source"
171169
WORKDIR="/project/package/workdir"
@@ -189,8 +187,9 @@ jobs:
189187
- id: upload
190188
uses: actions/upload-artifact@v4
191189
with:
192-
name: "wheel-${{ inputs.mpiname }}-\
193-
${{ inputs.version || 'latest' }}-\
190+
name: "wheel-\
191+
${{ steps.bootstrap.outputs.mpiname }}-\
192+
${{ steps.bootstrap.outputs.version }}-\
194193
${{ matrix.os }}-${{ matrix.arch }}"
195194
path: wheelhouse/*.whl
196195

@@ -202,7 +201,9 @@ jobs:
202201
# ./wheel-test.sh
203202
test $(uname) = Linux && runner=(
204203
docker run
205-
-e MPINAME=${{ inputs.mpiname }}
204+
-e MPINAME=${{ steps.bootstrap.outputs.mpiname }}
205+
-e VERSION=${{ steps.bootstrap.outputs.version }}
206+
-e RELEASE=${{ steps.bootstrap.outputs.release }}
206207
-v $(pwd):/${{ github.workspace }}
207208
-w ${{ github.workspace }}
208209
--platform linux/${{

bootstrap.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ case "$mpiname" in
77
openmpi) version=5.0.7 ;;
88
esac
99
version=${VERSION:-$version}
10+
release=${RELEASE:-}
1011

1112
ucxversion=1.18.0
1213
ofiversion=1.22.0
@@ -73,11 +74,13 @@ if test ! -d "$SOURCE"; then
7374
echo writing package metadata ...
7475
echo "Name: $mpiname" > "$PACKAGE/METADATA"
7576
echo "Version: $version" >> "$PACKAGE/METADATA"
77+
echo "Release: $release" >> "$PACKAGE/METADATA"
7678
else
7779
echo reusing directory "$SOURCE"...
7880
check() { test "$(awk "/$1/"'{print $2}' "$PACKAGE/METADATA")" = "$2"; }
79-
check Name "$mpiname" || (echo not "$mpiname-$version"!!! && exit 1)
80-
check Version "$version" || (echo not "$mpiname-$version"!!! && exit 1)
81+
check Name "$mpiname" || (echo "error: mpiname!=$mpiname" && exit 1)
82+
check Version "$version" || (echo "error: version!=$version" && exit 1)
83+
check Release "$release" || (echo "error: release!=$release" && exit 1)
8184
fi
8285

8386
if test "$(uname)" = "Linux"; then
@@ -188,3 +191,9 @@ for license in "${otherlicenses[@]}"; do
188191
echo copying "$module" license file...
189192
cp "$license" "$PACKAGE/LICENSE.$module"
190193
done
194+
195+
if test -n "${GITHUB_OUTPUT+x}"; then
196+
echo "mpiname=${mpiname}" >> $GITHUB_OUTPUT
197+
echo "version=${version}" >> $GITHUB_OUTPUT
198+
echo "release=${release}" >> $GITHUB_OUTPUT
199+
fi

cibw-check-mpi.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
mpiname="${MPINAME:-mpich}"
5-
case "$mpiname" in
6-
mpich) version=$(mpichversion --version | cut -d':' -f 2) ;;
7-
openmpi) version=$(ompi_info --version | head -n 1 | cut -d'v' -f 2) ;;
8-
esac
4+
if command -v mpichversion > /dev/null; then
5+
mpiname=mpich
6+
version=$(mpichversion --version | cut -d':' -f 2)
7+
elif command -v ompi_info > /dev/null; then
8+
mpiname=openmpi
9+
version=$(ompi_info --version | head -n 1 | cut -d'v' -f 2)
10+
fi
911

1012
tempdir="$(mktemp -d)"
1113
trap 'rm -rf $tempdir' EXIT

package/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ def get_tag(self):
2424
metadata = re.search(r"""
2525
Name:\s*(?P<name>.*)\n
2626
Version:\s*(?P<version>.*)\n
27+
Release:\s*(?P<release>.*)\n
2728
""", fobj.read(), re.VERBOSE).groupdict()
2829

2930
mpiname = metadata["name"]
3031
version = metadata["version"]
31-
release = os.environ.get("RELEASE", "")
32+
release = metadata["release"]
3233
if release:
3334
version += f".post{release}"
3435

wheel-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export CIBW_ARCHS=$ARCHLIST
1616
export CIBW_BEFORE_ALL='bash {project}/cibw-build-mpi.sh'
1717
export CIBW_BEFORE_BUILD='bash {project}/cibw-patch-cmd.sh'
1818
export CIBW_TEST_COMMAND='bash {project}/cibw-check-mpi.sh'
19-
export CIBW_ENVIRONMENT_PASS='MPINAME RELEASE SOURCE WORKDIR DESTDIR'
19+
export CIBW_ENVIRONMENT_PASS='SOURCE WORKDIR DESTDIR'
2020
export CIBW_MANYLINUX_AARCH64_IMAGE=manylinux2014
2121
export CIBW_MANYLINUX_X86_64_IMAGE=manylinux2014
2222

0 commit comments

Comments
 (0)