Skip to content

Commit

Permalink
[py] add the ability to generate a wheel via bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Mar 2, 2020
1 parent a3734f2 commit eb1f423
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
9 changes: 6 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ install_bazel_dependencies()

http_archive(
name = "rules_python",
sha256 = "b556b165ea1311bf68b6b0bc86d95e5cfca2e839aa6fbd232781bb3930f3d392",
strip_prefix = "rules_python-e0644961d74b9bbb8a975a01bebb045abfd5d1bd",
sha256 = "ddb2e1298684defde2f5e466d96e572119f30f9e2a901a7a81474fd4fa9f6d52",
strip_prefix = "rules_python-dd7f9c5f01bafbfea08c44092b6b0c8fc8fcb77f",
urls = [
"https://github.com/bazelbuild/rules_python/archive/e0644961d74b9bbb8a975a01bebb045abfd5d1bd.zip",
"https://github.com/bazelbuild/rules_python/archive/dd7f9c5f01bafbfea08c44092b6b0c8fc8fcb77f.zip",
],
patches = [
"//py:rules_python_any_version_wheel.patch"
],
)

Expand Down
34 changes: 34 additions & 0 deletions py/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@rules_python//experimental/python:wheel.bzl", "py_package", "py_wheel")
load("//py:defs.bzl", "py_test_suite", "pytest_test")
load("//:copy_file.bzl", "copy_file")

Expand Down Expand Up @@ -42,6 +43,39 @@ py_library(
],
)

py_package(
name = "selenium-pkg",
packages = [
"py.selenium",
"py.selenium.common",
"py.selenium.webdriver",
"py.selenium.webdriver.chromium",
"py.selenium.webdriver.chrome",
"py.selenium.webdriver.edge",
"py.selenium.webdriver.firefox",
"py.selenium.webdriver.remote",
"py.selenium.webdriver.safari",
],
deps = [":selenium"],
)

py_wheel(
name = 'selenium-wheel',
distribution = 'selenium',
python_tag = ["py2", "py3"],
version = "4.0.0.a4",
strip_path_prefixes = [
"py",
],
requires = [
"urllib3[secure]",
],
visibility = ["//visibility:public"],
deps = [
":selenium-pkg",
],
)

py_library(
name = "init-tree",
testonly = True,
Expand Down
36 changes: 36 additions & 0 deletions py/rules_python_any_version_wheel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git experimental/python/wheel.bzl experimental/python/wheel.bzl
index 9cd6534..7802d42 100644
--- experimental/python/wheel.bzl
+++ experimental/python/wheel.bzl
@@ -85,7 +85,7 @@ def _py_wheel_impl(ctx):
outfile = ctx.actions.declare_file("-".join([
ctx.attr.distribution,
ctx.attr.version,
- ctx.attr.python_tag,
+ ".".join(ctx.attr.python_tag),
ctx.attr.abi,
ctx.attr.platform,
]) + ".whl")
@@ -101,7 +101,7 @@ def _py_wheel_impl(ctx):
args = ctx.actions.args()
args.add("--name", ctx.attr.distribution)
args.add("--version", ctx.attr.version)
- args.add("--python_tag", ctx.attr.python_tag)
+ args.add_all(ctx.attr.python_tag, format_each = "--python_tag=%s")
args.add("--abi", ctx.attr.abi)
args.add("--platform", ctx.attr.platform)
args.add("--out", outfile.path)
@@ -177,10 +177,9 @@ refer to the package in other packages' dependencies.
default = "any",
doc = "Supported platforms. 'any' for pure-Python wheel.",
),
- "python_tag": attr.string(
- default = "py3",
- doc = "Supported Python major version. 'py2' or 'py3'",
- values = ["py2", "py3"],
+ "python_tag": attr.string_list(
+ default = ["py3"],
+ doc = "Supported Python major version. 'py2' and/or 'py3'",
),
"version": attr.string(
mandatory = True,

0 comments on commit eb1f423

Please sign in to comment.