When using the package manager pyenv, I have been unable to build the plist module linked to the correct version of Python. It is possible to build the module with Homebrew or the system Python installation but not without some changes.
Python 2.7.16 has been used below for all methods (Python 3 has other issues).
pyenv
Many combinations of LDFLAGS and other variables were tried unsuccessfully, the "Could not link test program to Python" error was not shown and the correct Python directories were found.
Fatal Python error: PyThreadState_Get: no current thread
./python-pyenv.sh: line 29: 10120 Abort trap: 6 python -c 'import plist; print(dir(plist))'
/usr/local/lib/python2.7/site-packages/plist.so:
/usr/local/lib/libplist.3.dylib (compatibility version 6.0.0, current version 6.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
Homebrew
This is the most straightforward process, although the unsupported python@2 formula must be used.
/usr/local/lib/python2.7/site-packages/plist.so:
/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/local/lib/libplist.3.dylib (compatibility version 6.0.0, current version 6.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
macOS Python
Unlike the Homebrew steps, the PYTHONPATH environment variable must be set.
Build script
```bash
#!/bin/bash
PYTHON_VERSION=2.7.16
if ! [ -x "$(command -v pip)" ]; then
sudo easy_install pip
fi
# Install Cython
pip install cython
export PATH=$PATH:$HOME/Library/Python/${PYTHON_VERSION%.*}/bin
# Compile libplist
export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION%.*}/site-packages
git clone git@github.com:libimobiledevice/libplist.git && cd libplist
./autogen.sh
make && make install
# Test
python -c 'import plist; print dir(plist)'
otool -L /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist.so
# Cleanup
pip uninstall -y cython
rm /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist*
rm -rf ../libplist
```
otool -L output:
/usr/local/lib/python2.7/site-packages/plist.so:
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.16)
/usr/local/lib/libplist.3.dylib (compatibility version 6.0.0, current version 6.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
When using the package manager pyenv, I have been unable to build the
plist
module linked to the correct version of Python. It is possible to build the module with Homebrew or the system Python installation but not without some changes.Python 2.7.16 has been used below for all methods (Python 3 has other issues).
pyenv
Many combinations of
LDFLAGS
and other variables were tried unsuccessfully, the "Could not link test program to Python" error was not shown and the correct Python directories were found.Build script
```bash #!/bin/bash PYTHON_VERSION=2.7.16 # Install Python brew install pyenv eval "$(pyenv init -)" pyenv install $PYTHON_VERSION pyenv global $PYTHON_VERSION # Install Cython pip install cython # Compile libplist git clone git@github.com:libimobiledevice/libplist.git && cd libplist ./autogen.sh make && make install # Test python -c 'import plist; print(dir(plist))' otool -L /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist.so # Cleanup # pip uninstall -y cython brew uninstall pyenv rm /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist* rm -rf ../libplist ```Python error
otool -L
output:Homebrew
This is the most straightforward process, although the unsupported python@2 formula must be used.
Build script
```bash #!/bin/bash PYTHON_VERSION=2.7.16_1 # Install Python brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0fc3f51093fe10c570eb777b04c93d86640f9e80/Formula/python@2.rb # Install Cython pip install cython # Compile libplist git clone git@github.com:libimobiledevice/libplist.git && cd libplist ./autogen.sh make && make install # Test python -c 'import plist; print dir(plist)' otool -L /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist.so # Cleanup pip uninstall -y cython brew uninstall python@2.rb rm /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist* rm -rf ../libplist ```otool -L
output:macOS Python
Unlike the Homebrew steps, the
PYTHONPATH
environment variable must be set.Build script
```bash #!/bin/bash PYTHON_VERSION=2.7.16 if ! [ -x "$(command -v pip)" ]; then sudo easy_install pip fi # Install Cython pip install cython export PATH=$PATH:$HOME/Library/Python/${PYTHON_VERSION%.*}/bin # Compile libplist export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION%.*}/site-packages git clone git@github.com:libimobiledevice/libplist.git && cd libplist ./autogen.sh make && make install # Test python -c 'import plist; print dir(plist)' otool -L /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist.so # Cleanup pip uninstall -y cython rm /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/plist* rm -rf ../libplist ```otool -L
output: