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

Sam build fails on Ubuntu 20.04.3 #280

Closed
Lewenhaupt opened this issue Sep 13, 2021 · 12 comments
Closed

Sam build fails on Ubuntu 20.04.3 #280

Lewenhaupt opened this issue Sep 13, 2021 · 12 comments

Comments

@Lewenhaupt
Copy link

Lewenhaupt commented Sep 13, 2021

Description:

Using sam cli 1.21.1 in github actions started to fail building wheels on Ubuntu 20.04.3. It previously worked on Ubuntu 20.04.2 but github upgraded to 20.04.3 and there is no way to go back.

Steps to reproduce:

Python 3.8.11
Run any python build using pypdf4 as a dependency using sam build on Ubuntu 20.04.3. It will fail to build the missing wheel.
--use-container will solve the issue but we do not wish to build inside container due to 500-issues against the AWS ECR.

Observed result:

2021-09-09 10:00:16,932 | initial incompatible: {pypdf4==1.27.0(sdist)}
2021-09-09 10:00:16,932 | Downloading missing wheels: {pypdf4==1.27.0(sdist)}
2021-09-09 10:00:16,932 | calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp38 --dest /tmp/tmp82embo2b pypdf4==1.27.0
2021-09-09 10:00:17,559 | compatible wheels after second download pass: {idna==2.10(wheel), urllib3==1.26.6(wheel), certifi==2021.5.30(wheel), chardet==4.0.0(wheel), requests==2.25.1(wheel)}
2021-09-09 10:00:17,559 | Build missing wheels from sdists (C compiling True): {pypdf4==1.27.0(sdist)}
2021-09-09 10:00:17,560 | calling pip wheel --no-deps --wheel-dir /tmp/tmp82embo2b /tmp/tmp82embo2b/PyPDF4-1.27.0.tar.gz
2021-09-09 10:00:18,662 | compatible after building wheels (no C compiling): {idna==2.10(wheel), urllib3==1.26.6(wheel), certifi==2021.5.30(wheel), chardet==4.0.0(wheel), requests==2.25.1(wheel)}
2021-09-09 10:00:18,662 | Build missing wheels from sdists (C compiling False): {pypdf4==1.27.0(sdist)}
2021-09-09 10:00:18,662 | calling pip wheel --no-deps --wheel-dir /tmp/tmp82embo2b /tmp/tmp82embo2b/PyPDF4-1.27.0.tar.gz
2021-09-09 10:00:19,754 | compatible after building wheels (C compiling): {idna==2.10(wheel), urllib3==1.26.6(wheel), certifi==2021.5.30(wheel), chardet==4.0.0(wheel), requests==2.25.1(wheel)}
2021-09-09 10:00:19,754 | Final compatible: {idna==2.10(wheel), chardet==4.0.0(wheel), urllib3==1.26.6(wheel), requests==2.25.1(wheel), certifi==2021.5.30(wheel)}
2021-09-09 10:00:19,754 | Final incompatible: set()
2021-09-09 10:00:19,754 | Final missing wheels: {pypdf4==1.27.0(sdist)}
2021-09-09 10:00:19,780 | PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "/home/runner/.virtualenvs/.venv/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 39, in execute

