From 8069fa5916bc8e9ef1d282f5882ff2bdf11ad229 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sun, 12 Oct 2025 00:50:44 -0700 Subject: [PATCH 1/2] internal: make release to chdir before looking for version markers (#3342) The release tool wasn't determining the next version correctly because it was in the wrong directory when that logic ran. To fix, chdir before that logic kicks off. --- tests/tools/private/release/release_test.py | 57 +++++++++++++++++++++ tools/private/release/release.py | 8 +-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/tests/tools/private/release/release_test.py b/tests/tools/private/release/release_test.py index 72a9a05cd6..676a898440 100644 --- a/tests/tools/private/release/release_test.py +++ b/tests/tools/private/release/release_test.py @@ -210,5 +210,62 @@ def test_get_latest_version_only_rc_tags(self, mock_get_tags): releaser.get_latest_version() +class DetermineNextVersionTest(unittest.TestCase): + def setUp(self): + self.tmpdir = pathlib.Path(tempfile.mkdtemp()) + self.original_cwd = os.getcwd() + self.addCleanup(shutil.rmtree, self.tmpdir) + + os.chdir(self.tmpdir) + # NOTE: On windows, this must be done before files are deleted. + self.addCleanup(os.chdir, self.original_cwd) + + self.mock_get_latest_version = patch( + "tools.private.release.release.get_latest_version" + ).start() + self.addCleanup(patch.stopall) + + def test_no_markers(self): + (self.tmpdir / "mock_file.bzl").write_text("no markers here") + self.mock_get_latest_version.return_value = "1.2.3" + + next_version = releaser.determine_next_version() + + self.assertEqual(next_version, "1.2.4") + + def test_only_patch(self): + (self.tmpdir / "mock_file.bzl").write_text( + ":::{versionchanged} VERSION_NEXT_PATCH" + ) + self.mock_get_latest_version.return_value = "1.2.3" + + next_version = releaser.determine_next_version() + + self.assertEqual(next_version, "1.2.4") + + def test_only_feature(self): + (self.tmpdir / "mock_file.bzl").write_text( + ":::{versionadded} VERSION_NEXT_FEATURE" + ) + self.mock_get_latest_version.return_value = "1.2.3" + + next_version = releaser.determine_next_version() + + self.assertEqual(next_version, "1.3.0") + + def test_both_markers(self): + (self.tmpdir / "mock_file_patch.bzl").write_text( + ":::{versionchanged} VERSION_NEXT_PATCH" + ) + (self.tmpdir / "mock_file_feature.bzl").write_text( + ":::{versionadded} VERSION_NEXT_FEATURE" + ) + self.mock_get_latest_version.return_value = "1.2.3" + + next_version = releaser.determine_next_version() + + self.assertEqual(next_version, "1.3.0") + + if __name__ == "__main__": unittest.main() diff --git a/tools/private/release/release.py b/tools/private/release/release.py index def6754347..6fce0ff3b0 100644 --- a/tools/private/release/release.py +++ b/tools/private/release/release.py @@ -170,6 +170,10 @@ def create_parser(): def main(): + # Change to the workspace root so the script can be run using `bazel run` + if "BUILD_WORKSPACE_DIRECTORY" in os.environ: + os.chdir(os.environ["BUILD_WORKSPACE_DIRECTORY"]) + parser = create_parser() args = parser.parse_args() @@ -179,10 +183,6 @@ def main(): version = determine_next_version() print(f"Determined next version: {version}") - # Change to the workspace root so the script can be run using `bazel run` - if "BUILD_WORKSPACE_DIRECTORY" in os.environ: - os.chdir(os.environ["BUILD_WORKSPACE_DIRECTORY"]) - print("Updating changelog ...") release_date = datetime.date.today().strftime("%Y-%m-%d") update_changelog(version, release_date) From 43a5acf8cedfce07fd4f933c9165f75e0b4d88c9 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sun, 12 Oct 2025 00:51:44 -0700 Subject: [PATCH 2/2] chore: release 1.7 prep (#3341) * Update changelog * Update version markers Work towards https://github.com/bazel-contrib/rules_python/issues/3338 --- CHANGELOG.md | 16 ++++++++-------- docs/api/rules_python/python/cc/index.md | 2 +- docs/environment-variables.md | 4 ++-- python/extensions/config.bzl | 2 +- python/features.bzl | 2 +- python/private/attributes.bzl | 2 +- python/private/current_py_cc_headers.bzl | 2 +- python/private/py_cc_toolchain_info.bzl | 2 +- python/private/py_cc_toolchain_rule.bzl | 2 +- python/private/py_executable.bzl | 2 +- python/private/py_info.bzl | 2 +- python/runfiles/runfiles.py | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aebcfccc15..d7c480582a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,18 +48,18 @@ BEGIN_UNRELEASED_TEMPLATE END_UNRELEASED_TEMPLATE --> -{#v0-0-0} -## Unreleased +{#v1-7-0} +## [1.7.0] - 2025-10-11 -[0.0.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.0.0 +[1.7.0]: https://github.com/bazel-contrib/rules_python/releases/tag/1.7.0 -{#v0-0-0-removed} +{#v1-7-0-removed} ### Removed * (core rules) Support for Bazel's long deprecated "extra actions" has been removed ([#3215](https://github.com/bazel-contrib/rules_python/issues/3215)). -{#v0-0-0-changed} +{#v1-7-0-changed} ### Changed * (deps) bumped rules_cc dependency to `0.1.5`. * (bootstrap) For {obj}`--bootstrap_impl=system_python`, `PYTHONPATH` is no @@ -88,7 +88,7 @@ END_UNRELEASED_TEMPLATE [20251010]: https://github.com/astral-sh/python-build-standalone/releases/tag/20251010 -{#v0-0-0-fixed} +{#v1-7-0-fixed} ### Fixed * (rules) The `PyInfo` constructor was setting the wrong value for `has_py3_only_sources` - this is now fixed. @@ -117,7 +117,7 @@ END_UNRELEASED_TEMPLATE * (rules) {obj}`py_console_script_binary` is now compatible with symbolic macros ([#3195](https://github.com/bazel-contrib/rules_python/pull/3195)). -{#v0-0-0-added} +{#v1-7-0-added} ### Added * (runfiles) The Python runfiles library now supports Bazel's `--incompatible_compact_repo_mapping_manifest` flag. @@ -1980,4 +1980,4 @@ Breaking changes: * (pip) Create all_data_requirements alias * Expose Python C headers through the toolchain. -[0.24.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.24.0 +[0.24.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.24.0 \ No newline at end of file diff --git a/docs/api/rules_python/python/cc/index.md b/docs/api/rules_python/python/cc/index.md index 2f4e3ae171..98d68dacd5 100644 --- a/docs/api/rules_python/python/cc/index.md +++ b/docs/api/rules_python/python/cc/index.md @@ -35,7 +35,7 @@ This target provides: * `CcInfo`: The C++ information about the Python ABI3 headers. -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 The {obj}`features.headers_abi3` attribute can be used to detect if this target is available or not. ::: diff --git a/docs/environment-variables.md b/docs/environment-variables.md index f0cf777a56..fba876f859 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -26,7 +26,7 @@ The {bzl:obj}`interpreter_args` attribute. :::{versionadded} 1.3.0 ::: -:::{versionchanged} VERSION_NEXT_FEATURE +:::{versionchanged} 1.7.0 Support added for {obj}`--bootstrap_impl=system_python`. ::: @@ -71,7 +71,7 @@ instead of the legacy Python scripts. :::{versionadded} 1.5.0 ::: -:::{versionchanged} VERSION_NEXT_FEATURE +:::{versionchanged} 1.7.0 Flipped to be enabled by default. ::: :::: diff --git a/python/extensions/config.bzl b/python/extensions/config.bzl index 2667b2a4fb..d8e621031e 100644 --- a/python/extensions/config.bzl +++ b/python/extensions/config.bzl @@ -43,7 +43,7 @@ def _config_impl(mctx): config = module_extension( doc = """Global settings for rules_python. -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 ::: """, implementation = _config_impl, diff --git a/python/features.bzl b/python/features.bzl index 00bc1a7817..291de33d1a 100644 --- a/python/features.bzl +++ b/python/features.bzl @@ -26,7 +26,7 @@ def _features_typedef(): True if the {obj}`@rules_python//python/cc:current_py_cc_headers_abi3` target is available. - :::{versionadded} VERSION_NEXT_FEATURE + :::{versionadded} 1.7.0 ::: :::: diff --git a/python/private/attributes.bzl b/python/private/attributes.bzl index 8fef1bbe2c..0e0872fbf5 100644 --- a/python/private/attributes.bzl +++ b/python/private/attributes.bzl @@ -402,7 +402,7 @@ https://bazel.build/extending/config#memory-performance-considerations for more information about risks and considerations. ::: -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 ::: """, ), diff --git a/python/private/current_py_cc_headers.bzl b/python/private/current_py_cc_headers.bzl index ef646317a6..f7fcd8d738 100644 --- a/python/private/current_py_cc_headers.bzl +++ b/python/private/current_py_cc_headers.bzl @@ -76,7 +76,7 @@ cc_library( ) ``` -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 ::: """, ) diff --git a/python/private/py_cc_toolchain_info.bzl b/python/private/py_cc_toolchain_info.bzl index 8cb3680b59..34d4acf305 100644 --- a/python/private/py_cc_toolchain_info.bzl +++ b/python/private/py_cc_toolchain_info.bzl @@ -64,7 +64,7 @@ fields: e.g. `:current_py_cc_headers` to act as the underlying headers target it represents). -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 The {obj}`features.headers_abi3` attribute can be used to detect if this attribute is available or not. ::: diff --git a/python/private/py_cc_toolchain_rule.bzl b/python/private/py_cc_toolchain_rule.bzl index b5c997ea6e..b89ea0e6b0 100644 --- a/python/private/py_cc_toolchain_rule.bzl +++ b/python/private/py_cc_toolchain_rule.bzl @@ -79,7 +79,7 @@ Target that provides the Python ABI3 (stable abi) headers. Typically this is a cc_library target. -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 The {obj}`features.headers_abi3` attribute can be used to detect if this attribute is available or not. ::: diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index 0df04a96d9..ad1afa91cd 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -139,7 +139,7 @@ This is mutually exclusive with {obj}`main`. :::{versionadded} 1.3.0 ::: -:::{versionchanged} VERSION_NEXT_FEATURE +:::{versionchanged} 1.7.0 Support added for {obj}`--bootstrap_impl=system_python`. ::: """, diff --git a/python/private/py_info.bzl b/python/private/py_info.bzl index 95b739dff2..8868b9d3b4 100644 --- a/python/private/py_info.bzl +++ b/python/private/py_info.bzl @@ -79,7 +79,7 @@ the venv to create the path under. A file that `venv_path` should point to. The file to link to should also be in `files`. -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 ::: """, "link_to_path": """ diff --git a/python/runfiles/runfiles.py b/python/runfiles/runfiles.py index 58f59c5406..fc794272c9 100644 --- a/python/runfiles/runfiles.py +++ b/python/runfiles/runfiles.py @@ -16,7 +16,7 @@ See @rules_python//python/runfiles/README.md for usage instructions. -:::{versionadded} VERSION_NEXT_FEATURE +:::{versionadded} 1.7.0 Support for Bazel's `--incompatible_compact_repo_mapping_manifest` flag was added. This enables prefix-based repository mappings to reduce memory usage for large dependency graphs under bzlmod.