mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
use the //tools/codegen target in Bazel (#74465)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/74465 This requires adding py_library and its PyPI dependency provider "requirement". ghstack-source-id: 152438643 Test Plan: Rely on CI to validate. Reviewed By: malfet Differential Revision: D35009795 fbshipit-source-id: 424c4968474b3c2fb37d2c7dba932b37605a63f7 (cherry picked from commit 91e442c3bf0e204b0fb6c98405aaaa7308011511)
This commit is contained in:
committed by
PyTorch MergeBot
parent
76eabe9ef0
commit
79307fbde0
11
BUILD.bazel
11
BUILD.bazel
@ -31,7 +31,7 @@ py_binary(
|
||||
name = "gen",
|
||||
srcs = ["tools/setup_helpers/gen.py"],
|
||||
deps = [
|
||||
":tools_codegen"
|
||||
"//tools/codegen"
|
||||
],
|
||||
)
|
||||
|
||||
@ -105,11 +105,6 @@ generate_aten(
|
||||
generator=":gen",
|
||||
)
|
||||
|
||||
py_library(
|
||||
name = "tools_codegen",
|
||||
srcs = glob(["tools/codegen/**/*.py"]),
|
||||
)
|
||||
|
||||
py_library(
|
||||
name = "tools_autograd",
|
||||
srcs = glob(["tools/autograd/*.py"]),
|
||||
@ -117,7 +112,7 @@ py_library(
|
||||
"tools/autograd/*.yaml",
|
||||
"tools/autograd/templates/*",
|
||||
]),
|
||||
deps = [":tools_codegen"],
|
||||
deps = ["//tools/codegen"],
|
||||
)
|
||||
|
||||
py_library(
|
||||
@ -1380,7 +1375,7 @@ cc_library(
|
||||
py_binary(
|
||||
name = "gen_op",
|
||||
srcs = ["caffe2/contrib/aten/gen_op.py"],
|
||||
deps = [":tools_codegen"],
|
||||
deps = ["//tools/codegen"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
|
@ -3,6 +3,13 @@ load("@rules_cuda//cuda:defs.bzl", "requires_cuda_enabled")
|
||||
load("//c10/macros:cmake_configure_file.bzl", "cmake_configure_file")
|
||||
load("//tools/config:defs.bzl", "if_cuda")
|
||||
|
||||
def _py_library(name, **kwds):
|
||||
deps = [dep for dep in kwds.pop("deps", []) if dep != None]
|
||||
native.py_library(name = name, deps = deps, **kwds)
|
||||
|
||||
def _requirement(_pypi_project):
|
||||
return None
|
||||
|
||||
# Rules implementation for the Bazel build system. Since the common
|
||||
# build structure aims to replicate Bazel as much as possible, most of
|
||||
# the rules simply forward to the Bazel definitions.
|
||||
@ -14,6 +21,8 @@ rules = struct(
|
||||
filegroup = native.filegroup,
|
||||
glob = native.glob,
|
||||
if_cuda = if_cuda,
|
||||
py_library = _py_library,
|
||||
requirement = _requirement,
|
||||
requires_cuda_enabled = requires_cuda_enabled,
|
||||
select = select,
|
||||
test_suite = native.test_suite,
|
||||
|
4
tools/codegen/BUILD.bazel
Normal file
4
tools/codegen/BUILD.bazel
Normal file
@ -0,0 +1,4 @@
|
||||
load("//:tools/bazel.bzl", "rules")
|
||||
load(":build.bzl", "define_targets")
|
||||
|
||||
define_targets(rules = rules)
|
Reference in New Issue
Block a user