diff --git a/layer/Python/Dockerfile b/layer/Python/Dockerfile index 7e6a979..e347349 100644 --- a/layer/Python/Dockerfile +++ b/layer/Python/Dockerfile @@ -6,8 +6,10 @@ USER root WORKDIR /tmp # PACKAGE_SUFFIX = '[all]==2.0.0' +# PACKAGE_SUFFIX = '[all] @ git+https://github.com/awslabs/aws-lambda-powertools-python@v2' # PACKAGE_SUFFIX = '[all]' # PACKAGE_SUFFIX = '=='2.0.0' +# PACKAGE_SUFFIX = ' @ git+https://github.com/awslabs/aws-lambda-powertools-python@v2' # PACKAGE_SUFFIX = '' RUN yum update -y && yum install -y zip unzip wget tar gzip binutils @@ -29,7 +31,7 @@ RUN yum install -y \ # Install cython to generate native code RUN pip install --upgrade pip wheel && pip install --upgrade cython # Optimize binary size and strip debugging symbols for optimum size -RUN CFLAGS="-Os -g0 -s" pip install --no-binary pydantic -t /asset/python aws-lambda-powertools$PACKAGE_SUFFIX +RUN CFLAGS="-Os -g0 -s" pip install --no-binary pydantic -t /asset/python "aws-lambda-powertools$PACKAGE_SUFFIX" # Removing nonessential files RUN cd /asset && \ diff --git a/src/lambda-powertools-layer.ts b/src/lambda-powertools-layer.ts index a7d060d..eeaec5d 100644 --- a/src/lambda-powertools-layer.ts +++ b/src/lambda-powertools-layer.ts @@ -58,7 +58,11 @@ export class LambdaPowertoolsLayer extends lambda.LayerVersion { suffix = '[all]'; } if (version) { - suffix = `${suffix}==${version}`; + if (version.startsWith('git')) { + suffix = `${suffix} @ ${version}`; + } else { + suffix = `${suffix}==${version}`; + } } break; case lambda.RuntimeFamily.NODEJS: diff --git a/test/lambda-powertools-python-layer.test.ts b/test/lambda-powertools-python-layer.test.ts index b629098..eb8951f 100644 --- a/test/lambda-powertools-python-layer.test.ts +++ b/test/lambda-powertools-python-layer.test.ts @@ -117,6 +117,13 @@ describe('construct build args for Dockerfile', () => { expect(args).toEqual('[all]'); }); + test('returns a git url with extras when a git url is provided', () => { + const version = 'git+https://github.com/awslabs/aws-lambda-powertools-python@v2'; + const args = LambdaPowertoolsLayer.constructBuildArgs(RuntimeFamily.PYTHON, true, version); + + expect(args).toEqual(`[all] @ ${version}`); + }); + test('returns only version when no extras flag provided', () => { const args = LambdaPowertoolsLayer.constructBuildArgs(RuntimeFamily.PYTHON, undefined, '1.11.0'); @@ -129,4 +136,11 @@ describe('construct build args for Dockerfile', () => { expect(args).toEqual(''); }); + test('returns a git url when a git url is provided and extras provided', () => { + const version = 'git+https://github.com/awslabs/aws-lambda-powertools-python@v2'; + const args = LambdaPowertoolsLayer.constructBuildArgs(RuntimeFamily.PYTHON, false, version); + + expect(args).toEqual(` @ ${version}`); + }); + }); \ No newline at end of file