Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Make license script used in build more portable #4861

Closed
wants to merge 1 commit into from
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
31 changes: 25 additions & 6 deletions cliv2/scripts/prepare_licenses.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail

VENV_DIR="./venv"

BASEDIR=$(dirname "$0")
PYTHON_VERSION=""

if python3 -c 'print("python3")' > /dev/null 2>&1; then
PYTHON_VERSION="3"
fi
# check to see if virtualenv is installed
command -v virtualenv >/dev/null 2>&1
VIRTUALENV_INSTALLED=$?

PIP_BREAK_SYSTEM_PACKAGES=1 pip$PYTHON_VERSION install requests
python$PYTHON_VERSION $BASEDIR/prepare_licenses.py
# if virtualenv is installed use that to isolate the python environment
if [ $VIRTUALENV_INSTALLED -eq 0 ]; then
# Create a new virtualenv if one doesn't exists
if [ ! -d "$VENV_DIR" ]; then
python -m venv $VENV_DIR
fi
source $VENV_DIR/bin/activate
pip install requests
python $BASEDIR/prepare_licenses.py
deactivate
else
# Fall back to use a local python installation
PYTHON_VERSION=""
if python3 -c 'print("python3")' > /dev/null 2>&1; then
PYTHON_VERSION="3"
fi
PIP_BREAK_SYSTEM_PACKAGES=1 pip$PYTHON_VERSION install requests
python$PYTHON_VERSION $BASEDIR/prepare_licenses.py
fi
Loading