-
Notifications
You must be signed in to change notification settings - Fork 293
Add support for poetry. #308
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nodejs 6.16.0 | ||
python 3.6.8 2.7.15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const fse = require('fs-extra'); | ||
const path = require('path'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
/** | ||
* poetry install | ||
*/ | ||
function pyprojectTomlToRequirements() { | ||
if ( | ||
!this.options.usePoetry || | ||
!fse.existsSync(path.join(this.servicePath, 'pyproject.toml')) | ||
) { | ||
return; | ||
} | ||
|
||
this.serverless.cli.log('Generating requirements.txt from pyproject.toml...'); | ||
|
||
const res = spawnSync( | ||
'poetry', | ||
['export', '--without-hashes', '-f', 'requirements.txt'], | ||
{ | ||
cwd: this.servicePath | ||
} | ||
); | ||
if (res.error) { | ||
if (res.error.code === 'ENOENT') { | ||
throw new Error( | ||
`poetry not found! Install it according to the poetry docs.` | ||
); | ||
} | ||
throw new Error(res.error); | ||
} | ||
if (res.status !== 0) { | ||
throw new Error(res.stderr); | ||
} | ||
fse.ensureDirSync(path.join(this.servicePath, '.serverless')); | ||
fse.moveSync( | ||
path.join(this.servicePath, 'requirements.txt'), | ||
path.join(this.servicePath, '.serverless', 'requirements.txt') | ||
); | ||
} | ||
|
||
module.exports = { pyprojectTomlToRequirements }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# Serverless | ||
.serverless | ||
.requirements | ||
unzip_requirements.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
slimPatterns: | ||
- "**/__main__.py" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import requests | ||
|
||
|
||
def hello(event, context): | ||
return requests.get('https://httpbin.org/get').json() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more question. Should this check the contents of the
pyproject.toml
file since other tools are configured with it too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Do you know what other tools might be configured to use it as well? I thought that file was introduced by poetry.
I did add support to disable this functionality so if someone is using a
pyproject.toml
without poetry, then they can tell this plugin to ignore the file.If I were to check the contents, that would most likely add another dep to this plugin so I can parse the toml. Is that something you really want me to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only tool I know of currently is
flit
, but I don't think that's for installation, only publication.Not sure which introduced it, but it's specified in PEP518 and there's nothing stopping someone from making a new packaging tool that uses it
fair point. Probably not. Lets leave it like this for now and we can revisit if another package manager leveraging pep518 pops up