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/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 => { diff --git a/test.bats b/test.bats index 9b8812dc..e10d5e1d 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 ../..) @@ -580,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 } 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