21367/21230: Set up dev-jobs with virtualenv
[arvados.git] / build / build-dev-docker-jobs-image.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 read -rd "\000" helpmessage <<EOF
7 Build an arvados/jobs Docker image from local git tree.
8
9 Intended for use by developers working on arvados-python-client or
10 arvados-cwl-runner and need to run a crunch job with a custom package
11 version.  Also supports building custom cwltool if CWLTOOL is set.
12
13 Syntax:
14         WORKSPACE=/path/to/arvados $(basename $0)
15
16 WORKSPACE=path         Path to the Arvados source tree to build packages from
17 CWLTOOL=path           (optional) Path to cwltool git repository.
18 SALAD=path             (optional) Path to schema_salad git repository.
19 CWL_UTILS=path         (optional) Path to cwl-utils git repository.
20
21 EOF
22
23 set -e
24
25 if [[ -z "$WORKSPACE" ]] ; then
26     export WORKSPACE=$(readlink -f $(dirname $0)/..)
27     echo "Using WORKSPACE $WORKSPACE"
28 fi
29
30 context_dir="$(mktemp --directory --tmpdir dev-jobs.XXXXXXXX)"
31 trap 'rm -rf "$context_dir"' EXIT INT TERM QUIT
32 ts_path="$context_dir/.timestamp"
33
34 for src_dir in "$WORKSPACE/sdk/python" "${CWLTOOL:-}" "${CWL_UTILS:-}" "${SALAD:-}" "$WORKSPACE/sdk/cwl"; do
35     if [[ -z "$src_dir" ]]; then
36         continue
37     fi
38     touch "$ts_path"
39     env -C "$src_dir" python3 setup.py sdist
40     find "$src_dir/dist/" -maxdepth 1 -type f -cnewer "$ts_path" -print0 \
41         | xargs -0 cp --target="$context_dir/"
42 done
43 rm "$ts_path"
44
45 cd "$WORKSPACE"
46 . build/run-library.sh
47 # This defines python_sdk_version and cwl_runner_version with python-style
48 # package suffixes (.dev/rc)
49 calculate_python_sdk_cwl_package_versions
50
51 set -x
52 docker build --no-cache \
53        -f "$WORKSPACE/sdk/dev-jobs.dockerfile" \
54        -t arvados/jobs:$cwl_runner_version \
55        "$context_dir"
56
57 arv-keepdocker arvados/jobs $cwl_runner_version