Installing PyMuPDF on a prerelease Python
I recently installed Python 3.13.0 rc2 to test rst2pdf against it and found that I couldn’t install PyMyPDF which is required for the tests.
$ pip install pymupdf ...
This is because for a pre-release version, binary wheels are not provided to PyPI for the mupdf dependency which is written in C++. Hence, the compiler needs the headers.
On my Mac, I had the CPATH environment variable set to /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include.
For mypdf to compile, I needed it set to Xcode’s path. This is most easily cound with:
$ echo `xcrun --show-sdk-path`/usr/include
On my computer, this is /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include.
Hence, to install, I used used:
export CPATH=`xcrun --show-sdk-path`/usr/include $ pip install pymupdf
PyMuPDF now installs and I can continue what I was doing.