Skip to content

Commit

Permalink
fix(pacmak/python): improve detection of twine (#845)
Browse files Browse the repository at this point in the history
Attempt to check for `twine` using `which`, and only fall back to
`pip3 show` if that fails. This should hopefully improve detection in
contexts where a Python virtual environment is activated that does not
have `twine` installed in it, causing `pip3 show` to (presumably) not
see it.
  • Loading branch information
RomainMuller authored and mergify[bot] committed Oct 22, 2019
1 parent 83a0447 commit 2c4ef29
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ export default class Python extends Target {
+ 'Run `pip3 install twine` to enable distribution package validation.');
}

// Approximating existence check using `pip3 show`. If that fails, assume twine is not there.
// Approximating existence check using `which`, falling back on `pip3 show`. If that fails, assume twine is not there.
async function twineIsPresent(): Promise<boolean> {
try {
const output = await shell('pip3', ['show', 'twine'], { cwd: sourceDir });
return output.trim() !== '';
await shell('which', ['twine'], { cwd: sourceDir });
return true;
} catch {
return false;
try {
const output = await shell('pip3', ['show', 'twine'], { cwd: sourceDir });
return output.trim() !== '';
} catch {
return false;
}
}
}
}
Expand Down

0 comments on commit 2c4ef29

Please sign in to comment.