Skip to content

Commit

Permalink
Update packager.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pushrbx committed May 16, 2019
1 parent 6696532 commit 5449ac3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions aws_lambda_builders/workflows/python_pip/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,11 @@ def _generate_egg_info(self, package_dir):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.communicate()
info_contents = self._osutils.get_directory_contents(egg_info_dir)
pkg_info_path = self._osutils.joinpath(
egg_info_dir, info_contents[0], 'PKG-INFO')
if len(info_contents) > 0:
pkg_info_path = self._osutils.joinpath(
egg_info_dir, info_contents[0], 'PKG-INFO')
else:
pkg_info_path = egg_info_dir.replace('egg-info', 'PKG-INFO')
return pkg_info_path

def _unpack_sdist_into_dir(self, sdist_path, unpack_dir):
Expand Down

7 comments on commit 5449ac3

@OscarVanL
Copy link

@OscarVanL OscarVanL commented on 5449ac3 Aug 19, 2019

Choose a reason for hiding this comment

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

Thanks, this solved the IndexError issue you described here by editing the file at C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\aws_lambda_builders\workflows\python_pip\packager.py

I'm still getting other Error: PythonPipBuilder:ResolveDependencies errors, though these could be unrelated.

@pushrbx
Copy link
Owner Author

Choose a reason for hiding this comment

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

That has to be something to do with distutils/setup.py stuff that it can't resolve the dependencies for the bundle, which can be caused by wrong version numbers. E.g. package X v1.0.0 has dependency on package Y v1.0.0 while package Z has dependency on package Y v1.0.1.
This would be my guess.

@OscarVanL
Copy link

Choose a reason for hiding this comment

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

I ended up solving it by checking the 'Build function inside a container' checkbox, which AFAIK just adds the --use-container parameter to the SAM command.

@NexPlex
Copy link

@NexPlex NexPlex commented on 5449ac3 Mar 31, 2020

Choose a reason for hiding this comment

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

I had the same issue SAM build Error: PythonPipBuilder:ResolveDependencies - list index out of range. I solving it by checking the 'Build function inside a container' checkbox in the PYCharm run configuration.

@kajalchatterjee
Copy link

Choose a reason for hiding this comment

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

How does it work for VS code? Once I modified the packager.py file that list out of index range error is gone. But I am still getting another error. pip install wheet did not help.
I am trying to build and debug using option available in code it self.

image

If i run SAM build --use container, it works fine.

An error occurred trying to run SAM Application locally: Error with child process: Building function 'awsToolkitSamLocalResource'
,Running PythonPipBuilder:ResolveDependencies
,Error: PythonPipBuilder:ResolveDependencies - {cryptography==2.9.2(wheel)}Can you please tell me what will be the equivalent o

@pushrbx
Copy link
Owner Author

@pushrbx pushrbx commented on 5449ac3 May 29, 2020

Choose a reason for hiding this comment

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

@kajalchatterjee

pip install wheet

correct:

pip install wheel

The error says

PythonPipBuilder:ResolveDependencies - {cryptography==2.9.2(wheel)}

So I would check that dependency first. You could create a new venv, and install this dep there, then check the folder structure of the dependency.
However I'm not familiar with VSCode. Probably you could change the config of vscode to run the thing with --use-container option then attach to the process. (Also I don't know what the --use-container option does)
So I recommend trying to debug without the SAM setup, in a different venv.

@CaptainDriftwood
Copy link

Choose a reason for hiding this comment

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

How is one supposed to resolve this issue if sam is installed on Linux and the lambda-builder dependency is brought in via the requirements.txt file?

Please sign in to comment.