3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-02 12:13:25 +00:00
z3/scripts
Copilot 5af999eb4f
Load versioned libz3 soname in Python bindings on Linux (#10290)
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>
2026-07-29 14:01:55 -07:00
..
tests Load versioned libz3 soname in Python bindings on Linux (#10290) 2026-07-29 14:01:55 -07:00
build-win-signed-cmake.yml Update build-win-signed-cmake.yml 2025-06-19 10:18:03 -07:00
build-win-signed.yml increase timeout on windows build 2026-01-05 09:09:57 -08:00
build_libcxx_msan.sh restore exec bit on configure & scripts/*.sh 2020-05-16 20:07:36 +01:00
coverage.yml jobs 2021-07-30 22:38:56 -07:00
find_non_defined_param_eval_patterns.py rename a Python file 2025-08-07 08:33:04 -07:00
generate-doc.yml ocamldoc 2021-01-29 06:47:10 -08:00
jsdoctest.yml Standardize ubutu-latest vmImage 2022-08-15 07:55:45 -07:00
mk_consts_files.py try without #!/bin/env python #5397 2021-07-10 15:20:56 +02:00
mk_copyright.py
mk_def_file.py try without #!/bin/env python #5397 2021-07-10 15:20:56 +02:00
mk_exception.py
mk_genfile_common.py Remove unnecessary blank lines in mk_genfile_common.py and mk_api_doc.py 2026-02-19 17:52:11 +00:00
mk_gparams_register_modules_cpp.py try without #!/bin/env python #5397 2021-07-10 15:20:56 +02:00
mk_install_tactic_cpp.py try without #!/bin/env python #5397 2021-07-10 15:20:56 +02:00
mk_make.py removed comments 2016-02-14 19:57:21 +00:00
mk_mem_initializer_cpp.py try without #!/bin/env python #5397 2021-07-10 15:20:56 +02:00
mk_nuget_task.py Fix NuGet packaging to handle dynamic glibc versions (#8474) 2026-02-02 09:16:27 -08:00
mk_pat_db.py try without #!/bin/env python #5397 2021-07-10 15:20:56 +02:00
mk_project.py Remove tptp5 example 2026-07-29 14:01:08 -07:00
mk_unix_dist.py Fix macOS cross-compilation from ARM64 to x86_64 in mk_unix_dist.py and mk_util.py 2026-02-19 18:02:52 +00:00
mk_unix_dist_cmake.py porting unix distribution script to cmake 2024-01-30 16:28:52 -08:00
mk_util.py Load versioned libz3 soname in Python bindings on Linux (#10290) 2026-07-29 14:01:55 -07:00
mk_win_dist.py use single thread for win-dist 2025-03-02 19:23:19 -08:00
mk_win_dist_cmake.py 2nd attempt to use uniform java library location under bin #7406 2024-09-30 10:05:09 -07:00
policy.json add ESRP signing of nuget packages 2019-02-27 14:43:39 -08:00
pyg2hpp.py try without #!/bin/env python #5397 2021-07-10 15:20:56 +02:00
README
test-examples-cmake.yml Remove tptp5 example 2026-07-29 14:01:08 -07:00
test-java-cmake.yml fix typos in script 2023-11-28 16:50:28 -08:00
test-jupyter.yml extract jupyter template 2019-06-11 11:52:42 -07:00
test-regressions-coverage.yml rename 2021-07-29 11:32:20 -07:00
test-regressions.yml more templates 2019-06-12 08:35:34 -07:00
test-z3.yml update pipelines 2019-06-12 01:25:43 -07:00
trackall.sh restore exec bit on configure & scripts/*.sh 2020-05-16 20:07:36 +01:00
update_api.py Load versioned libz3 soname in Python bindings on Linux (#10290) 2026-07-29 14:01:55 -07:00
update_header_guards.py
update_include.py update header include generation to use relative paths #534 2017-08-03 08:50:04 -07:00
update_version.py update release 2026-02-08 20:10:43 -08:00
VERSION.txt update version 2026-07-16 15:39:15 -07:00
vsts-mac.sh remove stale references to gac/csc 2020-07-26 12:03:03 -07:00
vsts-vs2013.cmd remove python doc test 2018-03-20 13:37:04 -07:00
vsts-vs2017.cmd rename additional build options #2709 2019-11-18 23:02:44 -08:00

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.