diff --git a/.plzconfig b/.plzconfig index d3a6ce3..5f11610 100644 --- a/.plzconfig +++ b/.plzconfig @@ -1,5 +1,5 @@ [Please] -Version = >=17.12.2 +Version = >=17.19.1 [Build] hashcheckers = sha256 @@ -18,6 +18,7 @@ Target = //plugins:shell [Plugin "e2e"] Target = //plugins:e2e +DefaultPlugin = //test:python-rules [PluginDefinition] name = python diff --git a/BUILD b/BUILD index d4490a6..f5aacaf 100644 --- a/BUILD +++ b/BUILD @@ -11,3 +11,12 @@ remote_file( url = f"https://get.please.build/{CONFIG.OS}_{CONFIG.ARCH}/{v}/please_{v}", visibility = ["PUBLIC"], ) + +export_file( + name = "plzconfig", + src = ".plzconfig", + test_only = True, + visibility = [ + "//test:python-rules", + ], +) diff --git a/plugins/BUILD b/plugins/BUILD index 5f9a130..03b61c8 100644 --- a/plugins/BUILD +++ b/plugins/BUILD @@ -11,5 +11,5 @@ plugin_repo( plugin_repo( name = "e2e", plugin = "plugin-integration-testing", - revision = "v1.0.3", + revision = "v1.1.0", ) diff --git a/test/BUILD b/test/BUILD index fd167db..216d6e2 100644 --- a/test/BUILD +++ b/test/BUILD @@ -17,6 +17,20 @@ package( }, ) +e2e_test_plugin( + name = "python-rules", + srcs = [ + "//build_defs:archs", + "//build_defs:python", + "//build_defs:version", + "//tools:please_pex", + "//:plzconfig", + ], + visibility = [ + "//test/...", + ], +) + python_binary( name = "strip_source", main = "strip_source.py", @@ -132,18 +146,19 @@ python_test( deps = ["//third_party/python:cx_oracle"], ) -plz_e2e_test( - name = "correct_labels_on_pip_libary_non_zip_safe", - cmd = "plz query print -f labels //third_party/python:pyyaml", - expected_output = "expected_labels_on_pyyaml.txt", - deps = ["//third_party/python:pyyaml"], -) - -plz_e2e_test( - name = "correct_labels_on_pip_libary_zip_safe", - cmd = "plz query print -f labels //third_party/python:grpcio", - expected_output = "expected_labels_on_grpcio.txt", - deps = ["//third_party/python:grpcio"], +plugin_e2e_test( + name = "pip_libary_zip_safe_label_test", + repo = "zip_safe_label_repo", + test_cmd = [ + "plz query print -f labels //third_party/python:safe > safe", + "plz query print -f labels //third_party/python:safe_implicit > safe_implicit", + "plz query print -f labels //third_party/python:unsafe > unsafe", + ], + expected_output = { + "safe": "py\npip:safe==1.0.0", + "safe_implicit": "py\npip:safe_implicit==1.0.0", + "unsafe": "py\npip:unsafe==1.0.0\npy:zip-unsafe", + }, ) # Test that python_wheel targets can have name_scheme as a list or a string diff --git a/test/expected_labels_on_grpcio.txt b/test/expected_labels_on_grpcio.txt deleted file mode 100644 index 4abfdd1..0000000 --- a/test/expected_labels_on_grpcio.txt +++ /dev/null @@ -1,2 +0,0 @@ -py -pip:grpcio==1.75.1 diff --git a/test/expected_labels_on_pyyaml.txt b/test/expected_labels_on_pyyaml.txt deleted file mode 100644 index eec3c79..0000000 --- a/test/expected_labels_on_pyyaml.txt +++ /dev/null @@ -1,3 +0,0 @@ -py -pip:PyYAML==6.0.2 -py:zip-unsafe diff --git a/test/zip_safe_label_repo/.plzconfig b/test/zip_safe_label_repo/.plzconfig new file mode 100644 index 0000000..2ffad3a --- /dev/null +++ b/test/zip_safe_label_repo/.plzconfig @@ -0,0 +1,2 @@ +[Plugin "python"] +Target = //plugins:python diff --git a/test/zip_safe_label_repo/plugins/BUILD_FILE b/test/zip_safe_label_repo/plugins/BUILD_FILE new file mode 100644 index 0000000..bd8b3fd --- /dev/null +++ b/test/zip_safe_label_repo/plugins/BUILD_FILE @@ -0,0 +1,4 @@ +plugin_repo( + name = "python", + revision = "e2e", +) diff --git a/test/zip_safe_label_repo/third_party/python/BUILD_FILE b/test/zip_safe_label_repo/third_party/python/BUILD_FILE new file mode 100644 index 0000000..970152f --- /dev/null +++ b/test/zip_safe_label_repo/third_party/python/BUILD_FILE @@ -0,0 +1,33 @@ +subinclude("///python//build_defs:python") + +package( + # The pip_library targets below aren't real Python modules, and don't need to be downloaded in + # order for this test to run - make sure we don't accidentally look for them on PyPI. + python = { + "default_pip_repo": "https://nonexistent.example", + "use_pypi": False, + }, +) + +# This target is explicitly zip-safe: +pip_library( + name = "safe", + licences = ["MIT"], + version = "1.0.0", + zip_safe = True, +) + +# This target is implicitly zip-safe, because it specifies no value for zip_safe: +pip_library( + name = "safe_implicit", + licences = ["MIT"], + version = "1.0.0", +) + +# This target is explicitly zip-unsafe: +pip_library( + name = "unsafe", + licences = ["MIT"], + version = "1.0.0", + zip_safe = False, +)