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

Provide "python3.x-intel64" command with macOS universal2 framework builds #88175

Closed
ned-deily opened this issue May 2, 2021 · 4 comments
Closed
Assignees
Labels
3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes OS-mac

Comments

@ned-deily
Copy link
Member

BPO 44009
Nosy @ronaldoussoren, @ned-deily, @miss-islington
PRs
  • bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs #25804
  • [3.9] bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25804) #25807
  • [3.8] bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25807) #25810
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ned-deily'
    closed_at = <Date 2021-05-02.10:56:39.641>
    created_at = <Date 2021-05-02.07:23:23.057>
    labels = ['OS-mac', '3.8', '3.9', '3.10']
    title = 'Provide "python3.x-intel64" command with macOS universal2 framework builds'
    updated_at = <Date 2021-05-02.10:56:39.641>
    user = 'https://github.com/ned-deily'

    bugs.python.org fields:

    activity = <Date 2021-05-02.10:56:39.641>
    actor = 'ned.deily'
    assignee = 'ned.deily'
    closed = True
    closed_date = <Date 2021-05-02.10:56:39.641>
    closer = 'ned.deily'
    components = ['macOS']
    creation = <Date 2021-05-02.07:23:23.057>
    creator = 'ned.deily'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44009
    keywords = ['patch']
    message_count = 4.0
    messages = ['392669', '392676', '392677', '392687']
    nosy_count = 3.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'miss-islington']
    pr_nums = ['25804', '25807', '25810']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44009'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @ned-deily
    Copy link
    Member Author

    On certain macOS configurations, it is possible to have a universal build (one that contains executables and libraries with binaries for more than one CPU architecture combined into "fat" files) where running with a choice of archs. Examples in the past included Intel-64 (x86_64) vs Intel-32 (i386) vs (in macOS 10.5 and 10.6) ppc (using Rosetta emulation. While it is possible to use the macOS arch utility to select a non-default arch for execution:
    arch -i386 /usr/local/bin/python3
    this method does not handle the common case of a Python program spawning another Python subprocess (to run a test, say) by calling the subprocess module to execute the interpreter binary recorded in sys.executable, which only contains the interpreter executable file name, not the arch command. Thus the subprocess attempts to launch in the default arch for the configuration rather than the overriden arch, which may cause program failures or incorrect results. To get around this where appropriate, framework universal builds on macOS provided an additional 32-bit-only python3.x executable file, python3.x-32, that solves this problem: by invoking Python with python3.x-32, the main interpreter process runs in 32-bit mode and any spawned subprocesses using sys.executable will also run in 32-bit mode.

    With the introduction of Apple Silicon Macs and their support for running x86_64 Intel-64 binaries with Rosetta 2 emulation, the need to be able to force Python to run a non-default arch reliably is again important for the transition period while third-party packages are being ported or tested on the new arm64-based Macs. For example, there are some popular packages on PyPI that do not yet provide universal2 or just arm64 wheels but, by forcing Python to run in Intel mode, existing wheels can be tested and used.

    To that end, the PR for this issue adds a "python3.x-intel64" and "python3-intel64" executable or symlink, as needed, when installing a macOS "universal2" framework build, similar to the "python3.x-32" and "python3-32" links installed for macOS "intel" framework builds.

    An example:

    $ sw_vers 
    ProductName:	macOS
    ProductVersion:	11.3
    BuildVersion:	20E232
    $ uname -a
    Darwin pyb20 20.4.0 Darwin Kernel Version 20.4.0: Fri Mar  5 01:14:02 PST 2021; root:xnu-7195.101.1~3/RELEASE_ARM64_T8101 arm64
    $ python3.8 -m pip install --only-binary ':all:' numpy
    ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
    ERROR: No matching distribution found for numpy
    $ python3.8-intel64 -m pip install --only-binary ':all:' numpy 
    Collecting numpy
      Using cached numpy-1.20.2-cp38-cp38-macosx_10_9_x86_64.whl (16.0 MB)
    Installing collected packages: numpy
    Successfully installed numpy-1.20.2

    Of course, for this to be useful assumes that running under Rosetta 2 emulation provides the correct results. Testing is advised!

    @ned-deily ned-deily added 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes labels May 2, 2021
    @ned-deily ned-deily self-assigned this May 2, 2021
    @ned-deily ned-deily added OS-mac 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes labels May 2, 2021
    @ned-deily ned-deily self-assigned this May 2, 2021
    @ned-deily
    Copy link
    Member Author

    New changeset 0cb33da by Ned Deily in branch 'master':
    bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25804)
    0cb33da

    @miss-islington
    Copy link
    Contributor

    New changeset de0e3f8 by Miss Islington (bot) in branch '3.9':
    [3.9] bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25804) (GH-25807)
    de0e3f8

    @ned-deily
    Copy link
    Member Author

    New changeset 78e5588 by Ned Deily in branch '3.8':
    bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25810)
    78e5588

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes OS-mac
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants