Repository navigation
Expand file tree
/
Copy pathdockcross-manylinux-download-cache.sh
More file actions
executable file
·140 lines (121 loc) · 5.05 KB
/
Copy pathdockcross-manylinux-download-cache.sh
File metadata and controls
executable file
·140 lines (121 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
########################################################################
# Download ITK build cache and other requirements to prepare for
# generating Linux Python wheels of the given ITK module.
#
# Most ITK modules will download and call `dockcross-manylinux-download-cache-and-build-module-wheels.sh` which will
# subsequently fetch and run this script for getting build artifacts.
# ITK modules with tailored build processes may instead directly fetch and run this script as part of their own
# custom build workflow. Examples include ITK GPU-based modules that require additional system configuration
# steps not present in `dockcross-manylinux-download-cache-and-build-module-wheels.sh`.
#
# ===========================================
# ENVIRONMENT VARIABLES
#
# `ITK_PACKAGE_VERSION`: Tag for ITKPythonBuilds build cache to use
# Examples: "v5.4.0", "v5.2.1.post1"
# See available tags at https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/tags
#
# `MANYLINUX_VERSION`: manylinux specialization used to build ITK for cache
# Examples: "_2_28", "2014", "_2_28_aarch64"
# See https://github.com/dockcross/dockcross
#
# `ITKPYTHONPACKAGE_TAG`: Tag for ITKPythonPackage build scripts to use.
# If ITKPYTHONPACKAGE_TAG is empty then the default scripts distributed
# with the ITKPythonBuilds archive will be used.
#
# `ITKPYTHONPACKAGE_ORG`: Github organization or user to use for ITKPythonPackage
# build script source. Default is InsightSoftwareConsortium.
# Ignored if ITKPYTHONPACKAGE_TAG is empty.
#
########################################################################
# -----------------------------------------------------------------------
# Script argument parsing
#
usage()
{
echo "Usage:
dockcross-manylinux-download-cache.sh
[ -h | --help ] show usage
[ python_version ] build wheel for a specific python version. (e.g. cp310)"
exit 2
}
FORWARD_ARGS=("$@") # Store arguments to forward them later
PARSED_ARGS=$(getopt -a -n dockcross-manylinux-download-cache-and-build-module-wheels \
-o hc:x: --long help,cmake_options:,exclude_libs: -- "$@")
eval set -- "$PARSED_ARGS"
while :
do
case "$1" in
-h | --help) usage; break ;;
--) shift; break ;;
*) echo "Unexpected option: $1.";
usage; break ;;
esac
done
# -----------------------------------------------------------------------
# Verify that unzstd binary is available to decompress ITK build archives.
unzstd_exe=`(which unzstd)`
if [[ -z ${unzstd_exe} ]]; then
echo "ERROR: can not find required binary 'unzstd' "
exit 255
fi
# Expect unzstd > v1.3.2, see discussion in `dockcross-manylinux-build-tarball.sh`
${unzstd_exe} --version
# -----------------------------------------------------------------------
# Fetch build archive
MANYLINUX_VERSION=${MANYLINUX_VERSION:=_2_28}
TARGET_ARCH=${TARGET_ARCH:=x64}
case ${TARGET_ARCH} in
x64)
TARBALL_SPECIALIZATION="-manylinux${MANYLINUX_VERSION}"
;;
*)
TARBALL_SPECIALIZATION="-manylinux${MANYLINUX_VERSION}_${TARGET_ARCH}"
;;
esac
TARBALL_NAME="ITKPythonBuilds-linux${TARBALL_SPECIALIZATION}.tar"
if [[ ! -f ${TARBALL_NAME}.zst ]]; then
echo "Fetching https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${ITK_PACKAGE_VERSION:=v5.4.0}/${TARBALL_NAME}.zst"
curl -L https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${ITK_PACKAGE_VERSION:=v5.4.0}/${TARBALL_NAME}.zst -O
fi
if [[ ! -f ./${TARBALL_NAME}.zst ]]; then
echo "ERROR: can not find required binary './${TARBALL_NAME}.zst'"
exit 255
fi
${unzstd_exe} --long=31 ./${TARBALL_NAME}.zst -o ${TARBALL_NAME}
if [ "$#" -lt 1 ]; then
echo "Extracting all files";
tar xf ${TARBALL_NAME}
else
echo "Extracting files relevant for: $1";
tar xf ${TARBALL_NAME} ITKPythonPackage/scripts/
tar xf ${TARBALL_NAME} ITKPythonPackage/ITK-source/
tar xf ${TARBALL_NAME} ITKPythonPackage/oneTBB-prefix/
tar xf ${TARBALL_NAME} --wildcards ITKPythonPackage/ITK-$1*
fi
rm ${TARBALL_NAME}
ln -s ITKPythonPackage/oneTBB-prefix ./
# -----------------------------------------------------------------------
# Optional: Update build scripts
#
# ITKPythonBuilds archives include ITKPythonPackage build scripts from the
# time of build. Those scripts may be updated for any changes or fixes
# since the archives were generated.
if [[ -n ${ITKPYTHONPACKAGE_TAG} ]]; then
echo "Updating build scripts to ${ITKPYTHONPACKAGE_ORG:=InsightSoftwareConsortium}/ITKPythonPackage@${ITKPYTHONPACKAGE_TAG}"
git clone "https://github.com/${ITKPYTHONPACKAGE_ORG}/ITKPythonPackage.git" "IPP-tmp"
pushd IPP-tmp/
git checkout "${ITKPYTHONPACKAGE_TAG}"
git status
popd
rm -rf ITKPythonPackage/scripts/
cp -r IPP-tmp/scripts ITKPythonPackage/
cp IPP-tmp/requirements-dev.txt ITKPythonPackage/
rm -rf IPP-tmp/
fi
if [[ ! -f ./ITKPythonPackage/scripts/dockcross-manylinux-build-module-wheels.sh ]]; then
echo "ERROR: can not find required binary './ITKPythonPackage/scripts/dockcross-manylinux-build-module-wheels.sh'"
exit 255
fi
echo "Finished fetching ITK build resources"