2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # When run with WORKSPACE pointing at a git checkout of arvados, this script
7 # calculates the package version of an Arvados component.
9 # set to --no-cache-dir to disable pip caching
11 STDOUT_IF_DEBUG=/dev/null
12 STDERR_IF_DEBUG=/dev/null
14 ITERATION="${ARVADOS_BUILDING_ITERATION:-1}"
16 . `dirname "$(readlink -f "$0")"`/run-library.sh
21 if [[ "$TYPE_LANG" == "" ]] || [[ "$SRC_PATH" == "" ]]; then
22 echo "Syntax: $0 <lang> <src_path>"
24 echo "Example: $0 go cmd/arvados-client"
25 echo "Example: $0 python3 services/fuse"
30 if [[ "$WORKSPACE" == "" ]]; then
31 echo "The WORKSPACE environment variable must be set, pointing at the root of the arvados git tree"
36 debug_echo "get-package-version.sh $TYPE_LANG $SRC_PATH"
38 if [[ "$TYPE_LANG" == "go" ]]; then
39 calculate_go_package_version go_package_version $SRC_PATH
40 echo "${go_package_version}-${ITERATION}"
41 elif [[ "$TYPE_LANG" == "python3" ]]; then
43 cd $WORKSPACE/$SRC_PATH
47 # filter a useless warning (when building the cwltest package) from the stderr output
48 if ! python3 setup.py $DASHQ_UNLESS_DEBUG sdist 2> >(grep -v 'warning: no previously-included files matching' |grep -v 'for version number calculation'); then
49 echo "Error, unable to run python3 setup.py sdist for $SRC_PATH"
53 PYTHON_VERSION=$(awk '($1 == "Version:"){print $2}' *.egg-info/PKG-INFO)
54 UNFILTERED_PYTHON_VERSION=$(echo -n $PYTHON_VERSION | sed s/\.dev/~dev/g |sed 's/\([0-9]\)rc/\1~rc/g')
56 echo "${UNFILTERED_PYTHON_VERSION}-${ITERATION}"