generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support python_version attribute (#347)
This PR adds support python_version attribute the same way rules_python does, with the exception that we generate no `defs.bzl` file that users can just replace their with. Instead we encourage them to create their own macros that sets the desired version on py_binary/py_test rule. ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes ### Test plan - New test cases added --------- Co-authored-by: Matt Mackay <[email protected]>
- Loading branch information
Showing
8 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_pytest_main", "py_test") | ||
|
||
py_binary( | ||
name = "multi_version", | ||
srcs = ["say.py"], | ||
deps = [ | ||
"@pypi_cowsay//:pkg", | ||
], | ||
python_version = "3.8.12" | ||
) | ||
py_pytest_main( | ||
name = "__test__", | ||
deps = ["@pypi_pytest//:pkg"], | ||
) | ||
|
||
py_test( | ||
name = "py_version_test", | ||
srcs = [ | ||
"py_version_test.py", | ||
":__test__", | ||
], | ||
main = ":__test__.py", | ||
deps = [ | ||
":__test__", | ||
], | ||
python_version = "3.8.12" | ||
) | ||
py_test( | ||
name = "py_version_default_test", | ||
srcs = [ | ||
"py_version_default_test.py", | ||
":__test__", | ||
], | ||
main = ":__test__.py", | ||
deps = [ | ||
":__test__", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import sys | ||
|
||
def test_default_py_version(): | ||
assert sys.version_info.major == 3, "sys.version_info.major == 3" | ||
assert sys.version_info.minor == 9, "sys.version_info.minor == 9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import sys | ||
|
||
def test_specific_py_version(): | ||
assert sys.version_info.major == 3, "sys.version_info.major == 3" | ||
assert sys.version_info.minor == 8, "sys.version_info.minor == 8" | ||
assert sys.version_info.micro == 12, "sys.version_info.micro == 12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import cowsay | ||
import sys | ||
|
||
cowsay.cow('hello py_binary, %s!' % sys.version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters