libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
532 stars 304 forks source link

Cannot build against Python.framework on macOS #188

Open James-Hudson3010 opened 3 years ago

James-Hudson3010 commented 3 years ago

On macOS, it is common to have a python installation which creates Python.framework. For example, the .dmg installers from python.org will do this. It can also be done using pyenv with (for example):

PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.8.5

If I use a build from pyenv with the Python.framework (version does not appear to matter) and then call autogen, I get the following error:

configure: error: in `/Users/jamesh/depot_localsoftware/libplist':
configure: error:
  Could not link test program to Python. Maybe the main Python library has been
  installed in some non-standard library path. If so, pass it to configure,
  via the LIBS environment variable.
  Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
  ============================================================================
   ERROR!
   You probably have to install the development version of the Python package
   for your distribution.  The exact name of this package varies among them.
  ============================================================================

I did try as it suggested and set the LIBS variable to various paths, but that did not help. Looking at config.log, I saw the source the failure:

configure:18078: clang -o conftest -g -O2  -I/Users/jamesh/.pyenv/versions/3.8.5/Python.framework/Versions/3.8/include/python3.8  -Wl,-stack_size,1000000  -framework CoreFoundation Python.framework/Versions/3.8/Python conftest.c  -L/Users/jamesh/.pyenv/versions/3.8.5/lib -lpython3.8 -lintl -ldl   -framework CoreFoundation  -lintl -ldl   -framework CoreFoundation  >&5
clang: error: no such file or directory: 'Python.framework/Versions/3.8/Python'

If I try the line manually with the full path to Python.framework/Versions/3.8/Python, it will find what it needs. Although, conftest.c will then not be found...I am not sure where that file comes from.

It is unclear how to call autogen so libplist will build in this context.

Note, that the sysconfig module can be used to obtain the information needed to understand how Python was installed on macOS. Some relevant variables are:

PYTHONFRAMEWORK = "Python"
PYTHONFRAMEWORKDIR = "Python.framework"
PYTHONFRAMEWORKINSTALLDIR = "/Users/jamesh/.pyenv/versions/3.8.5/Python.framework"
PYTHONFRAMEWORKPREFIX = "/Users/jamesh/.pyenv/versions/3.8.5"

when Python.framework is not being used, these variables are:

PYTHONFRAMEWORK = ""
PYTHONFRAMEWORKDIR = "no-framework"
PYTHONFRAMEWORKINSTALLDIR = ""
PYTHONFRAMEWORKPREFIX = ""
jagdish24 commented 2 years ago

@James-Hudson3010 Have you found any solution yet? I am getting same.

nikias commented 2 years ago

This is what I do for the github actions build workflow: https://github.com/libimobiledevice/libplist/blob/master/.github/workflows/build.yml#L63-L77

LangeZhao commented 2 years ago

try export PYTHON=python3 then ./autogen.sh

Ren-Qan commented 1 year ago

try ./autogen.sh CFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=10.11" --without-cython