Ask Your Question
1

How to contribute C++ binaries to SAGE

asked 2024-10-04 09:43:51 +0100

Mathieu Dutour Sikiric gravatar image

I have written several programs in C++ for algebraic computation. I think it would be nice for SAGE users to have access to them. Of course, that means writing the binding code, but that should not be an issue.

I have looked around at existing Python packaging systems and the two prominent ones are pip and conda (poetry seems used by some but does not seem great anyway):

  • pip seems fine but it has a limit of 60M on the total size. The problem is that the compilation can be long and I would like to submit the šackage as wheel, that is precompiled binaries. And each precompiled binary is about 20M.

  • Conda has a tendency to force you to use conda for everything.

The C++ code is available at https://github.com/MathieuDutSik/poly... (Academic references for the algorithm being implemented are available https://mathieudutsik.github.io/Publi...) There are many functions, but the ones that could be of interest for SAGE users:

  • Canonical form of positive definite matrices.

  • Dual description of polytopes using symmetries

  • Copositive programming

  • Isotropic vectors of rational quadratic forms.

  • Computation of Delaunay polytopes of a lattice.

  • Test of equivalence (with an explicit one if existing) and computation of automorphism group of indefinite rational quadratic forms.

The dependencies of the code are:

  • Boost and Eigen.

  • Nauty. Is Nauty an issue for SAGE? This is not completely open source. If a problem, I can use the bliss software which is less performant but fully open source.

I am using Makefile now, but I can easily create a CMakeLists.txt to provide a compilation environment (Dimitri Pasechnik mentioned this). The compilation takes about 40 minutes to compile the whole software.

Please let me know what is the path forward for the inclusion of the software in SAGE.

PS: I asked last year about that very question, but I was not yet ready and some problems can take a long time to resolve.

edit retag flag offensive close merge delete

Comments

This question is better to ask in sage-devel

Max Alekseyev gravatar imageMax Alekseyev ( 2024-10-04 17:18:46 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2024-10-04 21:50:47 +0100

vdelecroix gravatar image

I would like to answer two questions rather than one. Namely

  1. how to interface your C++ code with SageMath or Python
  2. how to distribute your C++ library (so that SageMath users can easily benefit from it)

interface: writing a Python interface to a C++ library can be done in several ways. I know of at least

Each one of these tools has its pros and cons. The interface needs not be written in sage source code itself and can easily be a standalone library. The three examples above are of this kind.

distribution: the first step in having people try your C++ library (and possibly a Python interface) is to have releases of your source code. This comes with versioning, API/ABI compatibilities between versions, ... One way out of the box is to use some automatized tools such as GNU autoconf, GNU automake or alternatively cmake. Though not all softwares use it, eg PARI/GP has a home-made build script.

Once you have proper and official releases of your libraries, you can ask yourself how to make this library available in a binary form (for conda, for linux distributions, for homebrew, etc). Each system has its own way of compiling and distributing packages. If your library is popular enough, you will easily find help to make packages available but this is a question towards them rather than sage developers.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-10-04 09:43:51 +0100

Seen: 226 times

Last updated: Oct 04