Skip to content

Add universal2 builds of Python to actions/setup-python #4133

@bwoodsend

Description

@bwoodsend

Tool name

universal2 builds of Python for macOS

Tool license

Python software foundation

Add or update?

  • Add
  • Update

Desired version

latest (3.9.6)

Approximate size

40MB in .pkg form. 150MB installed

Brief description of tool

As you're probably aware, Apple are transitioning from x86_64 to arm64. Whilst x86_64 machines are still around, Apple are encouraging software authors to ship universal2 applications which are executables for both x86_64 and arm64 glued together into one file and the OS is able to select the right half of the executable to run at runtime. The latest versions of Python on https://python.org/downloads now have a macOS 64-bit universal2 installer download option.

Given that the CI/CD servers are all x86_64, you're probably wondering why any of the above matters. Well... Python package authors are now also required to build their C extensions for macOS universal2 too. On the plus side, Python does this all automatically if the Python installation itself is compiled universal2. On the down side, there is no other way to build universal2 Python packages.

So long story short, without trying to do some wget https://www.python.org/ftp/python/3.9.6/python-3.9.6-macos11.pkg; sudo installer -pkg python-3.9.6-macos11.pkg -target / scariness to install Python directly from python.org, it is impossible to build Python packages from macOS arm64 on Github Actions.

One thing to note, building universal2 Pythons does not require access to arm64 machines - rather they can be cross compiled provided you have XCode >= 12.2 installed.

URL for tool's homepage

No response

Provide a basic test case to validate the tool's functionality.

test `lipo -archs $(which python)` = "x86_64 arm64"

Virtual environments affected

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11
  • Windows Server 2016
  • Windows Server 2019
  • Windows Server 2022

Can this tool be installed during the build?

No response

Tool installation time in runtime

No response

Are you willing to submit a PR?

I can try...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions