Skip to content

Dataflow not working in macOS #419

@dgarijo

Description

@dgarijo

In MacOS, we have the following error:

OSError: dlopen(/Users/rf208/inspect4py/inspect4py/resources/python_unix.so, 0x0006): tried: '/Users/rf208/inspect4py/inspect4py/resources/python_unix.so' (not a mach-o file), '/usr/local/lib/python_unix.so' (not a mach-o file), '/usr/lib/python_unix.so' (no such file)

Solution: We need to create a .so file for mac. Steps (following this doc: https://github.com/tree-sitter/py-tree-sitter#usage):

  1. git clone https://github.com/tree-sitter/tree-sitter-python
  2. Run:
from tree_sitter import Language, Parser

Language.build_library(
  # Store the library in the `build` directory
  'my-languages.so',

  # Include one or more languages
  [
    'path_to_cloned_repo/tree-sitter-python'
  ]
)
  1. This will create a file called "my-languages.so". Rename to "python_macOS.so"
  2. Add the file to folder: inspect4py/resources/
  3. Change line 1266 in cli.py:
if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
                language = Language(path_to_languages + os.path.sep + "python_win.so", "python")
            else:
                language = Language(path_to_languages + os.path.sep + "python_unix.so", "python")

to be

if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
    language = Language(path_to_languages + os.path.sep + "python_win.so", "python")
elif sys.platform.startswith("darwin"):
    language = Language(path_to_languages + os.path.sep + "python_macOS.so", "python")
else:
    language = Language(path_to_languages + os.path.sep + "python_unix.so", "python")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions