2021-12-07 20:16:03 -08:00
Python API
2024-07-12 09:16:47 -07:00
==========
2021-04-27 15:29:19 +02:00
2021-05-04 18:33:59 +02:00
.. only :: not bindings_python
.. warning ::
This documentation was built while python bindings were disabled. This part of the documentation is likely either empty or outdated. Please enable :code: `BUILD_BINDINGS_PYTHON` in :code: `cmake` and build the documentation again.
2021-11-17 11:40:49 -08:00
cvc5 offers two separate APIs for Python users.
2024-07-12 09:17:06 -07:00
The :doc: `base Python API <base/python>` is an almost exact copy of the
:doc: `C++ API <../cpp/cpp>` .
Alternatively, the :doc: `pythonic API <pythonic/pythonic>` is a more pythonic
API that aims to be fully compatible with `Z3s Python API
<https://z3prover.github.io/api/html/namespacez3py.html> `_ while adding
functionality that Z3 does not support.
2021-12-07 20:16:03 -08:00
.. toctree ::
:maxdepth: 1
2022-01-14 13:45:19 -08:00
pythonic/pythonic
base/python
2021-04-27 15:29:19 +02:00
2021-11-17 11:40:49 -08:00
Which Python API should I use?
------------------------------
2024-07-12 09:17:06 -07:00
If you are a new user, or already have an application that uses Z3's python
API, use the :doc: `pythonic API <pythonic/pythonic>` .
If you would like a more feature-complete---yet verbose---python API, with the
ability to do almost everything that the cpp API allows, use the :doc:`base
Python API <base/python>`.
2022-01-14 13:45:19 -08:00
2024-07-12 09:17:06 -07:00
You can compare examples using the two APIs by visiting the :doc:`examples page
<../../examples/quickstart> `.
2022-04-01 19:26:33 -07:00
2024-07-08 19:29:10 +02:00
Installation (from PyPi)
2024-07-12 09:16:47 -07:00
------------------------
2022-04-01 19:26:33 -07:00
The base and pythonic Python API can be installed via `pip` as follows:
.. code :: bash
pip install cvc5
2022-10-13 18:32:49 +03:00
2024-07-08 19:29:10 +02:00
Installation (from source)
2024-07-12 09:16:47 -07:00
--------------------------
2022-10-13 18:32:49 +03:00
2024-07-12 09:17:06 -07:00
The base and pythonic Python API can also be installed from source following
these steps:
2023-03-08 04:14:28 +02:00
.. code :: bash
2024-07-08 19:29:10 +02:00
git clone https://github.com/cvc5/cvc5.git
2022-10-13 18:32:49 +03:00
cd cvc5
./configure.sh --python-bindings --auto-download
cd build
2024-07-08 19:29:10 +02:00
make # add -jN for parallel build using N threads
make install
2024-07-17 08:55:07 +02:00
The last step installs both the cvc5 binary and the Python bindings.
If you want to install only the Python bindings, run the following
command instead of `` make install `` :
2022-10-13 18:32:49 +03:00
2024-07-17 08:55:07 +02:00
.. code :: bash
cmake --install . --component python-api
2025-09-10 10:44:59 -05:00
For Windows, the steps above must be executed in
2025-12-08 18:18:23 -06:00
a CLANG64 or CLANGARM64 environment with the required
2025-09-10 10:44:59 -05:00
dependencies installed
2024-07-17 08:55:07 +02:00
(see the :doc: `installation instructions <../../installation/installation>` ).
Finally, you can make sure that it works by running:
2022-10-13 18:32:49 +03:00
.. code :: bash
python3
import cvc5