Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.
This repository was archived by the owner on May 8, 2025. It is now read-only.

main_mypy.runfiles is not a valid Python package name #120

Open
@ssmall

Description

@ssmall

This seems like it could be similar to #15 but I'm opening a new issue because it has nothing to do with protobuf. I have a plain Python application with no external dependencies that only uses rules_python and Bzlmod.

I am consistently getting the error

main_mypy.runfiles is not a valid Python package name

when running bazel test.

My source file is

main.py

def sayHello():
    return f"Hello, world!"

if __name__ == "__main__":
    print(sayHello())

and my BUILD.bazel contains:

py_binary(
    name = "main",
    srcs = ["main.py"],
    visibility = ["//:__subpackages__"],
)

mypy_test(
    name = "main_mypy",
    deps = [
        ":main",
    ],
)

Lines from relevant files:

MODULE.bazel

bazel_dep(
    name = "rules_python",
    version = "0.31.0",
)
bazel_dep(
    name = "rules_python_gazelle_plugin",
    version = "0.31.0",
)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    configure_coverage_tool = True,
    python_version = "3.12",
)

bazel_dep(
    name = "mypy_integration",
    version = "0.0.0",
)

git_override(
    module_name = "mypy_integration",
    remote = "https://github.com/bazel-contrib/bazel-mypy-integration",
    commit = "c289c0cd30e53b5cc467b601295834dbc400f4b2",
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    hub_name = "mypy_pip",
    python_version = "3.12",
    requirements_lock = "//third_party/python/mypy:requirements_lock.txt",
)
use_repo(pip, "mypy_pip")

.bazelrc

build --@mypy_integration//:mypy=//third_party/python/mypy:mypy

third_party/python/mypy/BUILD.bazel

load("@mypy_pip//:requirements.bzl", "requirement")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")

compile_pip_requirements(
    name = "requirements",
    src = "requirements.txt",
    requirements_txt = "requirements_lock.txt",
)

alias(
    name = "mypy",
    actual = requirement("mypy"),
    visibility = ["//visibility:public"],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions