Skip to content

Add python packager - #7

Merged
sanathkr merged 2 commits into
aws:developfrom
stealthycoin:add-python-packager
Nov 13, 2018
Merged

Add python packager#7
sanathkr merged 2 commits into
aws:developfrom
stealthycoin:add-python-packager

Conversation

@stealthycoin

Copy link
Copy Markdown
Contributor

Add low level python packager

Port over the python dependency builder from Chalice. Also added a small
wrapper class to adapt the interface to something more like what the
Builder Action will use. The interface for the low level will stay the
same, the wrapper PythonPipDependencyBuilder class can be modified as
needed to match the expected interface as it evolves.

I made a few other changes as well to get the tests running, make things importable, etc.

@garnaat garnaat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of nitpicks. Tests all run for me locally. Code is a bit complicated so I'll need more time later today to review fully but overall looks goo.

Comment thread aws_lambda_builders/actions/python_pip/package.py Outdated
Comment thread aws_lambda_builders/actions/python_pip/package.py Outdated
Port over the python dependency builder from Chalice. Also added a small
wrapper class to adapt the interface to something more like what the
Builder Action will use. The interface for the low level will stay the
same, the wrapper PythonPipDependencyBuilder class can be modified as
needed to match the expected interface as it evolves.

@sanathkr sanathkr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not review the actual packager logic because it is coming from Chalice. I reviewed only the integration pieces. My biggest comment is to use the scratch_dir provided by the workflow instead of the system's tempdir.

My intention was to get more control over where files get written. Do you think this approach makes sense in general? Am I trying to control things out of my scope?

Comment thread .travis.yml
@@ -0,0 +1,19 @@
# Enable container based builds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is already in develop. If you rebase, you should get it

Comment thread aws_lambda_builders/workflows/python_pip/actions.py Outdated
we can extend at a later date to add more options to how pip is
called.
"""
# TODO: The DependencyBuilder makes the assumption that it is running

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How reliable is the process of finding a virtualenv matching the runtime we want? If it is a lot of guesswork, we can simply fail fast if python --version doesn't match the runtime we want.

If it is easy to discover virtualenvs, we can try to detect one and then fail if not found.

Either way, it is okay to make the assumption that users have a compatible version of Python/PIP available in their shell.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also created #11 to simplify this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #13 to investigate the virtualenv story

packages is included in the error object's ``missing`` property.
"""
if self._has_at_least_one_package(requirements_filepath):
with self._osutils.tempdir() as tempdir:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the system defined tempdir, this must use the tempdir passed to the Workflow.

See this - https://github.com/sanathkr/aws-lambda-builders/blob/builder-interfaces/aws_lambda_builders/workflow.py#L95-L98

It allows the builder library to control where files get written within a workflow. It is an extra layer of protection to ensure workflows don't mess with random files in the filesystem.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #12 to address this

return self._osutils.joinpath(unpack_dir, contents[0])

def get_package_name_and_version(self, sdist_path):
with self._osutils.tempdir() as tempdir:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the workflow provided tempdir instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#12

Comment thread aws_lambda_builders/workflows/python_pip/workflow.py Outdated
Comment thread tests/functional/workflows/test_packager.py
Comment thread tests/functional/workflows/test_utils.py

@sanathkr sanathkr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outstanding issues are minor. I created issues to track remaining work.

@sanathkr
sanathkr merged commit 1f5ebbc into aws:develop Nov 13, 2018
sanathkr pushed a commit that referenced this pull request Nov 19, 2018
Port over the python dependency builder from Chalice. Also added a small
wrapper class to adapt the interface to something more like what the
Builder Action will use. The interface for the low level will stay the
same, the wrapper PythonPipDependencyBuilder class can be modified as
needed to match the expected interface as it evolves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants