Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions sdks/java/container/license_scripts/license_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ set -e

# Get currently used Python version from Gradle or assume a default.
PYTHON=${1:-python3}
if ! command -v "${PYTHON}" >/dev/null 2>&1; then
if command -v python3 >/dev/null 2>&1; then
PYTHON=python3
else
PYTHON=python
fi
fi
SCRIPT_DIR="${PWD}/license_scripts"
ENV_DIR="${PWD}/build/virtualenv"

Expand All @@ -39,12 +46,12 @@ echo "Copying already-fetched licenses from ${EXISTING_LICENSE_DIR} to ${DOWNLOA
if [ -d "$DOWNLOAD_DIR" ]; then rm -rf "$DOWNLOAD_DIR" ; fi
mkdir -p "$DOWNLOAD_DIR"
cp -r "${EXISTING_LICENSE_DIR}"/*.jar "${DOWNLOAD_DIR}"
python -m venv --clear ${ENV_DIR} --without-pip --system-site-packages
${PYTHON} -m venv --clear ${ENV_DIR} --without-pip --system-site-packages
. ${ENV_DIR}/bin/activate
python -m pip install --retries 10 --upgrade pip setuptools wheel
${PYTHON} -m pip install --retries 10 --upgrade pip setuptools wheel

# install packages
python -m pip install --retries 10 -r ${SCRIPT_DIR}/requirement.txt
${PYTHON} -m pip install --retries 10 -r ${SCRIPT_DIR}/requirement.txt

# pull licenses, notices and source code
FLAGS="--license_index=${INDEX_FILE} \
Expand All @@ -53,8 +60,8 @@ FLAGS="--license_index=${INDEX_FILE} \
--manual_license_path=${SCRIPT_DIR}/manual_licenses \
--use_license_cache"

echo "Executing python ${SCRIPT_DIR}/pull_licenses_java.py $FLAGS"
python "${SCRIPT_DIR}/pull_licenses_java.py" $FLAGS
echo "Executing ${PYTHON} ${SCRIPT_DIR}/pull_licenses_java.py $FLAGS"
${PYTHON} "${SCRIPT_DIR}/pull_licenses_java.py" $FLAGS

# If this script is running, it is assumed that outputs are out of date and should be cleared and rewritten
if [ -d "$DEST_DIR" ]; then rm -rf "$DEST_DIR"; fi
Expand Down
Loading