Skip to content

How to cache ResolveRequirementEnvMarkers to reduce execution time in Bazel pip.parse (Bzlmod) #3510

@huyhoang8704

Description

@huyhoang8704

Hi everyone,

I’m currently using Bazel with Bzlmod, integrating Python dependencies via pip.parse.

During every build, I consistently see the following step being executed:

Running ResolveRequirementEnvMarkers(~/.momo/bazel-cache/local/modextwd/ruclearles_python~~pip/requirements_with_markers.in.json)
This step takes around 20–30 seconds each time, even when:

  • requirements.txt hasn’t changed
  • The Python version and platform remain the same
  • The Bazel cache is already warm

From what I understand, ResolveRequirementEnvMarkers is re-evaluating environment markers for Python dependencies, but it doesn’t seem to benefit from Bazel’s cache.

My questions:

  • Is this step expected to always run on every build when using pip.parse with Bzlmod?
  • Is there any supported way to cache or reuse the result of ResolveRequirementEnvMarkers?
  • Are there recommended Bazel flags or configuration (e.g. repository cache, module extension cache, lock files, etc.) to avoid re-running this step?
  • Would using pip.parse(..., requirements_lock = ...) or pre-generated lock files help here?
  • Any guidance or best practices to reduce the runtime of this step would be greatly appreciated.

Thanks in advance!

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