Skip to content

Package ptoas CLI in wheel#909

Open
Zhendong404 wants to merge 9 commits into
hw-native-sys:mainfrom
Zhendong404:pack-ptoas-in-wheel
Open

Package ptoas CLI in wheel#909
Zhendong404 wants to merge 9 commits into
hw-native-sys:mainfrom
Zhendong404:pack-ptoas-in-wheel

Conversation

@Zhendong404

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a ptoas CLI entry point to the ptoas wheel, packaging the unified runtime binaries and libraries, and implementing a Python launcher (_launcher.py) to execute the packaged binary with the correct environment variables. Feedback on the changes includes: importing NoReturn from typing to avoid a NameError, adding a fallback path in the launcher to support editable/development installations where the _runtime directory is not packaged, and simplifying a redundant conditional check in the _has_cli_option helper function.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ptodsl/ptoas/_launcher.py
Comment on lines +11 to +15
from __future__ import annotations

import os
import sys
from pathlib import Path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The type hint NoReturn is used for the main function, but it is not imported from the typing module. This will cause static type checkers (like mypy or pyright) to fail with an undefined name error.

Suggested change
from __future__ import annotations
import os
import sys
from pathlib import Path
from __future__ import annotations
import os
import sys
from pathlib import Path
from typing import NoReturn

