cryptominisat icon indicating copy to clipboard operation
cryptominisat copied to clipboard

pycryptosat doesn't build

Open antonio-rojas opened this issue 1 year ago • 12 comments
trafficstars

pycryptosat doesn't build in 5.11.22 as it's using API that was removed from the C++ library

python/src/pycryptosat.cpp: In function ‘PyObject* start_getting_small_clauses(Solver*, PyObject*, PyObject*)’:
python/src/pycryptosat.cpp:232:18: error: ‘class CMSat::SATSolver’ has no member named ‘start_getting_small_clauses’
  232 |     self->cmsat->start_getting_small_clauses(max_len, max_glue);
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
python/src/pycryptosat.cpp: In function ‘PyObject* get_next_small_clause(Solver*, PyObject*, PyObject*)’:
python/src/pycryptosat.cpp:250:29: error: ‘class CMSat::SATSolver’ has no member named ‘get_next_small_clause’
  250 |     bool ret = self->cmsat->get_next_small_clause(lits);
      |                             ^~~~~~~~~~~~~~~~~~~~~
python/src/pycryptosat.cpp: In function ‘PyObject* end_getting_small_clauses(Solver*, PyObject*, PyObject*)’:
python/src/pycryptosat.cpp:281:18: error: ‘class CMSat::SATSolver’ has no member named ‘end_getting_small_clauses’
  281 |     self->cmsat->end_getting_small_clauses();
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~

antonio-rojas avatar Jul 14 '24 08:07 antonio-rojas

Thanks, good point. Sorry, I was a bit under the weather. I'm fixing this now.

msoos avatar Jul 14 '24 11:07 msoos

Hi,

I have now pushed a new version to pypi:

https://pypi.org/project/pycryptosat/#files

You can check out how to build it by hand here:

https://github.com/msoos/cryptominisat/blob/master/.github/workflows/python-wheel-build.yml

I hope this resolves your issue!

Mate

msoos avatar Jul 14 '24 14:07 msoos

Actually, the built python module is wrong. I don't know how to fix this. I think I'm giving up. No more python module. Sorry.

msoos avatar Jul 14 '24 23:07 msoos

Should this be re-opened?

dimpase avatar Jan 12 '25 14:01 dimpase

Hi, this has been closed. I have no idea how to build the damned module. I can build the .so libraries, and it works on my computer. But I have no idea how to package these into a single library using pypi. I know this sounds bad. But I spent weeks, maybe even a month or two trying to do this thing and I am exhausted fighting with the build system of pypi. I can make it compile and run on my machine, but the wheel it builds only installs one of the .so files, and so all the dependencies are missing when the wheel is installed by anyone else. If you know how to fix this, please help. My understanding is that it's possible to fix via nix, but I just ran out of steam.

I hope this helps explain why I am not creating a python module,

Mate

msoos avatar Jan 12 '25 17:01 msoos

I am not asking you to spend more of your time on this, I merely ask for this to remain open - unless you really won't consider a PR which will fix this issue.

With integrated with cmake tools like pybind11, allowing one to build Python interfaces to C++ libraries, this can't be too hard to fix.

dimpase avatar Jan 12 '25 18:01 dimpase

fwiw I fixed this downstream by patching setup.py to build against the shared cryptominisat instead of building its own static copy. This should work for distro packaging, no idea about pypi

https://gitlab.archlinux.org/archlinux/packaging/packages/cryptominisat/-/blob/main/python-system-libs.patch?ref_type=heads

antonio-rojas avatar Jan 12 '25 18:01 antonio-rojas

Wow nice! Yeah, I have been doing something like what you have done in that PR as well -- tried building it shared. And that works beautifully! But it doesn't work in a system like pypi :S

Unfortunately the issue isn't binding, i.e. pybind11 won't help much I think :( The issue is linking, at least for pypi. The system works, AFAIK, if you build it locally. Reopening :)

msoos avatar Jan 12 '25 18:01 msoos

Actually, @antonio-rojas do you wanna create a PR out of that changeset? I'd merge it right in :)

msoos avatar Jan 12 '25 18:01 msoos

I don't think my patch is suitable to be merged as-is (otherwise I would have submitted a PR already) - it assumes that the library has already been built, and the path specified in library_dirs needs to match the build dir used by cmake. Ideally the shared library build should be integrated in setup.py (or the cmake build should have an option to build the python bindings) in such a way that the library build dir can be communicated properly to the python module build.

antonio-rojas avatar Jan 12 '25 19:01 antonio-rojas

Yeah, good point, building it as part of cmake would make sense. Then it would "just work". Maybe there are cmake modules that can do that.

msoos avatar Jan 12 '25 19:01 msoos

https://scikit-build-core.readthedocs.io/en/latest/ is the current recommendation for cmake-powered building of python packages. It's used by scikit, (py)zeromq, and many other very popular python projects.

dimpase avatar Jan 12 '25 22:01 dimpase