Skip to content

Expose z3-static CMake config CLI#109

Merged
tqchen merged 1 commit into
mainfrom
z3-static-config-cli
Jun 16, 2026
Merged

Expose z3-static CMake config CLI#109
tqchen merged 1 commit into
mainfrom
z3-static-config-cli

Conversation

@Ubospica

Copy link
Copy Markdown
Contributor

Summary

  • Add python -m z3_static.config --cmake-dir as a stable way for native build systems to locate the packaged Z3 CMake files.
  • Exercise the CLI in the static library smoke test and document the CMake integration pattern.
  • Allow the z3-static wheel workflow to publish package-only post releases such as 4.16.0.post1 without changing the upstream Z3 tag.

Validation

  • python -m compileall packages/z3-static/z3_static packages/z3-static/scripts/smoke_test_staticlib.py
  • PYTHONPATH=packages/z3-static python -m z3_static.config --cmake-dir
  • PYTHONPATH=packages/z3-static python -m z3_static.config

Add a stable python -m z3_static.config entry point so native builds can locate the packaged Z3 CMake files without depending on wheel internals.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a command-line configuration helper (z3_static.config) to retrieve the CMake directory for z3-static, updates the documentation and smoke tests to use this new CLI, and adds a version-suffix input to the GitHub Action for building wheels. The feedback suggests improving the CMake documentation snippet by adding COMMAND_ERROR_IS_FATAL ANY to handle execution failures gracefully, and refactoring the argument parsing logic in config.py to robustly handle empty argument lists when invoked programmatically.

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 on lines +31 to +35
execute_process(
COMMAND "${Python_EXECUTABLE}" -m z3_static.config --cmake-dir
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE Z3_DIR
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since the minimum required CMake version for this project is 3.20 (as seen in the smoke test), we can use COMMAND_ERROR_IS_FATAL ANY to ensure that any failure in the Python script (e.g., if z3-static is not installed or there is a Python error) is immediately caught and fails the CMake configuration with a clear error message, rather than failing later with a generic "Z3 CONFIG REQUIRED" error.

Suggested change
execute_process(
COMMAND "${Python_EXECUTABLE}" -m z3_static.config --cmake-dir
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE Z3_DIR
)
execute_process(
COMMAND "${Python_EXECUTABLE}" -m z3_static.config --cmake-dir
OUTPUT_VARIABLE Z3_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY
)

Comment on lines +20 to +26
args = parser.parse_args(argv)
if argv is None and len(sys.argv) == 1:
parser.print_help()
return

if args.cmake_dir:
print(get_cmake_dir())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current check argv is None and len(sys.argv) == 1 does not handle cases where argv is passed as an empty list (e.g., main([]) in testing or programmatic invocation). Checking the actual arguments list (either argv or sys.argv[1:]) before parsing is more robust and avoids unnecessary parsing when no arguments are provided.

Suggested change
args = parser.parse_args(argv)
if argv is None and len(sys.argv) == 1:
parser.print_help()
return
if args.cmake_dir:
print(get_cmake_dir())
args_list = sys.argv[1:] if argv is None else argv
if not args_list:
parser.print_help()
return
args = parser.parse_args(argv)
if args.cmake_dir:
print(get_cmake_dir())

@tqchen tqchen merged commit aa7fa49 into main Jun 16, 2026
8 checks passed
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