pulumi/sdk/python/dist/pulumi-analyzer-policy-python
Justin Van Patten 6b0a845cc1
Support publishing Python policy packs (#4644)
Adds support for publishing Python policy packs to the service, and downloading/using such policy packs when applied to stacks in an organization.
2020-05-22 15:01:15 -07:00

44 lines
1 KiB
Bash
Executable file

#!/bin/sh
# Parse the -virtualenv command line argument.
virtualenv=""
for arg in "$@"
do
case $arg in
-virtualenv=*)
virtualenv="${arg#*=}"
break
;;
esac
done
if [ -n "${virtualenv:-}" ] ; then
# Remove trailing slash.
virtualenv=${virtualenv%/}
# Make the path absolute (if not already).
case $virtualenv in
/*) : ;;
*) virtualenv=$PWD/$virtualenv;;
esac
# If python exists in the virtual environment, set PATH and run it.
if [ -f "$virtualenv/bin/python" ]; then
# Update PATH and unset PYTHONHOME.
PATH="$virtualenv/bin:$PATH"
export PATH
if [ -n "${PYTHONHOME:-}" ] ; then
unset PYTHONHOME
fi
# Run python from the virtual environment.
"$virtualenv/bin/python" -u -m pulumi.policy "$1" "$2"
else
echo "\"$virtualenv\" doesn't appear to be a virtual environment"
exit 1
fi
else
# Otherwise, just run python3.
python3 -u -m pulumi.policy "$1" "$2"
fi