update rules_python and let bazel install its own pip dependencies (#101405)

update rules_python and let bazel install its own pip dependencies

Summary:
This is the official way of doing Python in Bazel.

Test Plan: Rely on CI.

---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/pytorch/pytorch/pull/101405).
* #101406
* __->__ #101405
Pull Request resolved: https://github.com/pytorch/pytorch/pull/101405
Approved by: https://github.com/vors, https://github.com/huydhn
This commit is contained in:
mikey dagitses
2023-05-23 06:20:33 +00:00
committed by PyTorch MergeBot
parent 2ca75d49a8
commit 9bbee245fe
7 changed files with 255 additions and 21 deletions

View File

@ -1,5 +1,7 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_cuda//cuda:defs.bzl", "cuda_library", "requires_cuda_enabled")
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@pip_deps//:requirements.bzl", "requirement")
load("@pytorch//c10/macros:cmake_configure_file.bzl", "cmake_configure_file")
load("@pytorch//tools/config:defs.bzl", "if_cuda")
@ -10,13 +12,6 @@ def _genrule(**kwds):
def _is_cpu_static_dispatch_build():
return False
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.
@ -31,9 +26,9 @@ rules = struct(
glob = native.glob,
if_cuda = if_cuda,
is_cpu_static_dispatch_build = _is_cpu_static_dispatch_build,
py_binary = native.py_binary,
py_library = _py_library,
requirement = _requirement,
py_binary = py_binary,
py_library = py_library,
requirement = requirement,
requires_cuda_enabled = requires_cuda_enabled,
select = select,
test_suite = native.test_suite,