aws/aws-lambda-builders

sam build unable to resolve dependencies

malekadrar opened this issue · 1 comments

Description:

When I run sam build I get the following error:
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: QuantLib

Steps to reproduce:

  1. Set up the "Hello World" application by running the command sam init
  2. Add in the file hello_world/requirements.txt the package QuantLib
  3. Run the command sam build

Observed result:

I get the above mentioned error despite the package Quantlib exists in PyPI. Let's note that it's working properly when I run the command:
python -m pip install -r requirements.txt

Expected result:

sam should be able to download and install this package.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows 10
  2. sam version: SAM CLI, version 1.30.0
  3. Python version: 3.9.1

sam build --debug outputs

2021-09-09 09:26:18,081 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2021-09-09 09:26:18,081 | Using config file: samconfig.toml, config environment: default
2021-09-09 09:26:18,081 | Expand command line arguments to:
2021-09-09 09:26:18,084 | --template_file=C:\Users\malek\aws_sam\sam-app\template.yaml --build_dir=.aws-sam\build --cache_dir=.aws-sam\cache
2021-09-09 09:26:18,302 | 'build' command is called
2021-09-09 09:26:18,324 | No Parameters detected in the template
2021-09-09 09:26:18,364 | 2 stacks found in the template
2021-09-09 09:26:18,364 | No Parameters detected in the template
2021-09-09 09:26:18,388 | 2 resources found in the stack
2021-09-09 09:26:18,388 | No Parameters detected in the template
2021-09-09 09:26:18,404 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2021-09-09 09:26:18,404 | --base-dir is not presented, adjusting uri hello_world/ relative to C:\Users\malek\aws_sam\sam-app\template.yaml
2021-09-09 09:26:18,412 | No Parameters detected in the template
2021-09-09 09:26:18,428 | Instantiating build definitions
2021-09-09 09:26:18,436 | Same function build definition found, adding function (Previous: BuildDefinition(python3.9, C:\Users\malek\aws_sam\sam-app\hello_world, Zip, , fdbd190b-3916-47de-a689-6051080668d1, {}, {}, []), Current: BuildDefinition(python3.9, C:\Users\malek\aws_sam\sam-app\hello_world, Zip, , d6945c77-dba2-4ac5-ae3d-1d714b1f804b, {}, {}, []), Function: Function(name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='python3.9', memory=None, timeout=3, handler='app.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='C:\Users\malek\aws_sam\sam-app\hello_world', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'HttpApi', 'Properties': {'Path': '/hello', 'Method': 'get', 'ApiId': 'ServerlessHttpApi'}}}, metadata=None, inlinecode=None, codesign_config_arn=None, stack_path=''))
2021-09-09 09:26:18,436 | Building codeuri: C:\Users\malek\aws_sam\sam-app\hello_world runtime: python3.9 metadata: {} functions: ['HelloWorldFunction']
2021-09-09 09:26:18,436 | Building to following folder C:\Users\malek\aws_sam\sam-app.aws-sam\build\HelloWorldFunction
2021-09-09 09:26:18,444 | Loading workflow module 'aws_lambda_builders.workflows'
2021-09-09 09:26:18,460 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2021-09-09 09:26:18,468 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2021-09-09 09:26:18,476 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2021-09-09 09:26:18,484 | Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
2021-09-09 09:26:18,492 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2021-09-09 09:26:18,508 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2021-09-09 09:26:18,516 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2021-09-09 09:26:18,524 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2021-09-09 09:26:18,532 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2021-09-09 09:26:18,532 | Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2021-09-09 09:26:18,613 | Running workflow 'PythonPipBuilder'
2021-09-09 09:26:18,613 | Running PythonPipBuilder:ResolveDependencies
2021-09-09 09:26:18,685 | calling pip download -r C:\Users\malek\aws_sam\sam-app\hello_world\requirements.txt --dest C:\Users\malek\AppData\Local\Temp\tmpe08hwy8m --exists-action i
2021-09-09 09:26:19,582 | PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\actions.py", line 39, in execute
package_builder.build_dependencies(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\packager.py", line 145, in build_dependencies
self._dependency_builder.build_site_packages(requirements_path, artifacts_dir_path, scratch_dir_path)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\packager.py", line 223, in build_site_packages
wheels, packages_without_wheels = self._download_dependencies(scratch_directory, requirements_filepath)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\packager.py", line 247, in _download_dependencies
deps = self._download_all_dependencies(requirements_filename, directory)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\packager.py", line 329, in _download_all_dependencies
self._pip.download_all_dependencies(requirements_filename, directory)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\packager.py", line 655, in download_all_dependencies
raise NoSuchPackageError(str(package_name))
aws_lambda_builders.workflows.python_pip.packager.NoSuchPackageError: Could not satisfy the requirement: QuantLib

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflow.py", line 269, in run
action.execute()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\actions.py", line 45, in execute
raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: Could not satisfy the requirement: QuantLib

Build Failed
2021-09-09 09:26:19,582 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'fb46f94e-eab3-4bca-8094-a67d410935e6', 'installationId': '3b8e915e-c1c8-408b-99ec-b68f214d89ab', 'sessionId': '530d4427-21e0-453d-9749-3a378fca7c4a', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.30.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 1505, 'exitReason': 'WorkflowFailedError', 'exitCode': 1}}]}
2021-09-09 09:26:20,394 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: QuantLib

duplicate: #276