2020-03-18 23:15:57 +00:00
@ echo off
2020-05-22 22:01:15 +00:00
2024-06-17 09:10:04 +00:00
REM Parse the -virtualenv command line argument and populate `args` with all other arguments.
2020-06-09 23:42:53 +00:00
set pulumi_runtime_python_virtualenv =
2024-06-17 09:10:04 +00:00
set args =
2020-05-22 22:01:15 +00:00
: parse
if " %~1 " == " " goto endparse
if " %~1 " == " -virtualenv " (
REM Get the value as a fully-qualified path.
2020-06-09 23:42:53 +00:00
set " pulumi_runtime_python_virtualenv= %~f2 "
2024-06-17 09:10:04 +00:00
shift /1
) else (
set args = %args% %~1
2020-05-22 22:01:15 +00:00
)
shift /1
goto parse
: endparse
2020-06-09 23:42:53 +00:00
if defined pulumi_runtime_python_virtualenv (
2020-05-22 22:01:15 +00:00
REM If python exists in the virtual environment, set PATH and run it.
2020-06-09 23:42:53 +00:00
if exist " %pulumi_runtime_python_virtualenv% \Scripts\python.exe " (
2020-05-22 22:01:15 +00:00
REM Update PATH and unset PYTHONHOME.
2020-06-09 23:42:53 +00:00
set " PATH= %pulumi_runtime_python_virtualenv% \Scripts; %PATH% "
2020-05-22 22:01:15 +00:00
set PYTHONHOME =
REM Run python from the virtual environment.
2024-06-17 09:10:04 +00:00
" %pulumi_runtime_python_virtualenv% \Scripts\python.exe " -u -m pulumi.policy %args%
2020-05-22 22:01:15 +00:00
exit /B
) else (
2020-07-28 20:28:14 +00:00
echo The 'virtualenv' option in PulumiPolicy.yaml is set to %pulumi_runtime_python_virtualenv% , but %pulumi_runtime_python_virtualenv% doesn't appear to be a virtual environment. 1 >& 2
echo Run the following commands to create the virtual environment and install dependencies into it: 1 >& 2
echo 1. python -m venv %pulumi_runtime_python_virtualenv% 1 >& 2
echo 2. %pulumi_runtime_python_virtualenv% \Scripts\python.exe -m pip install --upgrade pip setuptools wheel 1 >& 2
echo 3. %pulumi_runtime_python_virtualenv% \Scripts\python.exe -m pip install -r %cd% \requirements.txt 1 >& 2
echo For more information see: https://www.pulumi.com/docs/intro/languages/python/#virtual-environments 1 >& 2
2020-05-22 22:01:15 +00:00
exit 1
)
) else (
2020-11-19 03:08:41 +00:00
if defined PULUMI_PYTHON_CMD (
REM If PULUMI_PYTHON_CMD is defined, run it.
2024-06-17 09:10:04 +00:00
" %PULUMI_PYTHON_CMD% " -u -m pulumi.policy %args%
2020-11-19 03:08:41 +00:00
) else (
REM Otherwise, just run python. We use `python` instead of `python3` because Windows
REM Python installers install only `python.exe` by default.
2024-06-17 09:10:04 +00:00
@ python -u -m pulumi.policy %args%
2020-11-19 03:08:41 +00:00
)
2020-05-22 22:01:15 +00:00
)