Skip to content

[envpool] migrate Bazel Qt rules in-tree - #341

Merged
Trinkle23897 merged 1 commit into
mainfrom
jiayi/envpool-phase5-infra-python
Mar 22, 2026
Merged

[envpool] migrate Bazel Qt rules in-tree#341
Trinkle23897 merged 1 commit into
mainfrom
jiayi/envpool-phase5-infra-python

Conversation

@Trinkle23897

Copy link
Copy Markdown
Collaborator

Summary

  • Problem: EnvPool still depends on the archived bazel_rules_qt repository even though the repo only needs a very small local Qt wrapper for Procgen, and the current branch also needed a small box2d typing fix to keep lint moving.
  • Scope: Replaces the external bazel_rules_qt archive with repo-local Qt configure/build files used by Procgen, and includes a narrow box2d_correctness_test.py mypy fix. It does not change threadpool, gym3_libenv, or bazel_clang_tidy pins.
  • Outcome: Bazel no longer fetches the archived Qt ruleset, Procgen continues to build against the local Linux Qt install, and box2d_correctness_test.py no longer trips mypy on scalar/shape comparisons.

This keeps the Qt dependency surface in-tree and removes a dead external Bazel rules dependency without changing Procgen's linked Qt libraries.

Technical Details

  • Approach: Add a minimal Linux-only third_party/qt repository rule that resolves the local Qt include directory and exposes the qt_core/qt_gui libraries EnvPool actually uses; then wire WORKSPACE and workspace1.bzl to those local rules.
  • Code pointers:
    • third_party/qt/qt_configure.bzl: minimal local Qt repository rule that finds the Qt headers and templates local_qt.bzl
    • third_party/qt/qt.BUILD: repo-local qt_core / qt_gui Bazel targets used by Procgen
    • WORKSPACE: rewires @qt to the in-repo Qt BUILD file and drops the external Qt toolchain registration
    • envpool/box2d/box2d_correctness_test.py: swaps two assert_allclose calls for assertEqual to satisfy mypy on shape/discrete-cardinality checks
  • Notes: upstream justbuchanan/bazel_rules_qt is archived and the previous pin was already at upstream head, so this is a replacement rather than a version bump.

Test Plan

Automated

  • make buildifier: pass
  • make addlicense: pass
  • make mypy: pass
  • USE_BAZEL_VERSION=8.6.0 bazelisk test //envpool/procgen:procgen_env_test //envpool/procgen:procgen_test --enable_workspace --noenable_bzlmod --config=test --test_output=errors --nocache_test_results on dev-0: pass
  • make bazel-test on dev-0: 30 / 30 tests pass
  • make lint on dev-0: in progress; flake8, py-format, clang-format, cpplint, buildifier, addlicense, mypy, docstyle, and spelling have passed, and only the long-running clang-tidy tail remains

Suggested Manual

  • make lint on a Linux devbox: confirm the remaining clang-tidy tail finishes cleanly on the exact tree in this PR

@Trinkle23897
Trinkle23897 merged commit f5e2010 into main Mar 22, 2026
2 of 4 checks passed
@Trinkle23897
Trinkle23897 deleted the jiayi/envpool-phase5-infra-python branch March 22, 2026 21:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7316cdc541

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +49 to +52
qt_autoconf = repository_rule(
implementation = _qt_autoconf_impl,
configure = True,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track BAZEL_RULES_QT_DIR in the repository rule

If a developer sets or changes BAZEL_RULES_QT_DIR after the first fetch, Bazel can keep reusing the cached @local_config_qt repository because qt_autoconf does not declare that environment variable as an input. Reading repository_ctx.os.environ directly here means the generated local_qt.bzl can stay pinned to a stale header path until the user manually cleans or syncs, which makes switching/fixing Qt installations unexpectedly fail.

Useful? React with 👍 / 👎.

Comment thread third_party/qt/qt.BUILD
allow_empty = True,
),
includes = ["."],
linkopts = ["-lQt5Core"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add the configured Qt libdir to the link flags

When BAZEL_RULES_QT_DIR points at a non-system Qt installation (for example /opt/Qt/...), this target still links with bare -lQt5Core/-lQt5Gui flags and never adds that prefix's lib directory. In that setup the headers resolve because new_local_repository is rooted at the include tree, but the final link still searches only the default system paths and fails to find the Qt shared libraries.

Useful? React with 👍 / 👎.

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.

1 participant