Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'set' object does not support indexing #34

Open
janisozaur opened this issue Nov 1, 2018 · 2 comments
Open

TypeError: 'set' object does not support indexing #34

janisozaur opened this issue Nov 1, 2018 · 2 comments

Comments

@janisozaur
Copy link

Using 13e0a6b with Python 3.7.1 on a following (redacted, simplified, but roughly the same) compile_commands.json, I get following error:

$ json2cmake      
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Traceback (most recent call last):
  File "/home/janisozaur/.local/bin/json2cmake", line 10, in <module>
    sys.exit(main())
  File "/home/janisozaur/.local/lib/python3.7/site-packages/json2cmake/__init__.py", line 223, in main
    database.write(args.outfile, name=args.name)
  File "/home/janisozaur/.local/lib/python3.7/site-packages/json2cmake/__init__.py", line 122, in write
    name = os.path.basename(os.path.commonprefix(files).rstrip("/_"))
  File "/usr/lib/python3.7/genericpath.py", line 76, in commonprefix
    if not isinstance(m[0], (list, tuple)):
TypeError: 'set' object does not support indexing
[
    {
        "arguments": [
            "/usr/bin/gcc",
            "-c",
            "-m64",
            "-fPIC",
            "-pipe",
            "-fno-strict-aliasing",
            "-Og",
            "-g",
            "-fno-omit-frame-pointer",
            "-I.",
            "-I../../include",
            "-o",
            "ccc.o",
            "../../../foo/bar_43/ccc.c"
        ],
        "directory": "/home/janisozaur/workspace/foo-build/bar_43",
        "file": "../../../foo/bar_43/ccc.c"
    },
    {
        "arguments": [
            "gcc",
            "-c",
            "-m64",
            "-I.",
            "-I../../include",
            "-fPIC",
            "-pipe",
            "-fno-strict-aliasing",
            "-Og",
            "-g",
            "-fno-omit-frame-pointer",
            "-o",
            "aaa.o",
            "../../../foo/bar_43/aaa.c"
        ],
        "directory": "/home/janisozaur/workspace/foo-build/bar_43",
        "file": "../../../foo/bar_43/aaa.c"
    },
    {
        "arguments": [
            "/usr/bin/gcc",
            "-c",
            "-m64",
            "-fPIC",
            "-pipe",
            "-fno-strict-aliasing",
            "-Og",
            "-g",
            "-fno-omit-frame-pointer",
            "-I.",
            "-I../../include",
            "-o",
            "bbb.o",
            "../../../foo/bar_43/bbb.c"
        ],
        "directory": "/home/janisozaur/workspace/foo-build/bar_43",
        "file": "../../../foo/bar_43/bbb.c"
    }
]

It looks like json2cmake is also looking for some git information, but in this case I built the project outside of the git clone.

@pvbouwel
Copy link

pvbouwel commented Aug 9, 2019

Encountered this as well.

Seems like the commonprefix (used at init.py:122) does not like the files that are submitted which is a set. Changing the line to:

            name = os.path.basename(os.path.commonprefix(list(files)).rstrip("/_"))

Avoids the error.

@ngbrown
Copy link

ngbrown commented Apr 19, 2021

Closed by #32, but it has not been released to PyPI yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants