actions / setup-python

Set up your GitHub Actions workflow with a specific version of Python
MIT License
1.69k stars 540 forks source link

python 3.7 from setup/python lacking GLIBC_2.28 to run in container #370

Closed oleks-popovych closed 2 years ago

oleks-popovych commented 2 years ago

Description: I’m trying to launch a workflow inside container on self-hosted runner.

Part of the workflow is python setup via action’s setup/python.

But I’m getting an error after trying to launch anything with installed python:

python: /lib/x86_64-linux-gnu/libm.so.6: versionGLIBC_2.29’ not found (required by /__w/_tool/Python/3.7.12/x64/lib/libpython3.7m.so.1.0)
python: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.28' not found (required by /__w/_tool/Python/3.7.12/x64/lib/libpython3.7m.so.1.0)

Action version: v2

Platform:

Runner type:

Tools version: python 3.7

Repro steps:

name: Testing

on:
  workflow_dispatch:

jobs:
  tests:
    container:
      image: ubuntu:18.04
    # ubuntu 20.04
    runs-on: self-hosted 

    steps:
    - name: Set up Python 3.7
      uses: actions/setup-python@v2
      with:
        python-version: 3.7

    - name: Install dev dependencies & build package
      run: |
        wget -qO- https://bootstrap.pypa.io/get-pip.py | python

Expected behavior: it doesn't throw the error

Actual behavior: error

vsafonkin commented 2 years ago

Hello @oleks-popovych, we will take a look at this, thank you for your report!

dsame commented 2 years ago

Hello @oleks-popovych,

Have you tried using the version 20.04 for container? That way you will have recent glibc version installed. Docker hub has the 20.04 image https://hub.docker.com/_/ubuntu

Please confirm if you need to run your build within 18.04 container, so we could provide you with some additional info. For any additional questions or concerns please feel free to leave a comment here.

oleks-popovych commented 2 years ago

@dsame I've tried to, but I have some specific constrains that tight me to ubuntu 18.04.

Also I didn't expect it to be this hard since if I'm trying to run my code on ubuntu 18.04 provided by github (runners) everything works fine.

dhvcc commented 2 years ago

Isn't this just the container lacking this lib? May be try inspect if this lib is present (or try to install it) before running setup-python? At least for me it seems to be the case

dsame commented 2 years ago

hello @oleks-popovych, In case you need to use python3.7 with the clean ubuntu 18.04 docker image the simplest way is to instal python 3.7 from some PPA repo:

    - name: Set up Python 3.7
      run: |
        apt update
        apt-get install -y software-properties-common 
        add-apt-repository -y ppa:deadsnakes/ppa
        apt-get install -y python3.7
        ln -s `which python3.7` /usr/local/bin/python
        python --version

Also pay attention the docker image provided does not have wget as well and you need to install it either in the separate step

   - name: Set up wget
      run: |
        apt-get install -y wget

or in the same time as the python package apt-get install -y python3.7 wget

The full workflow: https://github.com/akv-platform/python-docker-1804/actions/runs/2100834524

Ideally, to save the time in the workflow i'd create the docker inherited from ubunut:18.04 with the python and wget pre-installed

Please confirm the suggested solution works for you.

dsame commented 2 years ago

hello @dhvcc, you are absolutely correct. The latest glibc supported by Ubuntu 18.04 is 2.27

oleks-popovych commented 2 years ago

@dsame it seems that this is a way.

oleks-popovych commented 2 years ago

@dsame @dhvcc but still I don't understand why it's still working with python 3.7 installed via apt-get, but not via setup/python

dhvcc commented 2 years ago

@dsame @dhvcc but still I don't understand why it's still working with python 3.7 installed via apt-get, but not via setup/python

I think it's most likely not that setup-python is failing, but rather poetry choosing the wrong bundled version. I mena if you explicitly say poetry use 3.10 then it works, right?

oleks-popovych commented 2 years ago

@dhvcc I don't even know that setup/python uses poetry under the hood. could you elaborate more on your advice, since I'm not to how to connect setup/python and poetry

dhvcc commented 2 years ago

@dhvcc I don't even know that setup/python uses poetry under the hood. could you elaborate more on your advice, since I'm not to how to connect setup/python and poetry

Oh, that's a different issue that's not poetry related, sorry haha Basically what you need to do is to install right glibc version before running setup-python

vsafonkin commented 2 years ago

Hi @oleks-popovych, it's difficult to say why it doesn't work properly on your self-hosted runner, I'm trying to reproduce this issue on hosted runner and it works: https://github.com/vsafonkin/test-repo/runs/5970187832?check_suite_focus=true Could you try to execute apt-get update command before setup-python step?

oleks-popovych commented 2 years ago

@vsafonkin Thank you for your reply. I've already used a suggestion by @dsame to install python via apt-get instead of using setup/python

Still I'm confused why underlying system matters when things are running in a container?

dhvcc commented 2 years ago

@vsafonkin Thank you for your reply. I've already used a suggestion by @dsame to install python via apt-get instead of using setup/python

Still I'm confused why underlying system matters when things are running in a container?

Not an underlying (host) system matters. It's the container itself. If libs are missing in a container (which is running Ubuntu 18), then python won't be set up properly

vsafonkin commented 2 years ago

Still I'm confused why underlying system matters when things are running in a container?

As I see this issue: the setup-python action uses the python build from source code, which was built on the hosted runner and downloaded from python-versions repository. As I know, Ubuntu container uses OS kernel from host OS. So using a python that has been built on a OS kernel with certain versions of the libraries can cause problems when running on another OS kernel.

vsafonkin commented 2 years ago

Hi @oleks-popovych, I'm going to close this issue, feel free to contact us if you have any concerns, thank you.