mirror of
https://github.com/Z3Prover/z3
synced 2026-08-02 12:13:25 +00:00
The generated Python bindings loaded `libz3.so` without a soversion,
which could bind to an ABI-incompatible shared library when multiple Z3
versions are present. This change makes Linux bindings prefer the
versioned soname while leaving other platforms on the existing lookup
path.
- **Python loader generation**
- Thread a `z3py_soversion` parameter through `scripts/update_api.py`.
- Generate `_lib_name` as `libz3.so.<major>.<minor>` on Linux, and keep
`libz3.<ext>` elsewhere.
- Reuse `_lib_name` consistently for directory probing, system fallback,
and error messages.
- **Build-system wiring**
- Pass the current `SOVERSION` from the CMake Python bindings build on
Linux.
- Pass the same value through the `mk_make`/`mk_util.py` generation path
so both build systems emit the same loader behavior.
- **In-tree Python bindings layout**
- Add the matching `libz3.so.<major>.<minor>` link in `build/python/` on
Linux so the generated bindings work directly from the build tree.
- **Regression coverage**
- Add a focused script-level test for the generated loader preamble to
check:
- Linux uses the versioned soname when provided.
- Non-versioned fallback remains available when no soversion is
supplied.
Example of the generated Linux loader behavior:
```python
_sover = '5.0'
_ext = 'so'
_lib_name = 'libz3.%s.%s' % (_ext, _sover) if sys.platform.startswith('linux') and _sover else 'libz3.%s' % _ext
_lib = ctypes.CDLL(_lib_name)
```
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #7518
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
Co-authored-by: Nikolaj Bjorner <nikolaj@cs.stanford.edu>
|
||
|---|---|---|
| .. | ||
| tests | ||
| build-win-signed-cmake.yml | ||
| build-win-signed.yml | ||
| build_libcxx_msan.sh | ||
| coverage.yml | ||
| find_non_defined_param_eval_patterns.py | ||
| generate-doc.yml | ||
| jsdoctest.yml | ||
| mk_consts_files.py | ||
| mk_copyright.py | ||
| mk_def_file.py | ||
| mk_exception.py | ||
| mk_genfile_common.py | ||
| mk_gparams_register_modules_cpp.py | ||
| mk_install_tactic_cpp.py | ||
| mk_make.py | ||
| mk_mem_initializer_cpp.py | ||
| mk_nuget_task.py | ||
| mk_pat_db.py | ||
| mk_project.py | ||
| mk_unix_dist.py | ||
| mk_unix_dist_cmake.py | ||
| mk_util.py | ||
| mk_win_dist.py | ||
| mk_win_dist_cmake.py | ||
| policy.json | ||
| pyg2hpp.py | ||
| README | ||
| test-examples-cmake.yml | ||
| test-java-cmake.yml | ||
| test-jupyter.yml | ||
| test-regressions-coverage.yml | ||
| test-regressions.yml | ||
| test-z3.yml | ||
| trackall.sh | ||
| update_api.py | ||
| update_header_guards.py | ||
| update_include.py | ||
| update_version.py | ||
| VERSION.txt | ||
| vsts-mac.sh | ||
| vsts-vs2013.cmd | ||
| vsts-vs2017.cmd | ||
Instructions for updating external Z3 API ----------------------------------------- The python "macros": def_Type() and def_API() are used to add new types and function definitions to the Z3 API. The .h files provided to `mk_bindings(API_files)` contain these definitions. See src\api\z3_api.h for many examples. The bindings for .Net and Python are generated when mk_make.py is invoked.