@@ -290,6 +290,7 @@ def _cxx_test(*args, **kwargs):
290290
291291def _cxx_python_extension (* args , ** kwargs ):
292292 _patch_kwargs_common (kwargs )
293+ _remove_caffe2_deps (kwargs )
293294 kwargs ["srcs" ] = _patch_executorch_references (kwargs ["srcs" ])
294295 if "types" in kwargs :
295296 kwargs ["types" ] = _patch_executorch_references (kwargs ["types" ])
@@ -324,8 +325,19 @@ def _genrule(*args, **kwargs):
324325 kwargs ["name" ] += "_static"
325326 env .genrule (* args , ** kwargs )
326327
328+ def _remove_caffe2_deps (kwargs ):
329+ if not env .is_oss :
330+ return
331+ # We don't have Buckified PyTorch in OSS. At least let buck query work.
332+ MISSING_BUCK_DIRS = ("//caffe2" , "//pytorch" , "fbsource//third-party" )
333+ for dep_type in ('deps' , 'exported_deps' ):
334+ if dep_type not in kwargs :
335+ continue
336+ kwargs [dep_type ] = [x for x in kwargs [dep_type ] if not any ([x .startswith (y ) for y in MISSING_BUCK_DIRS ])]
337+
327338def _python_library (* args , ** kwargs ):
328339 _patch_kwargs_common (kwargs )
340+ _remove_caffe2_deps (kwargs )
329341 env .python_library (* args , ** kwargs )
330342
331343def _python_binary (* args , ** kwargs ):
0 commit comments