Build Failed
    package_builder.build_dependencies(
  File "/home/runner/.virtualenvs/.venv/lib/python3.8/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 "/home/runner/.virtualenvs/.venv/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 226, in build_site_packages
    raise MissingDependencyError(packages_without_wheels)
aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {pypdf4==1.27.0(sdist)}

Expected result:

Expect sam build to be able to build the wheel from the sdist.

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

  1. OS: Ubuntu 20.04.3
  2. sam --version: 1.21
  3. AWS region:

Add --debug flag to command you are running

@aahung
Copy link
Contributor

aahung commented Sep 13, 2021

Can you upgrade your sam-cli to 1.31.0 and try again? (Also upgrade your pip if you build without --use-container)

@Lewenhaupt
Copy link
Author

Yeah we get exactly the same issue unfortunately:
pip 21.2.4 from /home/runner/.virtualenvs/.venv/lib/python3.8/site-packages/pip (python 3.8)
SAM CLI, version 1.31.0
Error: PythonPipBuilder:ResolveDependencies - {pypdf4==1.27.0(sdist)}

@aahung
Copy link
Contributor

aahung commented Sep 14, 2021

I can reproduce it on macOS as well. Not reproducible with --use-container.

@aahung aahung transferred this issue from aws/aws-sam-cli Sep 14, 2021
@aahung
Copy link
Contributor

aahung commented Sep 14, 2021

We will look into the issue soon.

--use-container will solve the issue but we do not wish to build inside container due to 500-issues against the AWS ECR.

Can you elaborate what issues with --use-container?

@hoffa
Copy link

hoffa commented Sep 14, 2021

Can you try by adding the following before the installation:

pip install --upgrade setuptools wheel

I was unable to reproduce with:

python3.8 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install --upgrade aws-sam-cli
sam init --name sam-app --runtime python3.8 --dependency-manager pip --app-template hello-world
cd sam-app
echo 'pypdf4==1.27.0' > hello_world/requirements.txt
sam build

You might also want to give the aws-actions/setup-sam GitHub Action a try!

@aahung
Copy link
Contributor

aahung commented Sep 14, 2021

On top of what @hoffa suggested, after I ran pip install --upgrade setuptools wheel, I didn't see the error anymore. So @Lewenhaupt let us know if that doesn't resolve your issue

@aahung aahung added the blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days label Sep 14, 2021
@Lewenhaupt
Copy link
Author

Thanks guys @aahung @hoffa I'll give it a try :)
@aahung the issue for use with --use-container seems to be that we frequently get a 500: too many requests error when fetching the image that is being used which causes failures in our jobs. It also seems to be quite a lot slower in Github Actions than running without it.

@Lewenhaupt
Copy link
Author

Lewenhaupt commented Sep 16, 2021

Unfortunately no luck with upgraded setuptools and wheel :/

2021-09-16 08:07:34,546 | calling pip download -r /home/runner/work/robinhood/robinhood/documents/merge_pdf/requirements.txt --dest /tmp/tmpmpdkhztf --exists-action i
2021-09-16 08:07:38,802 | Full dependency closure: {urllib3==1.26.6(wheel), requests==2.25.1(wheel), certifi==2021.5.30(wheel), idna==2.10(wheel), chardet==4.0.0(wheel), pypdf4==1.27.0(sdist)}
2021-09-16 08:07:38,802 | initial compatible: {urllib3==1.26.6(wheel), requests==2.25.1(wheel), certifi==2021.5.30(wheel), idna==2.10(wheel), chardet==4.0.0(wheel)}
2021-09-16 08:07:38,802 | initial incompatible: {pypdf4==1.27.0(sdist)}
2021-09-16 08:07:38,802 | Downloading missing wheels: {pypdf4==1.27.0(sdist)}
2021-09-16 08:07:38,802 | calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp38 --dest /tmp/tmpmpdkhztf pypdf4==1.27.0
2021-09-16 08:07:40,277 | compatible wheels after second download pass: {urllib3==1.26.6(wheel), requests==2.25.1(wheel), certifi==2021.5.30(wheel), idna==2.10(wheel), chardet==4.0.0(wheel)}
2021-09-16 08:07:40,277 | Build missing wheels from sdists (C compiling True): {pypdf4==1.27.0(sdist)}
2021-09-16 08:07:40,277 | calling pip wheel --no-deps --wheel-dir /tmp/tmpmpdkhztf /tmp/tmpmpdkhztf/PyPDF4-1.27.0.tar.gz
2021-09-16 08:07:42,481 | compatible after building wheels (no C compiling): {urllib3==1.26.6(wheel), requests==2.25.1(wheel), certifi==2021.5.30(wheel), idna==2.10(wheel), chardet==4.0.0(wheel)}
2021-09-16 08:07:42,481 | Build missing wheels from sdists (C compiling False): {pypdf4==1.27.0(sdist)}
2021-09-16 08:07:42,481 | calling pip wheel --no-deps --wheel-dir /tmp/tmpmpdkhztf /tmp/tmpmpdkhztf/PyPDF4-1.27.0.tar.gz
2021-09-16 08:07:44,522 | compatible after building wheels (C compiling): {urllib3==1.26.6(wheel), requests==2.25.1(wheel), certifi==2021.5.30(wheel), idna==2.10(wheel), chardet==4.0.0(wheel)}
2021-09-16 08:07:44,522 | Final compatible: {urllib3==1.26.6(wheel), idna==2.10(wheel), requests==2.25.1(wheel), chardet==4.0.0(wheel), certifi==2021.5.30(wheel)}
2021-09-16 08:07:44,522 | Final incompatible: set()
2021-09-16 08:07:44,522 | Final missing wheels: {pypdf4==1.27.0(sdist)}
2021-09-16 08:07:44,554 | PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "/home/runner/.virtualenvs/.venv/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 39, in execute

package_builder.build_dependencies(
  File "/home/runner/.virtualenvs/.venv/lib/python3.8/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 "/home/runner/.virtualenvs/.venv/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 226, in build_site_packages
    raise MissingDependencyError(packages_without_wheels)
aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {pypdf4==1.27.0(sdist)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/.virtualenvs/.venv/lib/python3.8/site-packages/aws_lambda_builders/workflow.py", line 269, in run
    action.execute()
  File "/home/runner/.virtualenvs/.venv/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 45, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: {pypdf4==1.27.0(sdist)}
Build Failed
2021-09-16 08:07:44,558 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '3f5cee0c-a462-4afc-a1f6-b583ab2d68a1', 'installationId': '1928f58d-c021-411d-8eb9-8882490d80e0', 'sessionId': 'fa43af0c-0411-4f24-8d5f-ac135977095b', 'executionEnvironment': 'GitHubAction', 'ci': True, 'pyversion': '3.8.11', 'samcliVersion': '1.31.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 21576, 'exitReason': 'WorkflowFailedError', 'exitCode': 1}}]}
2021-09-16 08:07:44,937 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: PythonPipBuilder:ResolveDependencies - {pypdf4==1.27.0(sdist)}

@hoffa
Copy link

hoffa commented Sep 17, 2021

I was able to reproduce this in a personal repository with the following workflow:

on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: "3.8"
      - uses: aws-actions/setup-sam@v1
      - run: sam build --debug

This is an interesting issue, and while I'm not yet sure what's causing it, a temporary workaround seems to be doing the following before sam build:

pip install wheel
pip install pypdf4

@hoffa hoffa added type/bug and removed blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days labels Sep 17, 2021
@Lewenhaupt
Copy link
Author

@hoffa Thanks, I'll give that another try. I haven't tested with explicit install of pypdf4 yet.

@Lewenhaupt
Copy link
Author

Lewenhaupt commented Sep 20, 2021

@hoffa After some more experimentation I actually found that replacing syphar/restore-virtualenv@v1 with aws-actions/setup-sam@v1 seems to have solved it for us, i.e. no need to do:

pip install wheel
pip install pypdf4

So it seems that setup-sam@v1 resolves the issue given that there is nothing else messing around with the venv.

@hoffa
Copy link

hoffa commented Sep 20, 2021

Great to hear! I also realized a pip install wheel by itself was enough the build to succeed (which makes sense):

on: push
jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
      - run: pip install wheel
      - uses: aws-actions/setup-sam@v1
      - run: sam build

@hoffa hoffa closed this as completed Sep 20, 2021
zaro0508 added a commit to zaro0508/s3-synapse-sync that referenced this issue Oct 29, 2021
SAM build command was failing..

```
$ sam build
Building function 'Function'
Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - {pyyaml==6.0(wheel), cryptography==35.0.0(wheel), cffi==1.15.0(wheel)}
The command "sam build" exited with 1.
```

This is due to some change with wheels[1].  We attempt to pip
install wheel as a fix.

[1] aws/aws-lambda-builders#280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants