Skip to content

Minimal version of #1082 - just add the __init__.py files - #1087

Draft
aiuto wants to merge 2 commits into
bazelbuild:mainfrom
aiuto:init
Draft

aiuto wants to merge 2 commits into
bazelbuild:mainfrom
aiuto:init

Conversation

@aiuto

@aiuto aiuto commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@onnosteenbergen-samotics

Copy link
Copy Markdown

A small test project still reports warnings.

use_lib.py

from pkg.private import manifest
import pkg, pkg.private
print("ok", manifest.__file__, pkg.__file__, pkg.private.__file__)

BUILD

load("@rules_pkg//pkg:deb.bzl", "pkg_deb")
load("@rules_pkg//pkg:install.bzl", "pkg_install")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:verify_archive.bzl", "verify_archive_test")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")

pkg_files(name = "files", srcs = ["hello.txt"], prefix = "usr/share/hello")

pkg_tar(name = "my_tar", srcs = [":files"])

pkg_zip(name = "my_zip", srcs = [":files"])

pkg_tar(name = "data", srcs = [":files"], extension = "tar.gz")

pkg_deb(
    name = "my_deb",
    data = ":data",
    package = "hello",
    version = "1.0",
    architecture = "all",
    maintainer = "x <x@example.com>",
    description = "test",
)

pkg_install(name = "install", srcs = [":files"])

verify_archive_test(
    name = "verify_tar",
    target = ":my_tar",
    must_contain = ["usr/share/hello/hello.txt"],
)

load("@rules_python//python:py_binary.bzl", "py_binary")

py_binary(
    name = "use_lib",
    srcs = ["use_lib.py"],
    deps = ["@rules_pkg//pkg/private:manifest"],
)

MODULE.bazel

module(name = "consumer")
bazel_dep(name = "rules_pkg")
local_path_override(module_name = "rules_pkg", path = "../pr1087")
bazel_dep(name = "rules_python", version = "2.3.0")

rules_python_config = use_extension("@rules_python//python/extensions:config.bzl", "config")
rules_python_config.explicit_init_py(default = True)
$ bazel shutdown
$ bazel build //...
Starting local Bazel server (9.3.0) and connecting to it...
DEBUG: .../rules_python+/python/private/py_executable.bzl:1595:14: 
======================================================================
WARNING: Target @@rules_pkg+//pkg/private/zip:build_zip is using implicit __init__.py creation.
  This diabolic behavior is deprecated and will be disabled by default in a
  future release.
  See https://github.com/bazel-contrib/rules_python/issues/2945

  Ensure all __init__.py files are explicitly created and
  added to the srcs or deps of your targets.

  Disable implicit creation for your module in MODULE.bazel:

    rules_python_config = use_extension("@rules_python//python/extensions:config.bzl", "config")
    rules_python_config.explicit_init_py(default = True)

  Or for a specific target by setting:

    legacy_create_init = 0

  Or globally with the following Bazel flag:

    --incompatible_default_to_explicit_init_py
======================================================================
DEBUG: .../rules_python+/python/private/py_executable.bzl:1595:14: 
======================================================================
WARNING: Target @@rules_pkg+//pkg/private/tar:build_tar is using implicit __init__.py creation.
  This diabolic behavior is deprecated and will be disabled by default in a
  future release.
  See https://github.com/bazel-contrib/rules_python/issues/2945

  Ensure all __init__.py files are explicitly created and
  added to the srcs or deps of your targets.

  Disable implicit creation for your module in MODULE.bazel:

    rules_python_config = use_extension("@rules_python//python/extensions:config.bzl", "config")
    rules_python_config.explicit_init_py(default = True)

  Or for a specific target by setting:

    legacy_create_init = 0

  Or globally with the following Bazel flag:

    --incompatible_default_to_explicit_init_py
======================================================================
DEBUG: .../rules_python+/python/private/py_executable.bzl:1595:14: 
======================================================================
WARNING: Target @@rules_pkg+//pkg/private/deb:make_deb is using implicit __init__.py creation.
  This diabolic behavior is deprecated and will be disabled by default in a
  future release.
  See https://github.com/bazel-contrib/rules_python/issues/2945

  Ensure all __init__.py files are explicitly created and
  added to the srcs or deps of your targets.

  Disable implicit creation for your module in MODULE.bazel:

    rules_python_config = use_extension("@rules_python//python/extensions:config.bzl", "config")
    rules_python_config.explicit_init_py(default = True)

  Or for a specific target by setting:

    legacy_create_init = 0

  Or globally with the following Bazel flag:

    --incompatible_default_to_explicit_init_py
======================================================================
INFO: Analyzed 10 targets (103 packages loaded, 3269 targets configured).
INFO: Found 10 targets...
INFO: Elapsed time: 3.321s, Critical Path: 0.06s
INFO: 1 process: 82 action cache hit, 1 internal.
INFO: Build completed successfully, 1 total action

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants