Skip to content

All python build from source fail with error on my Mac #122050

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

Closed
matthewyang204 opened this issue Jul 20, 2024 · 5 comments
Closed

All python build from source fail with error on my Mac #122050

matthewyang204 opened this issue Jul 20, 2024 · 5 comments
Labels
build The build process and cross-build OS-mac type-bug An unexpected behavior, bug, or error

Comments

@matthewyang204
Copy link

matthewyang204 commented Jul 20, 2024

Bug report

Bug description:

Undefined symbols for architecture arm64:
  "_libintl_bindtextdomain", referenced from:
      __locale_bindtextdomain in _localemodule.o
      __locale_bindtextdomain in _localemodule.o
  "_libintl_dcgettext", referenced from:
      __locale_dcgettext in _localemodule.o
  "_libintl_dgettext", referenced from:
      __locale_dgettext in _localemodule.o
  "_libintl_gettext", referenced from:
      __locale_gettext in _localemodule.o
  "_libintl_setlocale", referenced from:
      __locale_setlocale in _localemodule.o
      __locale_setlocale in _localemodule.o
      __locale_localeconv in _localemodule.o
      __locale_localeconv in _localemodule.o
      __locale_localeconv in _localemodule.o
      __locale_localeconv in _localemodule.o
  "_libintl_textdomain", referenced from:
      __locale_textdomain in _localemodule.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Programs/_freeze_module] Error 1

CPython versions tested on:

3.13

Operating systems tested on:

macOS

@matthewyang204 matthewyang204 added the type-bug An unexpected behavior, bug, or error label Jul 20, 2024
@matthewyang204 matthewyang204 changed the title Python 3.13 beta refuses to build with error All python build from source fail with error on my Mac Jul 20, 2024
@ZeroIntensity
Copy link
Member

I'm not sure this is a CPython issue. Based on this issue, this issue, and this issue from Pyenv, it looks like you're attempt to build CPython for ARM64 from an x86 Homebrew installation.

@ronaldoussoren ronaldoussoren added OS-mac build The build process and cross-build labels Jul 20, 2024
@ronaldoussoren
Copy link
Contributor

As @ZeroIntensity writes this is due to having some libraries on the system that don't support the arm64 architecture, with as the most likely explanation that you have a homebrew installation for x86_64.

One way to verify: configure python with configure --enable-universalsdk --with-universal-archs=intel-64.

@ronaldoussoren ronaldoussoren closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2024
@matthewyang204
Copy link
Author

matthewyang204 commented Jul 25, 2024

Okay, so it seems to have worked correctly this time until the very end, during sudo make install:

ginstall: cannot stat 'Modules/_blake2.cpython-313-darwin.so': No such file or directory

Edit:
Nevermind, most of it works anyway. I think blake2 is a module or something. It also failed to import during the initial ./configure. May want to take a look at it anyway, but the majority of the interpreter works.

@1oh1
Copy link

1oh1 commented May 14, 2025

What worked for me (trying to build arm64 version of Python using pyenv) was to install gettext with brew install gettext

Also, if you have multiple Homebrew versions installed, you may want to use something like this in your shell profile:

if [[ $(arch) != arm64* ]]
then
    # x86_64 Homebrew
    eval "$(/usr/local/bin/brew shellenv)"
    export PYENV_ROOT="$HOME/.pyenv-x86"
else
    # arm64 Homebrew
    eval "$(/opt/homebrew/bin/brew shellenv)"
    export PYENV_ROOT="$HOME/.pyenv"
    export LDFLAGS="-L/opt/homebrew/lib"
    export CPPFLAGS="-I/opt/homebrew/include"
fi

# PyENV config
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - zsh)"

@ned-deily
Copy link
Member

For the record, having GNU gettext, which is GPLv3-licensed, is not required to build and run Python other than for some specific uses like for the gettext internationalization module. The build system looks for a libintl.h to determine whether to attempt to build with gettext. Apple does not supply gettext with macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build OS-mac type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants