@@ -27,9 +27,10 @@ displayVer() {
2727# Display usage
2828usage () {
2929 echo -e " AWS Lambda Layer Builder for Python Libraries\n"
30- echo -e " Usage: ${scriptname} [-p PYTHON_VER] [-n NAME] [-r] [-h] [-v]"
30+ echo -e " Usage: ${scriptname} [-p PYTHON_VER] [-n NAME] [-f] [- r] [-h] [-v]"
3131 echo -e " -p PYTHON_VER\t: Python version to use: 2.7, 3.6, 3.7, 3.8 (default 3.7)"
3232 echo -e " -n NAME\t: Name of the layer"
33+ echo -e " -f REQ_PATH\t: Path to requirements file"
3334 echo -e " -r\t\t: Raw mode, don't zip layer contents"
3435 echo -e " -d\t\t: Don't install Python dependencies"
3536 echo -e " -s\t\t: Don't strip .so files"
@@ -38,10 +39,11 @@ usage() {
3839}
3940
4041# Handle configuration
41- while getopts " :p:n:dsrhv" arg; do
42+ while getopts " :p:n:f: dsrhv" arg; do
4243 case " ${arg} " in
4344 p) PYTHON_VER=${OPTARG} ;;
4445 n) NAME=${OPTARG} ;;
46+ f) REQ_PATH=${OPTARG} ;;
4547 r) RAW_MODE=true;;
4648 d) NO_DEPS=true;;
4749 s) STRIP=false;;
@@ -64,7 +66,12 @@ NO_DEPS="${NO_DEPS:-false}"
6466STRIP=" ${STRIP:- true} "
6567
6668# Find location of requirements.txt
67- if [[ -f " ${CURRENT_DIR} /requirements.txt" ]]; then
69+ if [[ -f $REQ_PATH ]]; then
70+ if [[ ${REQ_PATH: 0: 1} != ' /' ]]; then
71+ REQ_PATH=" $( pwd) /${REQ_PATH} "
72+ fi
73+ echo " Using requirements.txt from command line input"
74+ elif [[ -f " ${CURRENT_DIR} /requirements.txt" ]]; then
6875 REQ_PATH=" ${CURRENT_DIR} /requirements.txt"
6976 echo " Using requirements.txt from script dir"
7077elif [[ -f " ${PARENT_DIR} /requirements.txt" ]]; then
0 commit comments