actions / setup-python

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

Python 3.8 and 3.9 not found on macOS #850

Closed ZeroIntensity closed 4 months ago

ZeroIntensity commented 5 months ago

Description: Python 3.8 and 3.9 on macOS no longer work, and actions complains about them not being a real version.

Action version: Latest

Platform:

Runner type:

Tools version: Python 3.8 - Python 3.9. It might be all versions <Python 3.10, but I haven't tested that.

Repro steps: See this run from yesterday, vs this run from this morning on the same commit.

Expected behavior: Python 3.8 and 3.9 should install on macOS

Actual behavior: The following is logged to actions:

Version 3.8 was not found in the local cache
Error: Version 3.8 with arch arm64 not found
The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
hugovk commented 5 months ago

This is a duplicate, macos-latest now uses M1 runners (macos-14-arm64) and 3.9 and earlier aren't available there: https://github.com/actions/setup-python/issues/696#issuecomment-1637587760

To fix, you can use one of the options at https://github.com/python/peps/pull/3763, or stick to macos-12 or macos-13 (but you get some nice speedups using M1 where available).

snorkman88 commented 5 months ago

I am facing the same issues when running GHA I get:

Installed versions
  Version 3.8 was not found in the local cache
  Error: The version '3.8' with architecture 'arm64' was not found for macOS 14.4.1.
ZeroIntensity commented 5 months ago

Odd, that issue is from months ago, but I only started having problems this morning.

hugovk commented 5 months ago

Yeah, macos-latest used to point to macos-12 but now points to macos-14-arm64.

You can check the top of your CI logs to see which image was used yesterday and today.

Paebbels commented 5 months ago

The list of offered Python versions is here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json

It shows no Python 3.8 and Python 3.9 for macOS (Python for ARM64 platform).

HarithaVattikuti commented 5 months ago

Hello @ZeroIntensity Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

HarithaVattikuti commented 5 months ago

Hello @ZeroIntensity

We are supporting python 3.8 and 3.9 versions for macos arm64 now. Please test your workflows.

Feel Free to reach out to us in case of any issues.

Olegt0rr commented 5 months ago

Hello @ZeroIntensity

We are supporting python 3.8 and 3.9 versions for macos arm64 now. Please test your workflows.

Feel Free to reach out to us in case of any issues.

It works, thanks

Tested here: https://github.com/aio-libs/aiohttp-sse/actions/runs/8828949346?pr=488

abravalheri commented 5 months ago

We are supporting python 3.8 and 3.9 versions for macos arm64 now. Please test your workflows.

Feel Free to reach out to us in case of any issues.

Hi @HarithaVattikuti, I am still having trouble with macos-latest and 3.8:

Run actions/setup-python@v5
  with:
    python-version: 3.8
    allow-prereleases: true
    check-latest: false
    token: ***
    update-environment: true
  env:
    FORCE_COLOR: 1
    PIP_DISABLE_PIP_VERSION_CHECK: true
    PIP_NO_PYTHON_VERSION_WARNING: true
    PIP_NO_WARN_SCRIPT_LOCATION: true
    TOX_OVERRIDE: testenv.pass_env+=GITHUB_*,FORCE_COLOR
    SETUPTOOLS_USE_DISTUTILS: local