Comment thread ptodsl/ptoas/_launcher.py Outdated
Comment on lines +40 to +47
def main() -> "NoReturn":
package_root = Path(__file__).resolve().parent
runtime_root = package_root / "_runtime"
binary = runtime_root / "bin" / "ptoas"
if not binary.is_file():
raise SystemExit(
f"wheel runtime is missing the packaged ptoas binary: {binary}"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In an editable/development installation (e.g., pip install -e .), the _runtime directory is not packaged or copied into the source tree (ptodsl/ptoas/_runtime). As a result, when running the ptoas CLI in editable mode, binary.is_file() will be False and the launcher will fail with a SystemExit error.

To support editable/development installations, we should add a fallback to locate the binary in the build/install directory (e.g., using the PTO_INSTALL_DIR environment variable or defaulting to the in-repo install directory relative to the package root).

Suggested change
def main() -> "NoReturn":
package_root = Path(__file__).resolve().parent
runtime_root = package_root / "_runtime"
binary = runtime_root / "bin" / "ptoas"
if not binary.is_file():
raise SystemExit(
f"wheel runtime is missing the packaged ptoas binary: {binary}"
)
def main() -> "NoReturn":
package_root = Path(__file__).resolve().parent
runtime_root = package_root / "_runtime"
# Fallback for editable/development installs where _runtime is not packaged in the source tree
if not runtime_root.exists():
env_install_dir = os.environ.get("PTO_INSTALL_DIR")
if env_install_dir:
runtime_root = Path(env_install_dir)
else:
# Default to in-repo install directory: repo_root/install
runtime_root = package_root.parent.parent / "install"
binary = runtime_root / "bin" / "ptoas"
if not binary.is_file():
raise SystemExit(
f"wheel runtime is missing the packaged ptoas binary: {binary}"
)

Comment thread ptodsl/ptoas/_launcher.py
Comment on lines +30 to +37
def _has_cli_option(argv: list[str], option: str) -> bool:
option_with_value = f"{option}="
for index, arg in enumerate(argv):
if arg == option or arg.startswith(option_with_value):
return True
if arg == option and index + 1 < len(argv):
return True
return False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The second if condition in _has_cli_option is redundant and unreachable. If arg == option is true, the first if condition (arg == option or arg.startswith(option_with_value)) will already evaluate to True and return True.

We can simplify the function to remove the redundant check and the unused index variable.

def _has_cli_option(argv: list[str], option: str) -> bool:
    option_with_value = f"{option}="
    for arg in argv:
        if arg == option or arg.startswith(option_with_value):
            return True
    return False

@reedhecre

reedhecre commented Jul 7, 2026

Copy link
Copy Markdown

Codex Review

该评论由 review 机器人自动更新。

  • PR: Package ptoas CLI in wheel #909 Package ptoas CLI in wheel
  • Author: Zhendong404
  • Base/Head: main / pack-ptoas-in-wheel
  • Head SHA: 51aaf66ae5a4
  • Trigger: PR 有新提交
  • Generated At: 2026-07-11T02:15:40Z
  • Previous Head SHA: 29dcfa526e19
  • Status: failed at codex-review (exit=1)

Summary

Review failed at stage codex-review: exit=1

Findings

未生成结构化 findings,因为 review 过程提前失败。

Log Tail

From https://github.com/hw-native-sys/PTOAS
 * branch              main       -> FETCH_HEAD
Switched to branch 'pr-909'
51aaf66ae5a46f6643db33ea23ef9b366b9fb4ff
 .github/workflows/ci.yml                   |  66 ++++++++-----
 .github/workflows/ci_sim.yml               | 130 +++++++++++++++---------
 README.md                                  |   6 +-
 _ptoas_build_backend.py                    |   6 ++
 docker/create_wheel.sh                     | 110 ++++++++++++++++++++-
 docker/test_ptoas_cli.sh                   |   1 -
 docker/test_wheel_imports.sh               |  47 +++++++++
 ptodsl/CMakeLists.txt                      |  16 +++
 ptodsl/ptoas/__init__.py                   |  10 ++
 ptodsl/ptoas/_launcher.py                  |  81 +++++++++++++++
 ptodsl/ptodsl/_bootstrap.py                |  18 +++-
 ptodsl/tests/test_bootstrap_runtime_env.py |  92 +++++++++++++++++
 ptodsl/tests/test_ptoas_wheel_launcher.py  | 153 +++++++++++++++++++++++++++++
 python/pto/dialects/pto.py                 |  27 +++--
 scripts/ptoas_env.sh                       |  27 +----
 scripts/sim_dsl.sh                         |  64 ++++++++++--
 16 files changed, 735 insertions(+), 119 deletions(-)
===== END STAGE clone rc=0 @ 2026-07-11 10:15:32 =====

===== STAGE codex-review @ 2026-07-11 10:15:32 =====
set -euo pipefail
cd '/tmp/ptoas-pr-review-monitor/runs/20260711_101525_pr909/repo'
'codex' exec -C '/tmp/ptoas-pr-review-monitor/runs/20260711_101525_pr909/repo' -s read-only -c 'model_provider="codereview"' -c 'model="gpt-5.4"' -c 'model_reasoning_effort="xhigh"' --output-schema '/tmp/ptoas-pr-review-monitor/runs/20260711_101525_pr909/review_schema.json' -o '/tmp/ptoas-pr-review-monitor/runs/20260711_101525_pr909/codex_last_message.json' --color never - < '/tmp/ptoas-pr-review-monitor/runs/20260711_101525_pr909/review_prompt.txt'
[monitor] stage timeout: 1800s
OpenAI Codex v0.115.0 (research preview)
--------
workdir: /tmp/ptoas-pr-review-monitor/runs/20260711_101525_pr909/repo
model: gpt-5.4
provider: codereview
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: none
session id: 019f4ef5-6450-73d1-bcf0-36b064653e0e
--------
user
你现在在审查 GitHub PR。

仓库:hw-native-sys/PTOAS
PR:#909 Package ptoas CLI in wheel
作者:Zhendong404
base branch:origin/main
head branch:HEAD(当前已 checkout 到 PR head)

要求:
1. 只审查这个 PR 相对 origin/main 的改动,必要时可以看上下文文件。
2. 重点找真实的 correctness / regression / contract mismatch / CI / runtime / compatibility 问题。
3. 不要提纯风格建议,不要提低价值猜测。
4. 严格按优先级输出:
   - P1:高概率会导致错误结果、编译/运行失败、严重回归、发布阻断
   - P2:重要缺陷、行为回归、遗漏校验/测试、较大兼容性问题
   - P3:次要但明确可改的问题
5. 如果没有问题,summary 直接写:未检查到 PR #909 存在问题,并返回 findings=[]。
6. 如果有问题,summary 简洁概括,findings 里每条都要给出:
   - severity
   - title
   - body(说明为什么是问题,尽量具体)
   - file(尽量给相对路径)
   - line(能确定就填整数,否则 null)

建议先查看:
- git status --short
- git diff --stat origin/main...HEAD
- git diff --unified=80 origin/main...HEAD

最终输出必须严格匹配 JSON schema。

mcp startup: no servers
Reconnecting... 1/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1944d0e38843f28-LAX, request id: 2fc46bc1-3650-43b3-a98d-9909d302ba70)
Reconnecting... 2/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1944d10fbf3265a-LAX, request id: 8caf7f46-e788-49ef-8ba8-6ede2fd03bcd)
Reconnecting... 3/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1944d14fe67b82d-LAS, request id: 8a8dcd33-dfb0-4e11-be79-24d8ad7a80e1)
Reconnecting... 4/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1944d1b9fccb7c1-LAS, request id: 43ff3e69-ba8b-40ac-a4a7-4f507d0de86c)
Reconnecting... 5/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1944d2648519d07-LAS, request id: 282797f7-23b1-41e9-92be-14fce2198dc3)
ERROR: unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1944d3cb863f472-LAX, request id: d8c5958d-6d3a-4428-aec4-6237ebe7a33b
Warning: no last agent message; wrote empty content to /tmp/ptoas-pr-review-monitor/runs/20260711_101525_pr909/codex_last_message.json
===== END STAGE codex-review rc=1 @ 2026-07-11 10:15:40 =====

@Zhendong404 Zhendong404 force-pushed the pack-ptoas-in-wheel branch 3 times, most recently from b233ce6 to 1bc5ad5 Compare July 9, 2026 11:12
@Zhendong404 Zhendong404 force-pushed the pack-ptoas-in-wheel branch from 29dcfa5 to 51aaf66 Compare July 11, 2026 02:11
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