Buck build for libtorch

I have built libtorch from source using the build_libtorch.py found here.

I would like use torch in some C++ libraries and have been considering building them with the Buck build system. Would the developers advise against this? Buck seems appealing, but I wonder if I am barking up the wrong tree.

We use Buck internally within Facebook to build PyTorch, but not all the build rules are open-sourced. build_variables.py contains a sanitized subset of them that could be a good starting point.

1 Like

Oh man, thank you. I didn’t take notice of build_variables.py. That looks great.

I’m also trying to build libtorch from source with a build system similar to buck (bazel). I just checked build_libtorch.py and build_variables.py, but still feel lost about how these scripts work. i can see there are a few custom rules in build_variables.py, but why these rules can be used directly in a bazel scripts?

also wondering if you can share your progress on this. Any sharing and suggestion would be really appreciated! Thanks!

can buck use build rules from bazel directly? i see “load(”@bazel_skylib//lib:new_sets.bzl", “sets”)" in tools/build_variables.py, which makes me a little bit confused.

You shouldn’t try to use build_variables.py directly; it’s intended to be used within Facebook’s internal environment. It can be a starting point for you to create your own Bazel rules, however.

Thanks for your answer.

Yeah, i can see there are some customized rules in build_variables.py, which are required if i want to use it, but i’m still wondering how is this scripts used by the internal environment. Since this is still a python script, how could the syntax like load("@bazel_skylib//lib:new_sets.bzl", "sets") work?