mlc-z3-static 4.16.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mlc_z3_static-4.16.0/CMakeLists.txt +31 -0
- mlc_z3_static-4.16.0/LICENSE +26 -0
- mlc_z3_static-4.16.0/PKG-INFO +156 -0
- mlc_z3_static-4.16.0/README.md +137 -0
- mlc_z3_static-4.16.0/example_project/CMakeLists.txt +30 -0
- mlc_z3_static-4.16.0/example_project/README.md +30 -0
- mlc_z3_static-4.16.0/example_project/cpp/main.cpp +20 -0
- mlc_z3_static-4.16.0/example_project/pyproject.toml +23 -0
- mlc_z3_static-4.16.0/example_project/scripts/link_static.sh +29 -0
- mlc_z3_static-4.16.0/example_project/src/mlc_z3_static_example/__init__.py +1 -0
- mlc_z3_static-4.16.0/example_project/src/mlc_z3_static_example/__main__.py +14 -0
- mlc_z3_static-4.16.0/pyproject.toml +68 -0
- mlc_z3_static-4.16.0/scripts/cibuildwheel_run.sh +20 -0
- mlc_z3_static-4.16.0/scripts/copy_wheel.py +19 -0
- mlc_z3_static-4.16.0/scripts/prepare_z3_v4_16_0.py +418 -0
- mlc_z3_static-4.16.0/scripts/smoke_test_mlc_z3_static.py +152 -0
- mlc_z3_static-4.16.0/scripts/wheel_macos_v4_16_0.sh +79 -0
- mlc_z3_static-4.16.0/scripts/wheel_manylinux_2_28_v4_16_0.sh +68 -0
- mlc_z3_static-4.16.0/scripts/wheel_verify.sh +137 -0
- mlc_z3_static-4.16.0/src/mlc_z3_static/__init__.py +119 -0
- mlc_z3_static-4.16.0/src/mlc_z3_static/_version.py +3 -0
- mlc_z3_static-4.16.0/src/mlc_z3_static/config.py +51 -0
- mlc_z3_static-4.16.0/src/mlc_z3_static/py.typed +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.26)
|
|
2
|
+
project(mlc_z3_static LANGUAGES NONE)
|
|
3
|
+
|
|
4
|
+
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
|
5
|
+
|
|
6
|
+
if(NOT "$ENV{MLC_Z3_STATIC_ALLOW_SOURCE_BUILD}" STREQUAL "1")
|
|
7
|
+
message(FATAL_ERROR
|
|
8
|
+
"mlc-z3-static source builds are disabled by default. Install a prebuilt "
|
|
9
|
+
"wheel, or set MLC_Z3_STATIC_ALLOW_SOURCE_BUILD=1 to build Z3 from source "
|
|
10
|
+
"explicitly.")
|
|
11
|
+
endif()
|
|
12
|
+
|
|
13
|
+
set(MLC_Z3_STATIC_STAGE_DIR "${CMAKE_BINARY_DIR}/staged/mlc_z3_static")
|
|
14
|
+
set(MLC_Z3_STATIC_BUILD_ROOT "${CMAKE_BINARY_DIR}/z3-build")
|
|
15
|
+
|
|
16
|
+
add_custom_target(stage_mlc_z3_static ALL
|
|
17
|
+
COMMAND
|
|
18
|
+
"${CMAKE_COMMAND}" -E env
|
|
19
|
+
"MLC_Z3_STATIC_PACKAGE_DIR=${MLC_Z3_STATIC_STAGE_DIR}"
|
|
20
|
+
"MLC_Z3_STATIC_BUILD_ROOT=${MLC_Z3_STATIC_BUILD_ROOT}"
|
|
21
|
+
"MLC_Z3_STATIC_CMAKE_GENERATOR=${CMAKE_GENERATOR}"
|
|
22
|
+
"${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prepare_z3_v4_16_0.py"
|
|
23
|
+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
24
|
+
COMMENT "Building Z3 static and shared artifacts"
|
|
25
|
+
VERBATIM
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
install(DIRECTORY "${MLC_Z3_STATIC_STAGE_DIR}/static" DESTINATION mlc_z3_static)
|
|
29
|
+
install(DIRECTORY "${MLC_Z3_STATIC_STAGE_DIR}/shared" DESTINATION mlc_z3_static)
|
|
30
|
+
install(DIRECTORY "${MLC_Z3_STATIC_STAGE_DIR}/licenses" DESTINATION mlc_z3_static)
|
|
31
|
+
install(FILES "${MLC_Z3_STATIC_STAGE_DIR}/staticlib.json" DESTINATION mlc_z3_static)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
This package is distributed under the MIT License.
|
|
2
|
+
|
|
3
|
+
The packaged Z3 artifacts are distributed under the upstream Z3 MIT License,
|
|
4
|
+
which is included in the wheel as mlc_z3_static/licenses/LICENSE-Z3.txt.
|
|
5
|
+
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) MLC AI
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mlc-z3-static
|
|
3
|
+
Version: 4.16.0
|
|
4
|
+
Summary: Prebuilt Z3 4.16.0 static and shared libraries, headers, and CMake metadata
|
|
5
|
+
Keywords: z3,smt,static-library,cmake
|
|
6
|
+
Author-Email: MLC AI <mlc.ai.dev@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: C++
|
|
14
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
15
|
+
Project-URL: Repository, https://github.com/mlc-ai/package
|
|
16
|
+
Project-URL: Z3, https://github.com/Z3Prover/z3
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# mlc-z3-static
|
|
21
|
+
|
|
22
|
+
`mlc-z3-static` is a Python package that carries native Z3 4.16.0 development
|
|
23
|
+
artifacts for build systems. It does not provide Z3 Python bindings.
|
|
24
|
+
|
|
25
|
+
The wheel contains:
|
|
26
|
+
|
|
27
|
+
- Z3 C and C++ headers.
|
|
28
|
+
- A position-independent static `libz3` (`libz3.a` on Unix-like platforms,
|
|
29
|
+
`.lib` on Windows).
|
|
30
|
+
- A shared `libz3`.
|
|
31
|
+
- Relocatable CMake and pkg-config metadata for each library flavor, under
|
|
32
|
+
`mlc_z3_static/<kind>/lib/cmake/z3` and `mlc_z3_static/<kind>/lib/pkgconfig`
|
|
33
|
+
for `kind` in `static` and `shared`.
|
|
34
|
+
|
|
35
|
+
The package is built with scikit-build-core: building a wheel runs
|
|
36
|
+
`scripts/prepare_z3_v4_16_0.py`, which downloads the pinned Z3 source archive,
|
|
37
|
+
verifies its SHA-256 digest, and builds both library flavors. Source builds are
|
|
38
|
+
opt-in (`MLC_Z3_STATIC_ALLOW_SOURCE_BUILD=1`) to avoid accidental long Z3
|
|
39
|
+
builds when pip cannot find a matching prebuilt wheel.
|
|
40
|
+
|
|
41
|
+
## Python Helpers
|
|
42
|
+
|
|
43
|
+
Build systems can locate the packaged artifacts from Python:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import mlc_z3_static
|
|
47
|
+
|
|
48
|
+
print(mlc_z3_static.get_cmake_dir("static"))
|
|
49
|
+
print(mlc_z3_static.get_cmake_prefix_path("shared"))
|
|
50
|
+
print(mlc_z3_static.get_static_library_path())
|
|
51
|
+
print(mlc_z3_static.get_shared_library_path())
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or from a build script through the configuration CLI:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
python -m mlc_z3_static.config --cmake-dir
|
|
58
|
+
python -m mlc_z3_static.config --prefix --kind shared
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Downstream CMake Usage
|
|
62
|
+
|
|
63
|
+
Install the wheel into the Python environment used by the downstream build:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python -m pip install mlc-z3-static==4.16.0
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Point CMake at the packaged static Z3 and use Z3's exported target:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cmake -S . -B build \
|
|
73
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
74
|
+
-DZ3_DIR="$(python -m mlc_z3_static.config --cmake-dir)"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```cmake
|
|
78
|
+
cmake_minimum_required(VERSION 3.20)
|
|
79
|
+
project(my_z3_consumer LANGUAGES C CXX)
|
|
80
|
+
|
|
81
|
+
find_package(Z3 CONFIG REQUIRED)
|
|
82
|
+
|
|
83
|
+
add_executable(my_z3_consumer main.cpp)
|
|
84
|
+
target_link_libraries(my_z3_consumer PRIVATE z3::libz3)
|
|
85
|
+
target_compile_features(my_z3_consumer PRIVATE cxx_std_20)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Or resolve the directory from inside CMake:
|
|
89
|
+
|
|
90
|
+
```cmake
|
|
91
|
+
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
|
92
|
+
execute_process(
|
|
93
|
+
COMMAND "${Python3_EXECUTABLE}" -m mlc_z3_static.config --cmake-dir
|
|
94
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
95
|
+
OUTPUT_VARIABLE Z3_DIR
|
|
96
|
+
)
|
|
97
|
+
find_package(Z3 CONFIG REQUIRED)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Z3 is implemented in C++, so even C-only consumers should enable CXX in the
|
|
101
|
+
CMake project and let CMake link through a C++ linker when using the static
|
|
102
|
+
archive. Use `--kind shared` (or `get_cmake_prefix_path("shared")`) to link the
|
|
103
|
+
shared flavor instead; each flavor has its own relocatable CMake prefix. See
|
|
104
|
+
`example_project/` for a complete uv-managed consumer.
|
|
105
|
+
|
|
106
|
+
## Local Build
|
|
107
|
+
|
|
108
|
+
Build a wheel directly:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
MLC_Z3_STATIC_ALLOW_SOURCE_BUILD=1 python -m build --wheel
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Use an existing Z3 checkout instead of downloading the pinned archive:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
MLC_Z3_STATIC_ALLOW_SOURCE_BUILD=1 \
|
|
118
|
+
MLC_Z3_STATIC_SOURCE_DIR=/path/to/z3 \
|
|
119
|
+
python -m build --wheel
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Build Release Wheels
|
|
123
|
+
|
|
124
|
+
From this directory:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
scripts/wheel_manylinux_2_28_v4_16_0.sh
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
scripts/wheel_macos_v4_16_0.sh
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The scripts use `uv` for host-side Python tooling, so Debian/Ubuntu system
|
|
135
|
+
Python restrictions such as PEP 668 and missing `ensurepip` do not affect the
|
|
136
|
+
host CIBW runner or post-build verifier. Both run `cibuildwheel==3.3.1`, retag
|
|
137
|
+
Linux wheels as `manylinux_2_28`, and verify each produced wheel from a clean
|
|
138
|
+
temporary virtual environment with:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
scripts/wheel_verify.sh wheelhouse/<wheel-file>.whl
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The verifier installs the wheel, configures a small CMake project against
|
|
145
|
+
`mlc_z3_static.get_cmake_prefix_path("static")`, links to `z3::libz3`, runs the
|
|
146
|
+
executable, and checks that the executable does not link against a dynamic
|
|
147
|
+
`libz3`.
|
|
148
|
+
|
|
149
|
+
The manylinux script defaults to the host architecture. Set
|
|
150
|
+
`MLC_Z3_STATIC_ARCH=x86_64` or `MLC_Z3_STATIC_ARCH=aarch64` to choose explicitly.
|
|
151
|
+
|
|
152
|
+
On macOS, local CIBW builds require an official python.org CPython installation.
|
|
153
|
+
The script defaults to the newest installed python.org CPython only as the build
|
|
154
|
+
interpreter. The output wheel is still Python-agnostic and tagged
|
|
155
|
+
`py3-none-<platform>`. Override `CIBW_BUILD` to force a specific installed build
|
|
156
|
+
interpreter, for example `CIBW_BUILD=cp313-macosx_arm64`.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# mlc-z3-static
|
|
2
|
+
|
|
3
|
+
`mlc-z3-static` is a Python package that carries native Z3 4.16.0 development
|
|
4
|
+
artifacts for build systems. It does not provide Z3 Python bindings.
|
|
5
|
+
|
|
6
|
+
The wheel contains:
|
|
7
|
+
|
|
8
|
+
- Z3 C and C++ headers.
|
|
9
|
+
- A position-independent static `libz3` (`libz3.a` on Unix-like platforms,
|
|
10
|
+
`.lib` on Windows).
|
|
11
|
+
- A shared `libz3`.
|
|
12
|
+
- Relocatable CMake and pkg-config metadata for each library flavor, under
|
|
13
|
+
`mlc_z3_static/<kind>/lib/cmake/z3` and `mlc_z3_static/<kind>/lib/pkgconfig`
|
|
14
|
+
for `kind` in `static` and `shared`.
|
|
15
|
+
|
|
16
|
+
The package is built with scikit-build-core: building a wheel runs
|
|
17
|
+
`scripts/prepare_z3_v4_16_0.py`, which downloads the pinned Z3 source archive,
|
|
18
|
+
verifies its SHA-256 digest, and builds both library flavors. Source builds are
|
|
19
|
+
opt-in (`MLC_Z3_STATIC_ALLOW_SOURCE_BUILD=1`) to avoid accidental long Z3
|
|
20
|
+
builds when pip cannot find a matching prebuilt wheel.
|
|
21
|
+
|
|
22
|
+
## Python Helpers
|
|
23
|
+
|
|
24
|
+
Build systems can locate the packaged artifacts from Python:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import mlc_z3_static
|
|
28
|
+
|
|
29
|
+
print(mlc_z3_static.get_cmake_dir("static"))
|
|
30
|
+
print(mlc_z3_static.get_cmake_prefix_path("shared"))
|
|
31
|
+
print(mlc_z3_static.get_static_library_path())
|
|
32
|
+
print(mlc_z3_static.get_shared_library_path())
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or from a build script through the configuration CLI:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python -m mlc_z3_static.config --cmake-dir
|
|
39
|
+
python -m mlc_z3_static.config --prefix --kind shared
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Downstream CMake Usage
|
|
43
|
+
|
|
44
|
+
Install the wheel into the Python environment used by the downstream build:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m pip install mlc-z3-static==4.16.0
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Point CMake at the packaged static Z3 and use Z3's exported target:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cmake -S . -B build \
|
|
54
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
55
|
+
-DZ3_DIR="$(python -m mlc_z3_static.config --cmake-dir)"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```cmake
|
|
59
|
+
cmake_minimum_required(VERSION 3.20)
|
|
60
|
+
project(my_z3_consumer LANGUAGES C CXX)
|
|
61
|
+
|
|
62
|
+
find_package(Z3 CONFIG REQUIRED)
|
|
63
|
+
|
|
64
|
+
add_executable(my_z3_consumer main.cpp)
|
|
65
|
+
target_link_libraries(my_z3_consumer PRIVATE z3::libz3)
|
|
66
|
+
target_compile_features(my_z3_consumer PRIVATE cxx_std_20)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or resolve the directory from inside CMake:
|
|
70
|
+
|
|
71
|
+
```cmake
|
|
72
|
+
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
|
73
|
+
execute_process(
|
|
74
|
+
COMMAND "${Python3_EXECUTABLE}" -m mlc_z3_static.config --cmake-dir
|
|
75
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
76
|
+
OUTPUT_VARIABLE Z3_DIR
|
|
77
|
+
)
|
|
78
|
+
find_package(Z3 CONFIG REQUIRED)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Z3 is implemented in C++, so even C-only consumers should enable CXX in the
|
|
82
|
+
CMake project and let CMake link through a C++ linker when using the static
|
|
83
|
+
archive. Use `--kind shared` (or `get_cmake_prefix_path("shared")`) to link the
|
|
84
|
+
shared flavor instead; each flavor has its own relocatable CMake prefix. See
|
|
85
|
+
`example_project/` for a complete uv-managed consumer.
|
|
86
|
+
|
|
87
|
+
## Local Build
|
|
88
|
+
|
|
89
|
+
Build a wheel directly:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
MLC_Z3_STATIC_ALLOW_SOURCE_BUILD=1 python -m build --wheel
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use an existing Z3 checkout instead of downloading the pinned archive:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
MLC_Z3_STATIC_ALLOW_SOURCE_BUILD=1 \
|
|
99
|
+
MLC_Z3_STATIC_SOURCE_DIR=/path/to/z3 \
|
|
100
|
+
python -m build --wheel
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Build Release Wheels
|
|
104
|
+
|
|
105
|
+
From this directory:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
scripts/wheel_manylinux_2_28_v4_16_0.sh
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
scripts/wheel_macos_v4_16_0.sh
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The scripts use `uv` for host-side Python tooling, so Debian/Ubuntu system
|
|
116
|
+
Python restrictions such as PEP 668 and missing `ensurepip` do not affect the
|
|
117
|
+
host CIBW runner or post-build verifier. Both run `cibuildwheel==3.3.1`, retag
|
|
118
|
+
Linux wheels as `manylinux_2_28`, and verify each produced wheel from a clean
|
|
119
|
+
temporary virtual environment with:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
scripts/wheel_verify.sh wheelhouse/<wheel-file>.whl
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The verifier installs the wheel, configures a small CMake project against
|
|
126
|
+
`mlc_z3_static.get_cmake_prefix_path("static")`, links to `z3::libz3`, runs the
|
|
127
|
+
executable, and checks that the executable does not link against a dynamic
|
|
128
|
+
`libz3`.
|
|
129
|
+
|
|
130
|
+
The manylinux script defaults to the host architecture. Set
|
|
131
|
+
`MLC_Z3_STATIC_ARCH=x86_64` or `MLC_Z3_STATIC_ARCH=aarch64` to choose explicitly.
|
|
132
|
+
|
|
133
|
+
On macOS, local CIBW builds require an official python.org CPython installation.
|
|
134
|
+
The script defaults to the newest installed python.org CPython only as the build
|
|
135
|
+
interpreter. The output wheel is still Python-agnostic and tagged
|
|
136
|
+
`py3-none-<platform>`. Override `CIBW_BUILD` to force a specific installed build
|
|
137
|
+
interpreter, for example `CIBW_BUILD=cp313-macosx_arm64`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
project(mlc_z3_static_uv_example LANGUAGES C CXX)
|
|
3
|
+
|
|
4
|
+
find_package(Z3 CONFIG REQUIRED)
|
|
5
|
+
|
|
6
|
+
if(DEFINED MLC_Z3_STATIC_EXPECTED_PREFIX)
|
|
7
|
+
get_target_property(Z3_IMPORTED_LOCATION z3::libz3 IMPORTED_LOCATION_RELEASE)
|
|
8
|
+
if(NOT Z3_IMPORTED_LOCATION)
|
|
9
|
+
get_target_property(Z3_IMPORTED_LOCATION z3::libz3 IMPORTED_LOCATION)
|
|
10
|
+
endif()
|
|
11
|
+
if(NOT Z3_IMPORTED_LOCATION)
|
|
12
|
+
message(FATAL_ERROR "z3::libz3 does not expose an imported library location")
|
|
13
|
+
endif()
|
|
14
|
+
|
|
15
|
+
file(REAL_PATH "${Z3_IMPORTED_LOCATION}" Z3_IMPORTED_LOCATION_REAL)
|
|
16
|
+
file(REAL_PATH "${MLC_Z3_STATIC_EXPECTED_PREFIX}" MLC_Z3_STATIC_EXPECTED_PREFIX_REAL)
|
|
17
|
+
string(FIND "${Z3_IMPORTED_LOCATION_REAL}" "${MLC_Z3_STATIC_EXPECTED_PREFIX_REAL}/" Z3_PREFIX_POSITION)
|
|
18
|
+
if(NOT Z3_PREFIX_POSITION EQUAL 0)
|
|
19
|
+
message(
|
|
20
|
+
FATAL_ERROR
|
|
21
|
+
"z3::libz3 resolves outside the installed mlc-z3-static wheel prefix.\n"
|
|
22
|
+
" imported: ${Z3_IMPORTED_LOCATION_REAL}\n"
|
|
23
|
+
" expected prefix: ${MLC_Z3_STATIC_EXPECTED_PREFIX_REAL}"
|
|
24
|
+
)
|
|
25
|
+
endif()
|
|
26
|
+
endif()
|
|
27
|
+
|
|
28
|
+
add_executable(mlc_z3_static_uv_example cpp/main.cpp)
|
|
29
|
+
target_link_libraries(mlc_z3_static_uv_example PRIVATE z3::libz3)
|
|
30
|
+
target_compile_features(mlc_z3_static_uv_example PRIVATE cxx_std_20)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# mlc-z3-static uv consumer example
|
|
2
|
+
|
|
3
|
+
This is a minimal downstream project that consumes `mlc-z3-static==4.16.0`
|
|
4
|
+
with `uv`, then links a tiny C++ program against the static Z3 CMake target
|
|
5
|
+
shipped in the wheel.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
From this directory:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv sync
|
|
13
|
+
uv run python -m mlc_z3_static_example
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Build The CMake Consumer
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
scripts/link_static.sh
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The script resolves the installed Z3 static CMake prefix through the
|
|
23
|
+
configuration CLI:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
uv run python -m mlc_z3_static.config --prefix
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then it configures CMake with that prefix so `find_package(Z3 CONFIG REQUIRED)`
|
|
30
|
+
finds the wheel-provided package instead of a system Z3.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include <z3++.h>
|
|
2
|
+
|
|
3
|
+
int main() {
|
|
4
|
+
z3::context cxx_ctx;
|
|
5
|
+
z3::expr x = cxx_ctx.bool_const("x");
|
|
6
|
+
z3::solver cxx_solver(cxx_ctx);
|
|
7
|
+
cxx_solver.add(x);
|
|
8
|
+
if (cxx_solver.check() != z3::sat) {
|
|
9
|
+
return 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Z3_config cfg = Z3_mk_config();
|
|
13
|
+
Z3_context ctx = Z3_mk_context(cfg);
|
|
14
|
+
Z3_solver solver = Z3_mk_solver(ctx);
|
|
15
|
+
Z3_solver_inc_ref(ctx, solver);
|
|
16
|
+
Z3_solver_dec_ref(ctx, solver);
|
|
17
|
+
Z3_del_context(ctx);
|
|
18
|
+
Z3_del_config(cfg);
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mlc-z3-static-example-project"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"mlc-z3-static==4.16.0",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[project.optional-dependencies]
|
|
14
|
+
build = [
|
|
15
|
+
"cmake>=3.26",
|
|
16
|
+
"ninja>=1.11",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools]
|
|
20
|
+
package-dir = { "" = "src" }
|
|
21
|
+
|
|
22
|
+
[tool.setuptools.packages.find]
|
|
23
|
+
where = ["src"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
cd "${project_dir}"
|
|
6
|
+
|
|
7
|
+
: "${UV:=uv}"
|
|
8
|
+
if ! command -v "${UV}" >/dev/null 2>&1; then
|
|
9
|
+
echo "uv executable not found: ${UV}" >&2
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
"${UV}" sync --extra build
|
|
14
|
+
|
|
15
|
+
mlc_z3_static_prefix="$("${UV}" run python -m mlc_z3_static.config --prefix)"
|
|
16
|
+
|
|
17
|
+
"${UV}" run --extra build cmake -S . -B build \
|
|
18
|
+
-G Ninja \
|
|
19
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
20
|
+
-DCMAKE_PREFIX_PATH="${mlc_z3_static_prefix}" \
|
|
21
|
+
-DMLC_Z3_STATIC_EXPECTED_PREFIX="${mlc_z3_static_prefix}"
|
|
22
|
+
"${UV}" run --extra build cmake --build build --config Release
|
|
23
|
+
|
|
24
|
+
exe="build/mlc_z3_static_uv_example"
|
|
25
|
+
if [[ -x "${exe}" ]]; then
|
|
26
|
+
"${exe}"
|
|
27
|
+
else
|
|
28
|
+
"${exe}.exe"
|
|
29
|
+
fi
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Example project that consumes the mlc-z3-static wheel."""
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import mlc_z3_static
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main() -> None:
|
|
7
|
+
print(f"Z3 tag: {mlc_z3_static.Z3_TAG}")
|
|
8
|
+
print(f"Z3 commit: {mlc_z3_static.Z3_COMMIT}")
|
|
9
|
+
print(f"Static CMake prefix: {mlc_z3_static.get_cmake_prefix_path('static')}")
|
|
10
|
+
print(f"Static library: {mlc_z3_static.get_static_library_path()}")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
if __name__ == "__main__":
|
|
14
|
+
main()
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["scikit-build-core>=0.11", "cmake>=3.26", "ninja"]
|
|
3
|
+
build-backend = "scikit_build_core.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mlc-z3-static"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Prebuilt Z3 4.16.0 static and shared libraries, headers, and CMake metadata"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "MLC AI", email = "mlc.ai.dev@gmail.com" }]
|
|
14
|
+
keywords = ["z3", "smt", "static-library", "cmake"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Programming Language :: C++",
|
|
21
|
+
"Topic :: Software Development :: Build Tools",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Repository = "https://github.com/mlc-ai/package"
|
|
26
|
+
Z3 = "https://github.com/Z3Prover/z3"
|
|
27
|
+
|
|
28
|
+
[tool.scikit-build]
|
|
29
|
+
cmake.version = ">=3.26"
|
|
30
|
+
wheel.py-api = "py3"
|
|
31
|
+
wheel.packages = ["src/mlc_z3_static"]
|
|
32
|
+
sdist.exclude = [
|
|
33
|
+
"build",
|
|
34
|
+
"dist",
|
|
35
|
+
"wheelhouse",
|
|
36
|
+
"example_project/build",
|
|
37
|
+
"example_project/.venv",
|
|
38
|
+
"src/mlc_z3_static/static",
|
|
39
|
+
"src/mlc_z3_static/shared",
|
|
40
|
+
"src/mlc_z3_static/licenses",
|
|
41
|
+
"src/mlc_z3_static/staticlib.json",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[tool.scikit-build.metadata.version]
|
|
45
|
+
provider = "scikit_build_core.metadata.regex"
|
|
46
|
+
input = "src/mlc_z3_static/_version.py"
|
|
47
|
+
|
|
48
|
+
[tool.cibuildwheel]
|
|
49
|
+
# CIBW_BUILD selects the Python used to run the build. scikit-build-core tags
|
|
50
|
+
# the output wheel py3-none because this package exposes native development
|
|
51
|
+
# artifacts, not a CPython ABI extension.
|
|
52
|
+
build = "cp311-*"
|
|
53
|
+
build-frontend = "build"
|
|
54
|
+
build-verbosity = 1
|
|
55
|
+
skip = "*-musllinux_* pp*"
|
|
56
|
+
test-requires = ["cmake", "ninja"]
|
|
57
|
+
test-command = "python {project}/scripts/smoke_test_mlc_z3_static.py"
|
|
58
|
+
|
|
59
|
+
[tool.cibuildwheel.environment]
|
|
60
|
+
MLC_Z3_STATIC_ALLOW_SOURCE_BUILD = "1"
|
|
61
|
+
|
|
62
|
+
[tool.cibuildwheel.linux]
|
|
63
|
+
manylinux-x86_64-image = "manylinux_2_28"
|
|
64
|
+
manylinux-aarch64-image = "manylinux_2_28"
|
|
65
|
+
repair-wheel-command = "python scripts/copy_wheel.py {wheel} {dest_dir}"
|
|
66
|
+
|
|
67
|
+
[tool.cibuildwheel.macos]
|
|
68
|
+
repair-wheel-command = "python scripts/copy_wheel.py {wheel} {dest_dir}"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
if [[ "$#" -lt 1 || "$#" -gt 3 ]]; then
|
|
5
|
+
echo "usage: cibuildwheel_run.sh <platform> [output-dir] [package-dir]" >&2
|
|
6
|
+
exit 1
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
platform="$1"
|
|
10
|
+
output_dir="${2:-wheelhouse}"
|
|
11
|
+
package_dir="${3:-.}"
|
|
12
|
+
|
|
13
|
+
: "${UV:=uv}"
|
|
14
|
+
if ! command -v "${UV}" >/dev/null 2>&1; then
|
|
15
|
+
echo "uv executable not found: ${UV}" >&2
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
"${UV}" tool run --isolated --from "cibuildwheel==3.3.1" \
|
|
20
|
+
cibuildwheel --platform "${platform}" --output-dir "${output_dir}" "${package_dir}"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import shutil
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> None:
|
|
10
|
+
if len(sys.argv) != 3:
|
|
11
|
+
raise SystemExit("usage: copy_wheel.py <wheel> <dest-dir>")
|
|
12
|
+
wheel = Path(sys.argv[1]).resolve()
|
|
13
|
+
dest_dir = Path(sys.argv[2]).resolve()
|
|
14
|
+
dest_dir.mkdir(parents=True, exist_ok=True)
|
|
15
|
+
shutil.copy2(wheel, dest_dir / wheel.name)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if __name__ == "__main__":
|
|
19
|
+
main()
|