-
-
Notifications
You must be signed in to change notification settings - Fork 594
feat(bzlmod): Moving register.toolchains internal #1238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
load("@python_aliases//3.10:defs.bzl", py_binary_3_10 = "py_binary", py_test_3_10 = "py_test") | ||
load("@python_aliases//3.11:defs.bzl", py_binary_3_11 = "py_binary", py_test_3_11 = "py_test") | ||
load("@python_aliases//3.9:defs.bzl", py_binary_3_9 = "py_binary", py_test_3_9 = "py_test") | ||
load("@rules_python//python:defs.bzl", "py_binary", "py_test") | ||
|
||
py_binary( | ||
name = "version_default", | ||
srcs = ["version.py"], | ||
main = "version.py", | ||
) | ||
|
||
py_binary_3_9( | ||
name = "version_3_9", | ||
srcs = ["version.py"], | ||
main = "version.py", | ||
) | ||
|
||
py_binary_3_10( | ||
name = "version_3_10", | ||
srcs = ["version.py"], | ||
main = "version.py", | ||
) | ||
|
||
py_binary_3_11( | ||
name = "version_3_11", | ||
srcs = ["version.py"], | ||
main = "version.py", | ||
) | ||
|
||
# This is a work in progress and the commented | ||
# tests will not work until we can support | ||
# multiple pips with bzlmod. | ||
|
||
#py_test( | ||
# name = "my_lib_default_test", | ||
# srcs = ["my_lib_test.py"], | ||
# main = "my_lib_test.py", | ||
# deps = ["//libs/my_lib"], | ||
#) | ||
|
||
#py_test_3_9( | ||
# name = "my_lib_3_9_test", | ||
# srcs = ["my_lib_test.py"], | ||
# main = "my_lib_test.py", | ||
# deps = ["//libs/my_lib"], | ||
#) | ||
|
||
#py_test_3_10( | ||
# name = "my_lib_3_10_test", | ||
# srcs = ["my_lib_test.py"], | ||
# main = "my_lib_test.py", | ||
# deps = ["//libs/my_lib"], | ||
#) | ||
|
||
#py_test_3_11( | ||
# name = "my_lib_3_11_test", | ||
# srcs = ["my_lib_test.py"], | ||
# main = "my_lib_test.py", | ||
# deps = ["//libs/my_lib"], | ||
#) | ||
|
||
py_test( | ||
name = "version_default_test", | ||
srcs = ["version_test.py"], | ||
env = {"VERSION_CHECK": "3.9"}, # The default defined in the WORKSPACE. | ||
main = "version_test.py", | ||
) | ||
|
||
py_test_3_9( | ||
name = "version_3_9_test", | ||
srcs = ["version_test.py"], | ||
env = {"VERSION_CHECK": "3.9"}, | ||
main = "version_test.py", | ||
) | ||
|
||
py_test_3_10( | ||
name = "version_3_10_test", | ||
srcs = ["version_test.py"], | ||
env = {"VERSION_CHECK": "3.10"}, | ||
main = "version_test.py", | ||
) | ||
|
||
py_test_3_11( | ||
name = "version_3_11_test", | ||
srcs = ["version_test.py"], | ||
env = {"VERSION_CHECK": "3.11"}, | ||
main = "version_test.py", | ||
) | ||
|
||
py_test( | ||
name = "version_default_takes_3_10_subprocess_test", | ||
srcs = ["cross_version_test.py"], | ||
data = [":version_3_10"], | ||
env = { | ||
"SUBPROCESS_VERSION_CHECK": "3.10", | ||
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_10)", | ||
"VERSION_CHECK": "3.9", | ||
}, | ||
main = "cross_version_test.py", | ||
) | ||
|
||
py_test_3_10( | ||
name = "version_3_10_takes_3_9_subprocess_test", | ||
srcs = ["cross_version_test.py"], | ||
data = [":version_3_9"], | ||
env = { | ||
"SUBPROCESS_VERSION_CHECK": "3.9", | ||
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_9)", | ||
"VERSION_CHECK": "3.10", | ||
}, | ||
main = "cross_version_test.py", | ||
) | ||
|
||
sh_test( | ||
name = "version_test_binary_default", | ||
srcs = ["version_test.sh"], | ||
data = [":version_default"], | ||
env = { | ||
"VERSION_CHECK": "3.9", # The default defined in the WORKSPACE. | ||
"VERSION_PY_BINARY": "$(rootpath :version_default)", | ||
}, | ||
) | ||
|
||
sh_test( | ||
name = "version_test_binary_3_9", | ||
srcs = ["version_test.sh"], | ||
data = [":version_3_9"], | ||
env = { | ||
"VERSION_CHECK": "3.9", | ||
"VERSION_PY_BINARY": "$(rootpath :version_3_9)", | ||
}, | ||
) | ||
|
||
sh_test( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can eliminate these sh_test wrappers by using native_test from skylib: https://github.com/bazelbuild/bazel-skylib/blob/main/docs/native_binary_doc.md#native_test They'll let you run the binary as a test directly; as a bonus, version.py goes away and the binaries can just directly use version_test.py I'm also fine with doing this in a followup PR. |
||
name = "version_test_binary_3_10", | ||
srcs = ["version_test.sh"], | ||
data = [":version_3_10"], | ||
env = { | ||
"VERSION_CHECK": "3.10", | ||
"VERSION_PY_BINARY": "$(rootpath :version_3_10)", | ||
}, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
|
||
process = subprocess.run( | ||
[os.getenv("SUBPROCESS_VERSION_PY_BINARY")], | ||
stdout=subprocess.PIPE, | ||
universal_newlines=True, | ||
) | ||
|
||
subprocess_current = process.stdout.strip() | ||
subprocess_expected = os.getenv("SUBPROCESS_VERSION_CHECK") | ||
|
||
if subprocess_current != subprocess_expected: | ||
print( | ||
f"expected subprocess version '{subprocess_expected}' is different than returned '{subprocess_current}'" | ||
) | ||
sys.exit(1) | ||
|
||
expected = os.getenv("VERSION_CHECK") | ||
current = f"{sys.version_info.major}.{sys.version_info.minor}" | ||
|
||
if current != expected: | ||
print(f"expected version '{expected}' is different than returned '{current}'") | ||
sys.exit(1) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import sys | ||
|
||
print(f"{sys.version_info.major}.{sys.version_info.minor}") |
Uh oh!
There was an error while loading. Please reload this page.