ElementsProject / libwally-core

Useful primitives for wallets
Other
282 stars 135 forks source link

Build problems on stock Sonoma: "configure: error: Cannot find python in your system path" #443

Closed ChristopherA closed 8 months ago

ChristopherA commented 8 months ago

Fresh install of macOS Sonoma 14.2.1 using UTM virtual machine on on MacBookPro M1 Max (i.e. brand new development environment, no other apps installed).

I've installed brew, then brew install autoconf automake gnu-sed libtool without errors.

I have successfully run:

git submodule init
git submodule sync --recursive
git submodule update --init --recursive
./tools/autogen.sh

However, when I get to ./configure:

% ./configure
checking build system type... aarch64-apple-darwin23.2.0
checking host system type... aarch64-apple-darwin23.2.0
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
…
checking whether C compiler accepts -fvisibility=hidden... yes
checking for memset_s... yes
checking for explicit_bzero... no
checking for explicit_memset... no
checking whether we can use inline asm code... yes
checking for byteswap.h... no
checking for sys/mman.h... yes
checking how to run the C preprocessor... gcc -E
checking for egrep -e... (cached) /usr/bin/grep -E
checking whether gcc is Clang... yes
checking whether pthreads work with "-pthread" and "-lpthread"... yes
checking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... no
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for asm/page.h... no
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for python... no
configure: error: Cannot find python in your system path

I then did brew install python3, same error. I presume that python3 is not what ./configure expects. So I tried alias:

> whereis python3
python3: /usr/bin/python3 /opt/homebrew/share/man/man1/python3.1
> python3 --version
Python 3.9.6
% which python
python not found
% which python3
/opt/homebrew/bin/python3
% echo 'alias python="python3"' >> ~/.zshrc && source ~/.zshrc;
% which python                            
python: aliased to /opt/homebrew/bin/python3
% python --version
Python 3.11.7

Still no luck ./configure still reports Cannot find python in your system path.

My best guess is that some sub-shell is not getting the alias.

There are a number of hacks to install multiple versions of python, but it is unclear even why building libwally-core requires python, or which python it needs. But currently on stock macOS Sonoma it doesn't build.

Two requests: if you have a quick fix of a different install of python, let me know in this issue. But ideally, since we are using this downstream in keytool-cli and some other apps, we'd prefer to know exactly what build dependency will make building on macOS work. This may mean you to trick like you do with gnu-sed (as sed on macOS is different than everywhere else).

(this was originally reported in downstream keytool https://github.com/BlockchainCommons/keytool-cli/issues/27 that uses libwally-core, but it is reproducible with libwally-core build instructions.)

jgriffiths commented 8 months ago

Hi @ChristopherA ,

Remove the alias, that will not be useful.

The python lookup expects to find a python interpreter in the path. If one is not available, set the PYTHON_VERSION environment variable to the interpreters version. e.g. if you have python3 in the path, then run:

PYTHON_VERSION=3 ./configure ...

As documented in the Python section of wally's README.md

If you are building a C/C++ executable then you should probably be passing --disable-swig-python --disable-swig-java --disable-js-wrappers to configure.

jgriffiths commented 8 months ago

Worth noting that your boxes python setup is rather screwed up.

% which python
python not found
> whereis python3
python3: /usr/bin/python3 /opt/homebrew/share/man/man1/python3.1
> python3 --version
Python 3.9.6
% which python3
/opt/homebrew/bin/python3

Claims that /opt/homebrew/bin/python3 is v 3.9.6.

% echo 'alias python="python3"' >> ~/.zshrc && source ~/.zshrc;
% which python                            
python: aliased to /opt/homebrew/bin/python3
% python --version
Python 3.11.7

Now somehow its v3.11.7? Something is amiss here.