GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - pysmt/mathsat-cffi: CFFI Wrapper for MathSAT library

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
README.rst
README.rst
 
 
mathsat_cffi.py
mathsat_cffi.py
 
 

Repository files navigation

CFFI Interface for MathSAT 5

The file mathsat_cffi.py provides an interface based on CFFI [1] to access the MathSAT SMT Solver. This allows the use of the same "binding" across multiple versions of Python, OS's, and (most importantly) with PyPy.

This is an EXPERIMENTAL interface and will change without notice

Technical Details

The wrapper is composed of two parts. The low-level CFFI interface, and a middle-level MathSAT wrapper. This distinction is less clear in the original SWIG wrapper, that mixes the two things. For better or worse, here we are forced to consider them separately.

The method FFI.cdef (in init_lib) defines which C-level information we want to access through the CFFI interface. To generate this information, we copy-paste the API of MathSAT (mathsat.h), and remove comments. Currently, CFFI is not able to deal with non-constant MACROS. Therefore we remove those, as well as all functions talking about types that are not defined there (e.g., gmp).

The rest of the code in init_lib simply tries to find the library (.so) and open it. If this succeeds, we take the resulting FFI library and wrap it using the middle-level MathSATWrapper.

In many cases, the functions from the underlying FFI object can be called directly. In other cases, however, we need to deal with the return type of the function, and perform some simple conversions. The class MathSATWrapper takes care of these conversions.

Creating libmathsat.so

In the MathSAT distribution [2] there is no .so file. To generate it from libmathsat.a we perform the following steps:

$ mkdir libmathsat
$ ar -x ../libmathsat.a
$ gcc -shared *.o -lgmp -lgmpxx -lstdc++ -o ../libmathsat.so

For the dlopen call of CFFI to work, libmathsat.so must be either in the same directory as mathsat_cffi.py or in the LD_LIBRARY_PATH.

[1] CFFI: https://bitbucket.org/cffi/cffi/overview

[2] MathSAT 5: http://mathsat.fbk.eu/download.html

About

CFFI Wrapper for MathSAT library

Resources

Readme
Activity
Custom properties

Stars

3 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.