Re: Pull request 870 in include-what-you-use: WIP: Add script to generate mappings for Python C API

60 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
Feb 3, 2021, 9:03:09 AM2/3/21
to include-wh...@googlegroups.com
Comment #1 on pull request 870 by Flamefire: WIP: Add script to generate mappings for Python C API
https://github.com/include-what-you-use/include-what-you-use/pull/870

Tested and fails.

The file contains `{"include": ["@[\"<]patchlevel\\.h[\">]", "private", "<Python.h>", "public"]},`
But I get:

```
/home/alex/git/scorep_binding_python/src/scorepy/events.cpp should add these lines:
#include <patchlevel.h> // for PY_MAJOR_VERSION

/home/alex/git/scorep_binding_python/src/scorepy/events.cpp should remove these lines:
- #include <Python.h> // lines 2-2
```

Run with `iwyu_tool -p build src/scorepy/events.cpp -- --mapping_file=python3.7.imp` on https://github.com/score-p/scorep_binding_python after configuring with CMake (I hate setting up paths ;) )

notifi...@include-what-you-use.org

unread,
Feb 3, 2021, 12:40:52 PM2/3/21
to include-wh...@googlegroups.com
Comment #1 on pull request 870 by kimgr: WIP: Add script to generate mappings for Python C API
https://github.com/include-what-you-use/include-what-you-use/pull/870

If this is a reasonably recent `iwyu_tool.py`, you need to add `-Xiwyu`-prefix for suffix arguments:

iwyu_tool -p build src/scorepy/events.cpp -- -Xiwyu --mapping_file=python3.7.imp

This was added to allow adding extra Clang arguments too.

notifi...@include-what-you-use.org

unread,
Feb 3, 2021, 4:02:27 PM2/3/21
to include-wh...@googlegroups.com
Comment #3 on pull request 870 by Flamefire: WIP: Add script to generate mappings for Python C API
https://github.com/include-what-you-use/include-what-you-use/pull/870

Ouch yes, it even says so: `error: unsupported option '--mapping_file=python3.7.imp'`

I'm surprised it doesn't just error out. Also the mapping_file param must be an absolute path: `iwyu_tool -p build src/scorepy/events.cpp -- -Xiwyu --mapping_file=$PWD/python3.7.imp` worked, so yes this works.
Hence I'd suggest to include a few of those generated ones with IWYU by default. I guess they won't vary to much by version if at all, so maybe 1 is enough.

For reference mine is attached:
[python3.7.imp.txt](https://github.com/include-what-you-use/include-what-you-use/files/5921443/python3.7.imp.txt)

notifi...@include-what-you-use.org

unread,
Feb 4, 2021, 1:34:43 PM2/4/21
to include-wh...@googlegroups.com
Comment #3 on pull request 870 by kimgr: WIP: Add script to generate mappings for Python C API
https://github.com/include-what-you-use/include-what-you-use/pull/870

Thank you! Yeah, let's throw a python3 version in there, py2 is dead (as if :)).

I'll clean things up and push an updated branch.

Reply all
Reply to author
Forward
0 new messages