Skip to content
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

AWS SAM CLI Python version detection fails on cimg/python3.9 #97

Closed
Willbly opened this issue Sep 15, 2021 · 2 comments
Closed

AWS SAM CLI Python version detection fails on cimg/python3.9 #97

Willbly opened this issue Sep 15, 2021 · 2 comments

Comments

@Willbly
Copy link

Willbly commented Sep 15, 2021

Something about the way that Python is installed is causing Python version detection to fail in the SAM CLI. It works in the legacy Python images.

Here are the debug logs for the SAM CLI:

2021-09-10 01:43:20,142 | Invalid executable for python at /home/circleci/.pyenv/shims/python3.9
Traceback (most recent call last):
  File "aws_lambda_builders/workflow.py", line 58, in wrapper
  File "aws_lambda_builders/workflows/python_pip/validator.py", line 48, in validate
aws_lambda_builders.exceptions.MisMatchRuntimeError: python executable found in your path does not match runtime. 
 Expected version: python3.9, Found version: /home/circleci/.pyenv/shims/python3.9. 
 Possibly related: https://github.com/awslabs/aws-lambda-builders/issues/30
2021-09-10 01:43:20,157 | Invalid executable for python at /home/circleci/.pyenv/shims/python
Traceback (most recent call last):
  File "aws_lambda_builders/workflow.py", line 58, in wrapper
  File "aws_lambda_builders/workflows/python_pip/validator.py", line 48, in validate
aws_lambda_builders.exceptions.MisMatchRuntimeError: python executable found in your path does not match runtime. 
 Expected version: python3.9, Found version: /home/circleci/.pyenv/shims/python. 
 Possibly related: https://github.com/awslabs/aws-lambda-builders/issues/30

Here is a code snippet from the aws-lambda-builders module that contains the Python version validation code:

cmd = self._validate_python_cmd(runtime_path)

p = subprocess.Popen(
  cmd, cwd=os.getcwd(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=OSUtils().original_environ()
)
p.communicate()
if p.returncode != 0:
  raise MisMatchRuntimeError(language=self.language, required_runtime=self.runtime, runtime_path=runtime_path)


def _validate_python_cmd(self, runtime_path):
  major, minor = self.runtime.replace(self.language, "").split(".")  # self.runtime is "python3.9"
  cmd = [
    runtime_path,
    "-c",
    "import sys; "
    "assert sys.version_info.major == {major} "
    "and sys.version_info.minor == {minor}".format(major=major, minor=minor),
  ]
  return cmd

When running the command /home/circleci/.pyenv/shims/python3.9 -c "import sys; assert sys.version_info.major == 3 and sys.version_info.minor == 9" myself, it passes correctly. I have also opened an issue with the aws-lambda-builders repository, but this issue could be caused by the image and could be causing other unknown issues.

@FelicianoTech
Copy link
Contributor

Thank you for reporting. Investigating.

@FelicianoTech
Copy link
Contributor

Closing this issue due to a lack of activity. This might be similar to #96? Which is also closed as of today. There's also the AWS image which an option now.

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

No branches or pull requests

2 participants