Building and testing SWIG, get "file system relative paths not allowed in hardened programs"

Viewed 272

I'm trying to build swig on macOS Catalina 10.15.7.

I was originally getting "file system relative paths not allowed in hardened programs" when using the system perl to build swig. I installed my own version of perl from source, and it seems to get further. I can build swig, but I'm still getting one error: "file system relative paths not allowed in hardened programs" when I run "make check".

Error message:

...
checking Examples/python/import_packages
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/tom/PycharmProjects/SpeechRecognitionTest/swig-4.0.2/Examples/python/import_packages/same_modnames1/pkg2/foo.py", line 13, in <module>
    from . import _foo
ImportError: dlopen(pkg2/_foo.so, 2): no suitable image found.  Did find:
    file system relative paths not allowed in hardened programs
Traceback (most recent call last):
  File "runme.py", line 26, in <module>
    run_except_on_windows(commandline)
  File "runme.py", line 8, in run_except_on_windows
    subprocess.check_call(commandline, env=env, shell=True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -m pkg2.foo' returned non-zero exit status 1
make[4]: *** [python_run] Error 1
make[3]: *** [check] Error 2
make[2]: *** [check] Error 1
make[1]: *** [import_packages.actionexample] Error 2

My goal is to use python 3.9, not python 2.7, but "make check" seems to check python 2.7. I tried using 3.9 and a venv, and "make check" just fails on print calls that don't have (), so I assume the test suite is 2.7 only.

From googling, "file system relative paths not allowed in hardened programs" seems to be due to some new macOS security feature. Moving to my own build of perl, and setting CPATH to that version reducted the numbers of these errors I got. But I still have one.

Can I proceed if I'm not using python 2.7? Is there a way to fix this?

I'm actually just trying to build PocketSphinx, which uses swig.

0 Answers
Related