Skip to content

Adding debug logging to python_pip builder #33

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 1 commit into from
Nov 22, 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 aws_lambda_builders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
AWS Lambda Builder Library
"""
__version__ = '0.0.2'
__version__ = '0.0.3-dev'
RPC_PROTOCOL_VERSION = "0.1"
26 changes: 26 additions & 0 deletions aws_lambda_builders/workflows/python_pip/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import re
import subprocess
import logging
from email.parser import FeedParser


Expand All @@ -14,6 +15,8 @@
from .compat import pip_no_compile_c_shim
from .utils import OSUtils

LOG = logging.getLogger(__name__)


# TODO update the wording here
MISSING_DEPENDENCIES_TEMPLATE = r"""
Expand Down Expand Up @@ -229,6 +232,9 @@ def _download_dependencies(self, directory, requirements_filename):
else:
incompatible_wheels.add(package)

LOG.debug("initial compatible: %s", compatible_wheels)
LOG.debug("initial incompatible: %s", incompatible_wheels | sdists)

# Next we need to go through the downloaded packages and pick out any
# dependencies that do not have a compatible wheel file downloaded.
# For these packages we need to explicitly try to download a
Expand All @@ -242,6 +248,10 @@ def _download_dependencies(self, directory, requirements_filename):
# file ourselves.
compatible_wheels, incompatible_wheels = self._categorize_wheel_files(
directory)
LOG.debug(
"compatible wheels after second download pass: %s",
compatible_wheels
)
missing_wheels = sdists - compatible_wheels
self._build_sdists(missing_wheels, directory, compile_c=True)

Expand All @@ -255,6 +265,10 @@ def _download_dependencies(self, directory, requirements_filename):
# compiler.
compatible_wheels, incompatible_wheels = self._categorize_wheel_files(
directory)
LOG.debug(
"compatible after building wheels (no C compiling): %s",
compatible_wheels
)
missing_wheels = sdists - compatible_wheels
self._build_sdists(missing_wheels, directory, compile_c=False)

Expand All @@ -264,6 +278,10 @@ def _download_dependencies(self, directory, requirements_filename):
# compatible version directly and building from source.
compatible_wheels, incompatible_wheels = self._categorize_wheel_files(
directory)
LOG.debug(
"compatible after building wheels (C compiling): %s",
compatible_wheels
)

# Now there is still the case left over where the setup.py has been
# made in such a way to be incompatible with python's setup tools,
Expand All @@ -273,6 +291,9 @@ def _download_dependencies(self, directory, requirements_filename):
compatible_wheels, incompatible_wheels = self._apply_wheel_whitelist(
compatible_wheels, incompatible_wheels)
missing_wheels = deps - compatible_wheels
LOG.debug("Final compatible: %s", compatible_wheels)
LOG.debug("Final incompatible: %s", incompatible_wheels)
LOG.debug("Final missing wheels: %s", missing_wheels)

return compatible_wheels, missing_wheels

Expand All @@ -285,14 +306,18 @@ def _download_all_dependencies(self, requirements_filename, directory):
self._pip.download_all_dependencies(requirements_filename, directory)
deps = {Package(directory, filename) for filename
in self._osutils.get_directory_contents(directory)}
LOG.debug("Full dependency closure: %s", deps)
return deps

def _download_binary_wheels(self, packages, directory):
# Try to get binary wheels for each package that isn't compatible.
LOG.debug("Downloading missing wheels: %s", packages)
self._pip.download_manylinux_wheels(
[pkg.identifier for pkg in packages], directory)

def _build_sdists(self, sdists, directory, compile_c=True):
LOG.debug("Build missing wheels from sdists "
"(C compiling %s): %s", compile_c, sdists)
for sdist in sdists:
path_to_sdist = self._osutils.joinpath(directory, sdist.filename)
self._pip.build_wheel(path_to_sdist, directory, compile_c)
Expand Down Expand Up @@ -537,6 +562,7 @@ def __init__(self, pip, osutils=None):
def _execute(self, command, args, env_vars=None, shim=None):
"""Execute a pip command with the given arguments."""
main_args = [command] + args
LOG.debug("calling pip %s", ' '.join(main_args))
rc, out, err = self._wrapped_pip.main(main_args, env_vars=env_vars,
shim=shim)
return rc, out, err
Expand Down