#!/bin/bash
set -eu
if [[ "${1:-}" == "install" ]]; then
  # We will receive `pip install -r requirements.txt` and need to
  # install the packages from the local dist. We previously just
  # installed everything under $PYTHON_WHEELS ($PYTHON_WHEELS/*.whl).
  # However, there is a bug that arises on v2 when we install everything,
  # including both `aws-cdk-lib` and `cx-api`, because the latter is also
  # packaged in the former and causes conflicts. This can lead to errors like:
  # "Unknown type: aws-cdk-lib.cx_api.CloudAssembly"
  # Since we only need aws-cdk-lib anyway (for now), just install it alone.
  exec pip install ${PYTHON_WHEELS}/aws_cdk_lib*.whl
fi

exec pip "$@"
