libplist icon indicating copy to clipboard operation
libplist copied to clipboard

Cannot build against Python.framework on macOS

Open James-Hudson3010 opened this issue 4 years ago • 4 comments

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 = ""

James-Hudson3010 avatar Feb 22 '21 13:02 James-Hudson3010

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

jagdish24 avatar Dec 10 '21 13:12 jagdish24

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

nikias avatar Dec 10 '21 14:12 nikias

try export PYTHON=python3 then ./autogen.sh

LangeZhao avatar Dec 23 '21 10:12 LangeZhao

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

Ren-Qan avatar Nov 08 '22 07:11 Ren-Qan