Skip to content

Step 1 of creating multi-python bindings. - #2576

Merged
stellaraccident merged 6 commits into
iree-org:mainfrom
stellaraccident:multipy
Jul 21, 2020
Merged

stellaraccident merged 6 commits into
iree-org:mainfrom
stellaraccident:multipy

Conversation

@stellaraccident

@stellaraccident stellaraccident commented Jul 19, 2020 •

Copy link
Copy Markdown
Collaborator
  • Adds the cmake machinery to configure the build to produce native modules for all specified python versions (should also work for python cross compile).
  • The default is as it has been (to use the identified default python config).
  • I had hoped to make a common library for this that I could share with LLVM, but IREE's use of CMake is too quirky and it would be easier to just adapt vs share.
  • This marks the end of the road for bazel_to_cmake support for python. I see no maintainable way to have a single sot that spans cmake, bazel and Google's bazel: they are all just too weird when it comes to shenanigans needed to built python extensions effectively.
  • Also fixed some default device enumeration issues in tests that were keeping me from making progress (no GPU on this container).

* Adds the cmake machinery to configure the build to produce native modules for all specified python versions (should also work for python cross compile).
* The default is as it has been (to use the identified default python config).
* I had hoped to make a common library for this that I could share with LLVM, but IREE's use of CMake is too quirky and it would be easier to just adapt vs share.
* This marks the end of the road for bazel_to_cmake support for python. I see no maintainable way to have a single sot that spans cmake, bazel and Google's bazel: they are all just too weird when it comes to shenanigans needed to built python extensions effectively.
* I'm going to transition all of the python packages to more of a CMake-normal syntax (versus this weird dep naming and other stuff we do to make it look like Bazel): Python will be divergent forever and I don't care if it is a bit different from the rest (and more consistent with upstream, which I am also working on).
* Also fixed some default device enumeration issues in tests that were keeping me from making progress (no GPU on this container).
* I intend to remove/simplify the current machinery for this stuff but have left it in place for now (to simplify rollbacks and diffs).
Comment on lines +110 to +111
if os.path.isfile(skip_file_path) or not os.path.isfile(build_file_path):
# No Bazel BUILD file in this directory or explicit skip.

@GMNGeoffrey GMNGeoffrey Jul 23, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already merged when I spotted this (sorry for the delay), but we've already got a pattern EDIT_BLOCKING_PATTERN you can put in the CMakeLists.txt file which will make the script fall back to printing what it would edit to stdout. Should we consolidate these two skipping methods? The idea behind falling back to stdout was that for something that wasn't fully automated, you might still want to see what the script would generate. It seems like here you want to always skip entirely.

Some options:

  1. Drop EDIT_BLOCKING_PATTERN and just use this
  2. Drop this and just use EDIT_BLOCKING_PATTERN
  3. (2), but also make EDIT_BLOCKING_PATTERN not do the stdout thing. Just skip the file
  4. (2), but also make EDIT_BLOCKING_PATTERN only apply in strict mode and otherwise write the file anyway (basically EDIT_BLOCKING_PATTERN becomes a manual way to tell bazel_to_cmake that it can't write this file cleanly.
  5. (2), but add an additional pattern to tell bazel_to_cmake to skip a file and not print to stdout.

Personally, I like option (4) I think it would make the behavior more consistent and still allows someone to see what bazel_to_cmake would do for any given file without spamming the logs by default.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I have much of an opinion as long as we have an obvious way to tell it that a directory is opted out (which, if I read properly, can be a comment in the CMakeLists file itself. Can you point exactly at what would need to change (or feel free to edit -- I'm not married to how I did this)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just put some comment in the CMakeLists.txt file like bazel_to_cmake: do not edit

The actual regex is

EDIT_BLOCKING_PATTERN = re.compile(
    r"bazel[\s_]*to[\s_]*cmake[\s_]*:?[\s_]*do[\s_]*not[\s_]*edit",
    flags=re.IGNORECASE)

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

Successfully merging this pull request may close these issues.

4 participants