From c847edece7b5a0f68e8ebdd8b099685b76921f3c Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 10 Oct 2018 00:46:42 +0000 Subject: [PATCH 1/3] test proving bug #261 with pip-tools --- circle.yml | 2 +- test.bats | 9 +++++++++ tests/base/serverless.yml | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index cef66fcb..f86e51af 100644 --- a/circle.yml +++ b/circle.yml @@ -24,7 +24,7 @@ jobs: # other deps - run: sudo apt -y update && sudo apt -y install python-pip python2.7 curl unzip # instal pipenv - - run: sudo python3.6 -m pip install pipenv + - run: sudo python3.6 -m pip install pipenv pip-tools # install nodejs - run: curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - && sudo apt -y install nodejs # install serverless & depcheck diff --git a/test.bats b/test.bats index 9b8812dc..562c523d 100755 --- a/test.bats +++ b/test.bats @@ -35,6 +35,15 @@ teardown() { ls puck/flask } +@test "py3.6 can package flask with hashes" { + cd tests/base + npm i $(npm pack ../..) + pip-compile --output-file requirements-w-hashes.txt --generate-hashes requirements.txt + sls package --fileName requirements-w-hashes.txt + unzip .serverless/sls-py-req-test.zip -d puck + ls puck/flask +} + @test "py3.6 can package flask & bottle with zip option" { cd tests/base npm i $(npm pack ../..) diff --git a/tests/base/serverless.yml b/tests/base/serverless.yml index 7c864714..65078c7c 100644 --- a/tests/base/serverless.yml +++ b/tests/base/serverless.yml @@ -13,6 +13,7 @@ custom: slim: ${opt:slim, self:custom.defaults.slim} slimPatterns: ${file(./slimPatterns.yml):slimPatterns, self:custom.defaults.slimPatterns} vendor: ${opt:vendor, ''} + fileName: ${opt:fileName, 'requirements.txt'} defaults: slim: false slimPatterns: false From 4a2eeb19d67dc39b1f1db9800661676dbfb83e5e Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 10 Oct 2018 00:50:12 +0000 Subject: [PATCH 2/3] honor escaped newlines in requirements.txt fixes #261 --- lib/pip.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pip.js b/lib/pip.js index aed9c03f..a6285d8c 100644 --- a/lib/pip.js +++ b/lib/pip.js @@ -297,6 +297,7 @@ function generateRequirementsFile(source, target, options) { const noDeploy = new Set(options.noDeploy || []); const requirements = fse .readFileSync(source, { encoding: 'utf-8' }) + .replace(/\\\n/g, ' ') .split(/\r?\n/); var prepend = []; const filteredRequirements = requirements.filter(req => { From 62c0249956c1f76344228caa772cd71e0ac829fc Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Thu, 1 Nov 2018 14:36:21 -0400 Subject: [PATCH 3/3] fix merge issue --- test.bats | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test.bats b/test.bats index 562c523d..e10d5e1d 100755 --- a/test.bats +++ b/test.bats @@ -589,11 +589,8 @@ teardown() { @test "py3.6 supports custom file name with fileName option" { cd tests/base npm i $(npm pack ../..) - docker &> /dev/null || skip "docker not present" - ! uname -sm|grep Linux || groups|grep docker || id -u|egrep '^0$' || skip "can't dockerize on linux if not root & not in docker group" - perl -p -i'.bak' -e 's/(pythonRequirements:$)/\1\n fileName: puck/' serverless.yml echo "requests" > puck - sls package + sls --fileName puck package ls .serverless/requirements/requests ! ls .serverless/requirements/flask }