SoftwareUnderstanding / inspect4py

Static code analysis package for Python repositories
https://inspect4py.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
27 stars 10 forks source link

Dataflow not working in macOS #419

Closed dgarijo closed 1 year ago

dgarijo commented 1 year ago

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' ] )

3. This will create a file called "my-languages.so". Rename to "python_macOS.so"
4. Add the file to folder: `inspect4py/resources/`
5. 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")

dgarijo commented 1 year ago

Oh, and also change the corresponding test file

OEG-Clark commented 1 year ago

Done in the new pull request, if anything, let me know, on it ASAP

dgarijo commented 1 year ago

The PR has conflicting files. You should pull the latest version of the repository, not from your previous fork