Skip to content

honor escaped newlines in requirements.txt #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
14 changes: 10 additions & 4 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../..)
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions tests/base/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down