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

setup-python failing for 3.9 on macos-latest #981

Open
2 of 5 tasks
abravalheri opened this issue Dec 12, 2024 · 2 comments
Open
2 of 5 tasks

setup-python failing for 3.9 on macos-latest #981

abravalheri opened this issue Dec 12, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@abravalheri
Copy link

abravalheri commented Dec 12, 2024

Description:
The setup-python action started failing recently when installing Python 3.9 on the macos-latest.
Please note that the setup-python action is the second one to run, just after checkout (this was previously the case for 3.8, but not 3.9).

https://github.com/pypa/setuptools/actions/runs/12298183072/job/34321035714#step:3:49

2024-12-12T14:13:48.9877800Z Current runner version: '2.321.0'
2024-12-12T14:13:48.9908530Z ##[group]Operating System
2024-12-12T14:13:48.9909210Z macOS
2024-12-12T14:13:48.9909550Z 14.7.1
2024-12-12T14:13:48.9909990Z 23H222
2024-12-12T14:13:48.9910350Z ##[endgroup]
2024-12-12T14:13:48.9910700Z ##[group]Runner Image
2024-12-12T14:13:48.9911090Z Image: macos-14-arm64
2024-12-12T14:13:48.9911510Z Version: 20241202.580
2024-12-12T14:13:48.9912270Z Included Software: https://github.com/actions/runner-images/blob/macos-14-arm64/20241202.580/images/macos/macos-14-arm64-Readme.md
2024-12-12T14:13:48.9913350Z Image Release: https://github.com/actions/runner-images/releases/tag/macos-14-arm64%2F20241202.580
2024-12-12T14:13:48.9914070Z ##[endgroup]
2024-12-12T14:13:48.9914510Z ##[group]Runner Image Provisioner
2024-12-12T14:13:48.9915090Z 2.0.385.1+6d6c56aa16f1b9c7dd7935df5d63980397e44def
2024-12-12T14:13:48.9915550Z ##[endgroup]
2024-12-12T14:13:48.9916370Z ##[group]GITHUB_TOKEN Permissions
2024-12-12T14:13:48.9918010Z Contents: read
2024-12-12T14:13:48.9918400Z Metadata: read
2024-12-12T14:13:48.9918750Z ##[endgroup]
2024-12-12T14:13:48.9921160Z Secret source: Actions
2024-12-12T14:13:48.9921760Z Prepare workflow directory
2024-12-12T14:13:49.0566390Z Prepare all required actions
2024-12-12T14:13:49.0609520Z Getting action download info
2024-12-12T14:13:49.3415060Z Download action repository 'actions/checkout@v4' (SHA:11bd71901bbe5b1630ceea73d27597364c9af683)
2024-12-12T14:13:49.6328890Z Download action repository 'actions/setup-python@v5' (SHA:0b93645e9fea7318ecaed2b359559ac225c90a2b)
2024-12-12T14:13:49.7780230Z Download action repository 'actions/cache@v4' (SHA:1bd1e32a3bdc45362d1e726936510720a7c30a57)
2024-12-12T14:13:51.0723740Z Download action repository 'codecov/codecov-action@v4' (SHA:b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238)
2024-12-12T14:13:52.1695880Z Complete job name: test (3.9, macos-latest)
2024-12-12T14:13:52.2160910Z ##[group]Run actions/checkout@v4
2024-12-12T14:13:52.2161850Z with:
2024-12-12T14:13:52.2162370Z   repository: pypa/setuptools
2024-12-12T14:13:52.2163290Z   token: ***
2024-12-12T14:13:52.2163800Z   ssh-strict: true
2024-12-12T14:13:52.2164320Z   ssh-user: git
2024-12-12T14:13:52.2164870Z   persist-credentials: true
2024-12-12T14:13:52.2165470Z   clean: true
2024-12-12T14:13:52.2166020Z   sparse-checkout-cone-mode: true
2024-12-12T14:13:52.2166660Z   fetch-depth: 1
2024-12-12T14:13:52.2167190Z   fetch-tags: false
2024-12-12T14:13:52.2167740Z   show-progress: true
2024-12-12T14:13:52.2168290Z   lfs: false
2024-12-12T14:13:52.2168790Z   submodules: false
2024-12-12T14:13:52.2169330Z   set-safe-directory: true
2024-12-12T14:13:52.2170040Z env:
2024-12-12T14:13:52.2170520Z   FORCE_COLOR: 1
2024-12-12T14:13:52.2171070Z   PIP_DISABLE_PIP_VERSION_CHECK: true
2024-12-12T14:13:52.2171770Z   PIP_NO_PYTHON_VERSION_WARNING: true
2024-12-12T14:13:52.2172490Z   PIP_NO_WARN_SCRIPT_LOCATION: true
2024-12-12T14:13:52.2173240Z   TOX_OVERRIDE: testenv.pass_env+=GITHUB_*,FORCE_COLOR
2024-12-12T14:13:52.2174020Z   SETUPTOOLS_USE_DISTUTILS: local
2024-12-12T14:13:52.2174660Z ##[endgroup]
2024-12-12T14:13:52.4893350Z Syncing repository: pypa/setuptools
2024-12-12T14:13:52.4895110Z ##[group]Getting Git version info
2024-12-12T14:13:52.4895980Z Working directory is '/Users/runner/work/setuptools/setuptools'
2024-12-12T14:13:52.4897240Z [command]/opt/homebrew/bin/git version
2024-12-12T14:13:52.5520410Z git version 2.47.1
2024-12-12T14:13:52.5543570Z ##[endgroup]
2024-12-12T14:13:52.5549300Z Copying '/Users/runner/.gitconfig' to '/Users/runner/work/_temp/f3b14f8e-5b08-42ae-b57f-930399059772/.gitconfig'
2024-12-12T14:13:52.5555460Z Temporarily overriding HOME='/Users/runner/work/_temp/f3b14f8e-5b08-42ae-b57f-930399059772' before making global git config changes
2024-12-12T14:13:52.5557210Z Adding repository directory to the temporary git global config as a safe directory
2024-12-12T14:13:52.5562940Z [command]/opt/homebrew/bin/git config --global --add safe.directory /Users/runner/work/setuptools/setuptools
2024-12-12T14:13:52.5648180Z Deleting the contents of '/Users/runner/work/setuptools/setuptools'
2024-12-12T14:13:52.5650450Z ##[group]Initializing the repository
2024-12-12T14:13:52.5654770Z [command]/opt/homebrew/bin/git init /Users/runner/work/setuptools/setuptools
2024-12-12T14:13:52.5812600Z hint: Using 'master' as the name for the initial branch. This default branch name
2024-12-12T14:13:52.5814220Z hint: is subject to change. To configure the initial branch name to use in all
2024-12-12T14:13:52.5815540Z hint: of your new repositories, which will suppress this warning, call:
2024-12-12T14:13:52.5816450Z hint:
2024-12-12T14:13:52.5817100Z hint: 	git config --global init.defaultBranch <name>
2024-12-12T14:13:52.5817870Z hint:
2024-12-12T14:13:52.5819140Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2024-12-12T14:13:52.5820370Z hint: 'development'. The just-created branch can be renamed via this command:
2024-12-12T14:13:52.5821320Z hint:
2024-12-12T14:13:52.5821810Z hint: 	git branch -m <name>
2024-12-12T14:13:52.5822730Z Initialized empty Git repository in /Users/runner/work/setuptools/setuptools/.git/
2024-12-12T14:13:52.5825170Z [command]/opt/homebrew/bin/git remote add origin https://github.com/pypa/setuptools
2024-12-12T14:13:52.5996260Z ##[endgroup]
2024-12-12T14:13:52.6183700Z ##[group]Disabling automatic garbage collection
2024-12-12T14:13:52.6258540Z [command]/opt/homebrew/bin/git config --local gc.auto 0
2024-12-12T14:13:52.6261560Z ##[endgroup]
2024-12-12T14:13:52.6262710Z ##[group]Setting up auth
2024-12-12T14:13:52.6264260Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp core\.sshCommand
2024-12-12T14:13:52.6267380Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2024-12-12T14:13:52.7234480Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2024-12-12T14:13:52.7279290Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2024-12-12T14:13:52.8140700Z [command]/opt/homebrew/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2024-12-12T14:13:52.8203460Z ##[endgroup]
2024-12-12T14:13:52.8209420Z ##[group]Fetching the repository
2024-12-12T14:13:52.8211270Z [command]/opt/homebrew/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +37718aa8f0d00928010008d99546f58fa71e6e24:refs/remotes/origin/main
2024-12-12T14:13:53.6654220Z From https://github.com/pypa/setuptools
2024-12-12T14:13:53.6655490Z  * [new ref]         37718aa8f0d00928010008d99546f58fa71e6e24 -> origin/main
2024-12-12T14:13:53.6704490Z ##[endgroup]
2024-12-12T14:13:53.6705380Z ##[group]Determining the checkout info
2024-12-12T14:13:53.6706390Z ##[endgroup]
2024-12-12T14:13:53.6708240Z [command]/opt/homebrew/bin/git sparse-checkout disable
2024-12-12T14:13:53.6762460Z [command]/opt/homebrew/bin/git config --local --unset-all extensions.worktreeConfig
2024-12-12T14:13:53.6803360Z ##[group]Checking out the ref
2024-12-12T14:13:53.6805280Z [command]/opt/homebrew/bin/git checkout --progress --force -B main refs/remotes/origin/main
2024-12-12T14:13:53.7536420Z Switched to a new branch 'main'
2024-12-12T14:13:53.7638290Z branch 'main' set up to track 'origin/main'.
2024-12-12T14:13:53.7940400Z ##[endgroup]
2024-12-12T14:13:53.7942300Z [command]/opt/homebrew/bin/git log -1 --format=%H
2024-12-12T14:13:53.7943400Z 37718aa8f0d00928010008d99546f58fa71e6e24
2024-12-12T14:13:53.8084040Z ##[group]Run actions/setup-python@v5
2024-12-12T14:13:53.8084720Z with:
2024-12-12T14:13:53.8085180Z   python-version: 3.9
2024-12-12T14:13:53.8085720Z   allow-prereleases: true
2024-12-12T14:13:53.8086270Z   check-latest: false
2024-12-12T14:13:53.8086960Z   token: ***
2024-12-12T14:13:53.8087500Z   update-environment: true
2024-12-12T14:13:53.8088300Z env:
2024-12-12T14:13:53.8088750Z   FORCE_COLOR: 1
2024-12-12T14:13:53.8089380Z   PIP_DISABLE_PIP_VERSION_CHECK: true
2024-12-12T14:13:53.8090050Z   PIP_NO_PYTHON_VERSION_WARNING: true
2024-12-12T14:13:53.8090690Z   PIP_NO_WARN_SCRIPT_LOCATION: true
2024-12-12T14:13:53.8091420Z   TOX_OVERRIDE: testenv.pass_env+=GITHUB_*,FORCE_COLOR
2024-12-12T14:13:53.8092170Z   SETUPTOOLS_USE_DISTUTILS: local
2024-12-12T14:13:53.8092790Z ##[endgroup]
2024-12-12T14:13:53.9405530Z ##[group]Installed versions
2024-12-12T14:13:53.9478550Z Version ~3.9.0-0 was not found in the local cache
2024-12-12T14:13:54.9491810Z Version ~3.9.0-0 is available for downloading
2024-12-12T14:13:54.9492440Z Download from "https://github.com/actions/python-versions/releases/download/3.9.13-11183687820/python-3.9.13-darwin-arm64.tar.gz"
2024-12-12T14:13:55.9218940Z Extract downloaded archive
2024-12-12T14:13:55.9349340Z [command]/usr/bin/tar xz -C /Users/runner/work/_temp/5a42bdf7-3360-49a8-8184-ed45e19e9072 -f /Users/runner/work/_temp/abcdd745-fdba-4cde-84f4-c5a34341a574
2024-12-12T14:13:55.9856350Z Execute installation script
2024-12-12T14:13:55.9954570Z Check if Python hostedtoolcache folder exist...
2024-12-12T14:13:56.0004670Z Install Python binaries from prebuilt package
2024-12-12T14:14:08.1407560Z installer: Package name is Python
2024-12-12T14:14:08.1408830Z installer: Upgrading at base path /
2024-12-12T14:14:08.1409260Z installer: The upgrade was successful.
2024-12-12T14:14:08.1409960Z Create hostedtoolcach symlinks (Required for the backward compatibility)
2024-12-12T14:14:08.1410830Z Create Python 3.9.13 folder
2024-12-12T14:14:08.1413530Z Create additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)
2024-12-12T14:14:08.1452240Z Upgrading pip...
2024-12-12T14:14:08.1995650Z ##[error]Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 221, in run_module
2024-12-12T14:14:08.2011680Z ##[error]mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 130, in _get_module_details
    spec = importlib.util.find_spec(mod_name)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 103, in find_spec
    return _find_spec(fullname, parent_path)
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 79, in find_spec
    return method()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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.9/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 111, in pip_imported_during_build
    return any(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 112, in <genexpr>
    frame.f_globals['__file__'].endswith('setup.py')
KeyError: '__file__'
2024-12-12T14:14:08.2016600Z ##[error]Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
2024-12-12T14:14:08.2018630Z ##[error]return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
2024-12-12T14:14:08.2021510Z ##[error]exec(code, run_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ensurepip/__main__.py", line 5, in <module>
2024-12-12T14:14:08.2023550Z ##[error]sys.exit(ensurepip._main())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ensurepip/__init__.py", line 206, in _main
2024-12-12T14:14:08.2025390Z ##[error]return _bootstrap(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ensurepip/__init__.py", line 125, in _bootstrap
2024-12-12T14:14:08.2034670Z ##[error]return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ensurepip/__init__.py", line 34, in _run_pip
2024-12-12T14:14:08.2036790Z ##[error]return subprocess.run([sys.executable, "-c", code], check=True).returncode
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
2024-12-12T14:14:08.2038380Z ##[error]raise CalledProcessError(retcode, process.args,
2024-12-12T14:14:08.2042530Z ##[error]subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.9/bin/python', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/var/folders/0w/4z5l9vds32nbkz7l22n8j6s80000gn/T/tmpzbeydwkk/setuptools-58.1.0-py3-none-any.whl\', \'/var/folders/0w/4z5l9vds32nbkz7l22n8j6s80000gn/T/tmpzbeydwkk/pip-22.0.4-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/var/folders/0w/4z5l9vds32nbkz7l22n8j6s80000gn/T/tmpzbeydwkk\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
2024-12-12T14:14:08.2056270Z ##[error]The process '/bin/bash' failed with exit code 1
2024-12-12T14:14:08.2298000Z Post job cleanup.
2024-12-12T14:14:08.3661650Z [command]/opt/homebrew/bin/git version
2024-12-12T14:14:08.3925870Z git version 2.47.1
2024-12-12T14:14:08.3965340Z Copying '/Users/runner/.gitconfig' to '/Users/runner/work/_temp/b6465900-6518-44bb-b042-979cf6d4d2c1/.gitconfig'
2024-12-12T14:14:08.4036970Z Temporarily overriding HOME='/Users/runner/work/_temp/b6465900-6518-44bb-b042-979cf6d4d2c1' before making global git config changes
2024-12-12T14:14:08.4045150Z Adding repository directory to the temporary git global config as a safe directory
2024-12-12T14:14:08.4045950Z [command]/opt/homebrew/bin/git config --global --add safe.directory /Users/runner/work/setuptools/setuptools
2024-12-12T14:14:08.4093570Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp core\.sshCommand
2024-12-12T14:14:08.4147040Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2024-12-12T14:14:08.4852990Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2024-12-12T14:14:08.4903370Z http.https://github.com/.extraheader
2024-12-12T14:14:08.4907670Z [command]/opt/homebrew/bin/git config --local --unset-all http.https://github.com/.extraheader
2024-12-12T14:14:08.4952200Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2024-12-12T14:14:08.5616130Z Cleaning up orphan processes

Action version:
actions/setup-python@v5 - https://github.com/pypa/setuptools/actions/runs/12298183072/job/34321035714#step:3:1

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Python 3.9

Repro steps:
A description with steps to reproduce the issue. If your have a public example or repo to share, please provide the link.

https://github.com/pypa/setuptools/actions/runs/12298183072/job/34321035714#step:3:49

Expected behavior:

The setup-python action should successfully install Python 3.9 on macos-latest independently of the contents of the repository where the action is running.

Actual behavior:

The setup-python action fails to install Python 3.9 on macos-latest for the setuptools repository.


Please note that this problem has already been previously reported:

#860

The assessment in #860 (comment) that the problem is being caused by setuptools itself is not completely accurate.

While it is true that old versions of setuptools did expect every frame to contain a __file__ attribute, this bug in the setuptools has been fixed around 3 years ago pypa/setuptools@137ab9d.

What seems to be happening is that the host for the action has a pre-installed, very old version, and no longer supported version of setuptools, even before the action tries to run ensurepip. Because that old version of setuptools is installed in the host, ensurepip fails.

I believe that the best solution here is either:

  1. Guarantee that the host has the most up to date version of setuptools installed
  2. Guarantee that the host has no version of setuptools installed
  3. Ensure that all the installations of Python don't have any kind of "cross-contamination" regarding locations for libraries, so that an old version of setuptools does not get loaded when trying to install pip via ensurepip.
  4. Maybe run python -m ensurepip with some form of isolation flag (like -I)?

Also note that the issue is happening on the setuptools repository specifically, which may mean the following:

  • The setup-python can be affected by which folders and files are present on the current working directory when the action runs...
    • This can be problematic because people can have all sorts of files and directories in their repository and then they might affect how the action runs.
    • Possible solution: temporarily cd into /tmp before running the commands on setup-python? Or use some of the isolation flags when running Python scripts (e.g. -I)?

Please see more information in #860.

@abravalheri abravalheri added bug Something isn't working needs triage labels Dec 12, 2024
abravalheri added a commit to abravalheri/setuptools that referenced this issue Dec 12, 2024
abravalheri added a commit to pypa/setuptools that referenced this issue Dec 12, 2024
@mahabaleshwars
Copy link

Hello @abravalheri,
Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.

@priyagupta108
Copy link
Contributor

Hi @abravalheri,
There is no version of setuptools pre-installed on the macos-latest host. The setup-python action downloads Python packages from actions/python-versions, which are compiled from the official Python source.

The issue arises due to the behavior of the ensurepip module, which is bundled with the official Python source. For Python versions prior to 3.12, ensurepip module bundles specific version of setuptools in the Python's Lib directory for the corresponding Python version, and installs this bundled version of setuptools along with pip when executed. For reference, please see PEP 453.

The version of setuptools bundled with Python 3.9 is outdated and may not be compatible with certain configurations, causing the ensurepip command to fail.

To resolve this issue and ensure the setup process completes successfully, you can set the SETUPTOOLS_USE_DISTUTILS environment variable to stdlib. This workaround, suggested in issue #860, might help resolve conflicts for Python 3.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants