Skip to content

Fix poetry 1.0.0b1 export prints to stdout by default #395

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 4 commits into from
Aug 12, 2019
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
8 changes: 5 additions & 3 deletions lib/poetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ function pyprojectTomlToRequirements() {

const editableFlag = new RegExp(/^-e /gm);
const sourceRequirements = path.join(this.servicePath, 'requirements.txt');
const requirementsContents = fse.readFileSync(sourceRequirements, {
encoding: 'utf-8'
});
const requirementsContents =
res.stdout.toString().trim() || // As of poetry 1.0.0b1, requirements.txt is printed to standard output when the -o option is not specified.
fse.readFileSync(sourceRequirements, {
encoding: 'utf-8'
});

if (requirementsContents.match(editableFlag)) {
this.serverless.cli.log(
Expand Down
15 changes: 15 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const sls = mkCommand('sls');
const git = mkCommand('git');
const npm = mkCommand('npm');
const perl = mkCommand('perl');
const poetry = mkCommand('poetry');

const setup = () => {
removeSync(getUserCachePath());
Expand Down Expand Up @@ -1874,3 +1875,17 @@ test(
},
{ skip: !canUseDocker() }
);

// From this point on, the version of the poetry is 1.0.0a0
test('poetry1.0.0a0 py3.6 can package flask with default options', t => {
process.chdir('tests/poetry');
const path = npm(['pack', '../..']);
npm(['i', path]);
poetry(['self', 'update', '--preview', '1.0.0a0']);
sls(['package']);
const zipfiles = listZipFiles('.serverless/sls-py-req-test.zip');
t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged');
t.true(zipfiles.includes(`bottle.py`), 'bottle is packaged');
t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged');
t.end();
});