Unable to compile Python3.12 on macOS 14.3.1

Hi,

I had been using Python 3.11 compiled from python/cpython for a while.

However, I haven’t been able to compile Python 3.12 on macOS Sonoma so far.

Here’s were the steps I tried to compile Python 3.12 from source:

  1. Install dependencies
brew install pkg-config openssl@3.0 xz gdbm tcl-tk
  1. Run configure
cd python/cpython/
git checkout 3.12

GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
   GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \
   ./configure --with-pydebug \
               --with-openssl="$(brew --prefix openssl@3.0)"
  1. Make
make -j2

which complains by saying

Python/deepfreeze/deepfreeze.c:47968:14: error: no member named '_py_zipimporter' in 'struct _Py_global_strings::(unnamed at ./Include/internal/pycore_global_strings.h:59:5)'
            &_Py_ID(zipimporter),
             ^~~~~~~~~~~~~~~~~~~
./Include/internal/pycore_global_strings.h:768:41: note: expanded from macro '_Py_ID'
     (_Py_SINGLETON(strings.identifiers._py_ ## NAME._ascii.ob_base))
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<scratch space>:187:1: note: expanded from here
_py_zipimporter
^

Did I miss anything? or is Install dependencies out-of-date?

I’ve had no problem with a similar setup, though I don’t generally configure using --with-pydebug. Does the problem disappear if you get rid of that?

I used your configure command, but ran git clean -fdx beforehand. I had no compile issue.

It is possible there are dependency issues. Does it compile for you with the above git clean command?

1 Like

Thanks! Running git clean -fdx beforehand addressed my issue.

Meanwhile, removing --with-pydebug had no effect on my problem originally.

1 Like

I only recently learned about git clean -fdx from one of the core devs (whose name isn’t coming to me right now) in relation to using git bisect to track down an error-causing commit. I can’t claim to have a crystal ball in this regard.

2 Likes

If you want to see what git clean will remove, you can use the interactive option git clean -fdxi.

This is something that we should consider adding to the devguide alongside make clean.