From 0af3f88e078b0313faf94456dbd1e52a7fa272b6 Mon Sep 17 00:00:00 2001 From: Oleksandr Fedorov Date: Wed, 27 May 2026 15:33:57 +0200 Subject: [PATCH 1/2] fix: exclude docs package from google-cloud-audit-log wheel --- packages/google-cloud-audit-log/setup.py | 4 +++- .../tests/unit/test_packaging.py | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/google-cloud-audit-log/setup.py b/packages/google-cloud-audit-log/setup.py index 238055125f0d..840feb929533 100644 --- a/packages/google-cloud-audit-log/setup.py +++ b/packages/google-cloud-audit-log/setup.py @@ -58,7 +58,9 @@ long_description_content_type="text/markdown", install_requires=dependencies, license="Apache-2.0", - packages=find_namespace_packages(exclude=("tests*", "testing*")), + packages=find_namespace_packages( + include=("google*",), exclude=("docs*", "tests*", "testing*") + ), python_requires=">=3.9", url="https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-audit-log", include_package_data=True, diff --git a/packages/google-cloud-audit-log/tests/unit/test_packaging.py b/packages/google-cloud-audit-log/tests/unit/test_packaging.py index 80b0aa0d7a61..7f1a10548589 100644 --- a/packages/google-cloud-audit-log/tests/unit/test_packaging.py +++ b/packages/google-cloud-audit-log/tests/unit/test_packaging.py @@ -37,3 +37,26 @@ def test_namespace_package_compat(tmp_path): env = dict(os.environ, PYTHONPATH=str(tmp_path)) cmd = [sys.executable, "-m", "google.cloud.othermod"] subprocess.check_call(cmd, env=env) + + +def test_setup_py_does_not_discover_docs_package(monkeypatch): + import pathlib + import runpy + + captured_kwargs = {} + + def fake_setup(**kwargs): + captured_kwargs.update(kwargs) + + package_root = pathlib.Path(__file__).parents[2] + monkeypatch.chdir(package_root) + monkeypatch.setattr("setuptools.setup", fake_setup) + + runpy.run_path(str(package_root / "setup.py"), run_name="__main__") + + packages = captured_kwargs["packages"] + + assert "google.cloud.audit" in packages + assert not any( + package == "docs" or package.startswith("docs.") for package in packages + ) From 5fb2ac3f4547ccfcb752b881130e82027e89ba47 Mon Sep 17 00:00:00 2001 From: Oleksandr Fedorov Date: Wed, 27 May 2026 19:45:25 +0200 Subject: [PATCH 2/2] test: update packaging test to inspect installed metadata The CI unit test environments do not keep setuptools installed at runtime, even though the package is installed before tests run. Inspect the installed google-cloud-audit-log metadata instead of executing setup.py and monkeypatching setuptools.setup. --- .../tests/unit/test_packaging.py | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/packages/google-cloud-audit-log/tests/unit/test_packaging.py b/packages/google-cloud-audit-log/tests/unit/test_packaging.py index 7f1a10548589..d6a184296329 100644 --- a/packages/google-cloud-audit-log/tests/unit/test_packaging.py +++ b/packages/google-cloud-audit-log/tests/unit/test_packaging.py @@ -15,6 +15,7 @@ import os import subprocess import sys +from importlib import metadata # See https://docs.pytest.org/en/stable/how-to/tmp_path.html#the-tmp-path-fixture @@ -39,24 +40,13 @@ def test_namespace_package_compat(tmp_path): subprocess.check_call(cmd, env=env) -def test_setup_py_does_not_discover_docs_package(monkeypatch): - import pathlib - import runpy - - captured_kwargs = {} - - def fake_setup(**kwargs): - captured_kwargs.update(kwargs) - - package_root = pathlib.Path(__file__).parents[2] - monkeypatch.chdir(package_root) - monkeypatch.setattr("setuptools.setup", fake_setup) - - runpy.run_path(str(package_root / "setup.py"), run_name="__main__") +def test_top_level_package_metadata_excludes_docs(): + top_level = metadata.distribution("google-cloud-audit-log").read_text( + "top_level.txt" + ) - packages = captured_kwargs["packages"] + assert top_level is not None + top_level_packages = set(top_level.splitlines()) - assert "google.cloud.audit" in packages - assert not any( - package == "docs" or package.startswith("docs.") for package in packages - ) + assert "google" in top_level_packages + assert "docs" not in top_level_packages