Installed versions
  Version ~3.8.0-0 was not found in the local cache
  Version ~3.8.0-0 is available for downloading
  Download from "https://github.com/actions/python-versions/releases/download/3.8.10-8833490[2](https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329#step:3:2)98/python-[3](https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329#step:3:3).8.10-darwin-arm64.tar.gz"
  Extract downloaded archive
  /usr/bin/tar xz -C /Users/runner/work/_temp/c[4](https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329#step:3:4)9b1822-0f6f-4d2a-ae95-fdae63cc4323 -f /Users/runner/work/_temp/8c0d1b73-e480-404c-904b-98876ab86d14
  Execute installation script
  Check if Python hostedtoolcache folder exist...
  Install Python binaries from prebuilt package
  installer: Package name is Python
  installer: Upgrading at base path /
  installer: The upgrade was successful.
  Create hostedtoolcach symlinks (Required for the backward compatibility)
  Create Python 3.8.10 folder
  Create additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)
  Upgrading pip...
  Error: Traceback (most recent call last):
    File "<string>", line 6, in <module>
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 203, in run_module
      mod_name, mod_spec, code = _get_module_details(mod_name)
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 130, in _get_module_details
      spec = importlib.util.find_spec(mod_name)
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/util.py", line 103, in find_spec
      return _find_spec(fullname, parent_path)
    File "<frozen importlib._bootstrap>", line 914, in _find_spec
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 79, in find_spec
      return method()
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 100, in spec_for_pip
      if self.pip_imported_during_build():
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 111, in pip_imported_during_build
      return any(
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 112, in <genexpr>
      frame.f_globals['__file__'].endswith('setup.py')
  KeyError: '__file__'
  Error: Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main
      return _run_code(code, main_globals, None,
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
      exec(code, run_globals)
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ensurepip/__main__.py", line [5](https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329#step:3:5), in <module>
      sys.exit(ensurepip._main())
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ensurepip/__init__.py", line 20[6](https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329#step:3:6), in _main
      return _bootstrap(
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ensurepip/__init__.py", line 125, in _bootstrap
      return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ensurepip/__init__.py", line 34, in _run_pip
      return subprocess.run([sys.executable, "-c", code], check=True).returncode
    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 516, in run
      raise CalledProcessError(retcode, process.args,
  subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.8/bin/python', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/var/folders/3m/p59k4qdj0f1[7](https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329#step:3:7)st0gn2cmj3640000gn/T/tmpezbv7_yj/setuptools-56.0.0-py3-none-any.whl\', \'/var/folders/3m/p5[9](https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329#step:3:9)k4qdj0f17st0gn2cmj3640000gn/T/tmpezbv7_yj/pip-21.1.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/var/folders/3m/p59k4qdj0f17st0gn2cmj3640000gn/T/tmpezbv7_yj\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.

https://github.com/pypa/setuptools/actions/runs/8844957694/job/24287879211?pr=4329

aparnajyothi-y commented 4 months ago

Hello @ZeroIntensity, We are supporting python 3.8 and 3.9 versions for macos arm64 now. Please test your workflows. Closing this issue for now and let us know to reopen this issue if the you are still facing the issue.

Hello @abravalheri, We have investigated the issue and we found that setup-python is successful on macos-latest. We have further more investigated by looking into your project about the issue and found that the file attribute is not found in the global scope of a module being used, which in this case is the setup.py file. The issue occurs in the context of the setup-python action when it tries to install setuptools and pip. The error is more likely to do with how the environment is configured in the action rather than the macOS version. We can add a step to upgrade setuptools before the step where the error occurs to resolve the issue.

name: Upgrade setuptools run: pip install --upgrade setuptools

we can change the setup.py file in the repository, consider replacing it with pyproject.toml and setup.cfg. The pyproject.toml file is a newer, more robust method of managing Python package builds and dependencies. Please raise new issue if the issue still exists as this issue is opened for Python 3.8 and 3.9 support on macOS.

abravalheri commented 4 months ago

Hello @abravalheri, We have investigated the issue and we found that setup-python is successful on macos-latest. We have further more investigated by looking into your project about the issue and found that the file attribute is not found in the global scope of a module being used, which in this case is the setup.py file. The issue occurs in the context of the setup-python action when it tries to install setuptools and pip. The error is more likely to do with how the environment is configured in the action rather than the macOS version.\nWe can add a step to upgrade setuptools before the step where the error occurs to resolve the issue.\n\nname: Upgrade setuptools\nrun: pip install --upgrade setuptools\n\nwe can change the setup.py file in the repository, consider replacing it with pyproject.toml and setup.cfg. The pyproject.toml file is a newer, more robust method of managing Python package builds and dependencies.\nPlease raise new issue if the issue still exists as this issue is opened for Python 3.8 and 3.9 support on macOS.

Hi @aparnajyothi-y thank you for investigating, but this explanation does not make much sense for me.

You suggested installing the updated version of setuptools before the step that is failing... The problem with this suggestion that the problem that is failing is the installation of Python itself... So, how should I update stuff when Python is not installed yet? The step that is failing is very much the first one, it should not depend on the code inside the repository, right?

The second suggestion about replacing setup.py with pyproject.toml, also does not work and actually contains a bit of misleading and innacurate information:

  1. pyproject.toml is by no means more robust, it is just a different configuration format.

  2. setup.py, setup.cfg and pyproject.toml are not mutually exclusive, they can all exist at the same time and do different things - that is exactly what happens in the repository with problems: we have all of these files at the same time.

Please note that the problem is happening for the repository of setuptools itself. Maybe that is related?