Error: PythonPipBuilder:ResolveDependencies - Unable to retrieve name/version for package: shared-code (local module)
Description:
I am attempting to SAM build a Python lambda that utilizes a local editable pip module. The name of this module is shared_code. Here is my project structure:
├── README.md
├── template.yaml (SAM template)
├── function_1/
│ ├── Pipfile
│ ├── Pipfile.lock
│ ├── requirements.txt
│ └── src
│ ├── __init__.py
│ ├── handler.py
├── function_2/
│ ├── Pipfile
│ ├── Pipfile.lock
│ ├── requirements.txt
│ └── src
│ ├── __init__.py
│ ├── handler.py
├── shared_code/
│ ├── setup.py
│ └── src
│ ├── __init__.py
│ ├── utility1.py
│ ├── utility2.py
Here is the lambda function in SAM template:
LambdaFunction1:
Type: AWS::Serverless::Function
Properties:
FunctionName: lambda1
Description: Lambda function 1
Timeout: 30
MemorySize: 128
CodeUri: ./function_1
Handler: src.handler.lambda_handler
Dependency Versions
sam --version
SAM CLI, version 1.73.0
python --version
Python 3.9.6
pip --version
pip 22.3.1
docker --version
Docker version 20.10.21, build baeda1f
Steps to reproduce:
- [
shared_code/] ➜ pip install -e . - [
function1/] ➜ pipenv install -e ../shared_code - [
function1/] ➜ pipenv requirements > requirements.txt - [
function1/] ➜ sam build --template-file=../template.yaml --manifest requirements.txt LambdaFunction1 --debug
Observed result:
2023-02-22 14:08:16,573 | Running workflow 'PythonPipBuilder'
2023-02-22 14:08:16,574 | Running PythonPipBuilder:ResolveDependencies
2023-02-22 14:08:16,610 | calling pip download -r /Users/user/code/project/function1/requirements.txt --dest /var/folders/sr/xrd0djnn1c3bgq607gg_fbsm0000gq/T/tmpdd8pa0r0 --exists-action i
2023-02-22 14:08:24,228 | Non zero rc (2) from the setup.py egg_info command: b"Usage: sam [OPTIONS] COMMAND [ARGS]...\nTry 'sam -h' for help.\n\nError: No such option: -c\n"
2023-02-22 14:08:24,228 | Using fallback location for PKG-INFO file in package directory: /var/folders/sr/xrd0djnn1c3bgq607gg_fbsm0000gq/T/tmplkehgf8b/shared-code
2023-02-22 14:08:24,265 | PythonPipBuilder:ResolveDependencies raised unhandled exception
Traceback (most recent call last):
File "aws_lambda_builders/workflow.py", line 372, in run
File "aws_lambda_builders/workflows/python_pip/actions.py", line 51, in execute
File "aws_lambda_builders/workflows/python_pip/packager.py", line 156, in build_dependencies
File "aws_lambda_builders/workflows/python_pip/packager.py", line 256, in build_site_packages
File "aws_lambda_builders/workflows/python_pip/packager.py", line 280, in _download_dependencies
File "aws_lambda_builders/workflows/python_pip/packager.py", line 364, in _download_all_dependencies
File "aws_lambda_builders/workflows/python_pip/packager.py", line 364, in <setcomp>
File "aws_lambda_builders/workflows/python_pip/packager.py", line 513, in __init__
File "aws_lambda_builders/workflows/python_pip/packager.py", line 555, in _calculate_name_and_version
File "aws_lambda_builders/workflows/python_pip/packager.py", line 626, in get_package_name_and_version
File "aws_lambda_builders/workflows/python_pip/packager.py", line 609, in _get_pkg_info_filepath
aws_lambda_builders.workflows.python_pip.packager.UnsupportedPackageError: Unable to retrieve name/version for package: shared-code
Build Failed
Expected result:
Build Succeeded. I also want to be able to sam local invoke and utilize the VSCode debugger to debug the code.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS:
ProductName: macOS
ProductVersion: 12.6.3
BuildVersion: 21G419
sam --version: SAM CLI, version 1.73.0- AWS region: local
# Paste the output of `sam --info` here
{
"version": "1.73.0",
"system": {
"python": "3.8.13",
"os": "macOS-12.6.3-arm64-arm-64bit"
},
"additional_dependencies": {
"docker_engine": "20.10.21",
"aws_cdk": "Not available",
"terraform": "Not available"
}
}
Add --debug flag to command you are running
Thanks for raising this issue! Could you push a sample to a new sample repo before we attempt to debug further? Might be useful to see how the imports look like and the contents of the requirements.txt file.
Closing given no response. Please re-open or create a new issue if you still facing the same problem.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
I'm running into a similar issue with the combination of uv workspaces and sam. Bummer this is closed. Any context on the fix would be mighty helpful.
hi @pizza-planet could you provide a example package or list of commands that could reproduce this issue?