0

I am trying to install saxonC extension for python in mac OS for xml transformation using xsl and i am getting the below error when i run "python3 saxon-setup.py build_ext -if" as mentioned in the documentation here: https://www.saxonica.com/saxon-c/documentation11/index.html#!starting/installingpython

Error: clang: error: no such file or directory: '../DocumentBuilder.cpp' clang: error: no input files error: command '/usr/bin/clang' failed with exit code 1

  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 10 '22 at 06:22
  • Are you running `python3 saxon-setup.py build_ext -if` from the `python-saxon` folder inside of the `Saxon.C.API` folder? Is that HE or PE or EE you are trying? – Martin Honnen Jun 10 '22 at 07:49
  • @MartinHonnen Thank you for the catch, after i copy `Saxon.C.API` seems like it was successful with few warnings. But after i run `import saxonc` from the python-saxon folder I am getting below error. I am not sure why it is looking for eec.dylib, I am actualy using HE but i tried to rename the file to file it is looking for ended up with same error: import saxonc Unable to load /usr/local/lib/libsaxoneec.dylib Error: : Undefined error: 0 – user19292603 Jun 10 '22 at 15:43
  • Yes, sorry, I think there is a known issue with MacOS and SaxonC HE, see https://saxonica.plan.io/issues/5470 on how to fix it. – Martin Honnen Jun 10 '22 at 15:52
  • After i renamed the file to `libsaxoneec.dylib` in /usr/local/lib it is still giving the same error. Any inputs on this, do you think of any permissions issue: Unable to load /usr/local/lib/libsaxoneec.dylib Error: : Undefined error: 0 – user19292603 Jun 10 '22 at 16:02
  • The suggested fix is to edit the file `SaxonCGlue.c` to have line with `"/libsaxoneec.dylib"` changed to `"/libsaxonhec.dylib"` and then to recompile/rebuild any C/C++ and Python or PHP sample and library code. – Martin Honnen Jun 10 '22 at 16:16
  • The installation doc for Mac says something like "If you encounter permission issues after copying, then the privileges of the folders and files may need adjusting" but I am afraid I don't know details, perhaps better wait for other SaxonC and Mac users or @ond of Saxonica to tell you more. – Martin Honnen Jun 10 '22 at 16:19
  • Thanks @MartinHonnen I tried to update the glue file and then ran `python3 saxon-setup.py build_ext -if` but it is still the same error. Not sure if it is because i am on M1 chip, i will wait for their reply then : Unable to load /usr/local/lib/libsaxonhec.dylib Error: : Undefined error: 0 – user19292603 Jun 10 '22 at 18:12
  • Did you try to compile and execute the command samples or the C++/cpp samples? Do they run or do you get the same error? – Martin Honnen Jun 10 '22 at 19:37
  • I think the Saxonica guys might be busy this weekend at XmlPrague; but you might be right that the dylib library Saxonica provides might simply not work with the M1 ARM architecture. I am not sure, however, I think from a terminal using `file path/to/file.dylib` is supposed to tell you for which architectures the library works. – Martin Honnen Jun 11 '22 at 07:36
  • Thank you for reporting this problem. I am investigating this further. – ond1 Jun 11 '22 at 08:51
  • 1
    I have tried it on our M1 machine and yes I am seeing the same failure too. I have created the following bug issue to track this problem: https://saxonica.plan.io/issues/5559 I will investigate this further to see if we can find a workaround. – ond1 Jun 11 '22 at 13:52
  • There is also a possibility that Apple cannot verify the dylib library. Please try the following: sudo xattr -d -r com.apple.quarantine libsaxon-HEC-11.3/libsaxonhec.dylib – ond1 Jun 11 '22 at 14:14
  • 1
    Users of SaxonC on the M1 machines will encounter the following problem: Excelsior Jet produces the library libsaxonhec.dylib as an x86_64 file. The C/C++ samples and/or Python/PHP extensions they build on the machine will be as an arm64 file. This won’t work. The Python extension needs to be built on an x86_64. I will investigate a workaround – ond1 Jun 13 '22 at 10:09

2 Answers2

0

Run the following command to escape the unsigned library issue:

xattr -d -r com.apple.quarantine libsaxon-HEC-11.3/libsaxonhec.dylib

The SaxonC libsaxonhec.dylib library is an x86_64 file. Therefore the executables for the samples, Python and PHP extension also need to be built as an x86_64 file.

The following command for building the SaxonC python extension should work:

arch -x86_64 python3 saxon-setup.py build_ext -if

Unfortunately python3 needs to be run as x86_64:

arch -x86_64 python3 saxon_example3.py

ond1
  • 691
  • 6
  • 10
  • The compilation of the extension as described works for me but the running of the example fails with `Startup: dladdr() failed.` – Martin Honnen Jun 13 '22 at 11:00
  • which example did you run? – ond1 Jun 13 '22 at 11:03
  • `arch -x86_64 python3 saxon_example3.py` and `arch -x86_64 python3 saxon_example2.py` – Martin Honnen Jun 13 '22 at 11:14
  • That is strange. I am running these samples without problem. Wondering what is different to your machine? I am using Python 3.8.9. I have also upgraded pip3 and Cython. Not sure if that makes a difference. – ond1 Jun 13 '22 at 11:17
  • Also running SaxonC-HE – ond1 Jun 13 '22 at 11:18
  • Python here is Python 3.8.9 as well. The building/compilation of the extension spews out a lot of warnings, but that happens on usable builds under Windows and Linux as well. It is hard to find those that matter, it might be that the Mac in a cloud I tried on doesn't have the right C++ tools as some warnings are on `auto` declarations being C++ 11 only, not sure whether I got those on Windows as well and just ignored them like the rest. – Martin Honnen Jun 13 '22 at 11:33
  • I am using Mac Mini with an M1 chip. > g++ --version Apple clang version 13.1.6 (clang-1316.0.21.2.5) Target: arm64-apple-darwin21.5.0 Thread model: posix – ond1 Jun 13 '22 at 11:36
  • I get `Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin20.6.0Thread model: posix`. Let's perhaps wait whether the original poster has more luck on his/her machine with your suggestion, I am kind of beyond my skillset if C++ build problems on a Mac happen. – Martin Honnen Jun 13 '22 at 11:42
  • Got it to work on one Mac Mini M1 but only after lots of attempt to run it and step by step acceptance/permission to MacOS to execute all the unsigned dynlibs making up SaxonC or the Excelsior runtime. – Martin Honnen Jun 13 '22 at 20:35
0

SaxonC 12.0 now supports M1 chip. Also SaxonC is available as a Pypi package which will make installation easier. See: https://pypi.org/user/saxonica/

ond1
  • 691
  • 6
  • 10