Ask Your Question

Modifying packages/libraries source code

asked 2020-08-25 17:17:09 +0200

anonymous user


I was looking at the source of one of the libraries (libbraiding) that Sage uses and was interested in making a few small changes and testing the result.

I have no experience with compiling/packaging such code; I was wondering whether it is easy to download the source of the Sage package, make a couple of minor changes to it and then force Sage to install/compile it? If yes, can someone please point me in the right direction?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2020-08-25 18:57:22 +0200

tmonteil gravatar image

libbraidingis a C++ library that you can fetch at so you need to know some C++ to be able to modify it.

Let me assume that you installed Sage from source (see the doc), and suggest the following easy "hacky" way.

You can see the tarball of the library as SAGE_ROOT/upstream/libbraiding-1.0.tar.gz where SAGE_ROOT is the directory where you installed Sage.

You can unpack that archive somewhere (with the command tar xvf libbraiding-1.0.tar.gz that creates a libbraiding-1.0 directory with all the source code) and start modify the code. Once you are happy, you can repack a tarball with another version : tar czvf libbraiding-2.0.tar.gz DIRECTORY where DIRECTORY is the unpacked and modified directory (it is currently named libbraiding-1.0).

Now you can put this alternative archive back into the SAGE_ROOT/upstream directory, it has the name libbraiding-2.0.tar.gz.

You should tell Sage to use that 2.0 version by modifying the file SAGE_ROOT/build/pkgs/libbraiding/package-version.txt and replace 1.0.p0 with 2.0.

Now, you have to tell Sage to recompute the hashsums of the tarball, by running the command sage --package fix-checksum. This will update the file SAGE_ROOT/build/pkgs/libbraiding/checksums.ini

Now, you can rebuild the package with the command: sage -f libbraiding

I let you guess how to go back to version 1.0p0 once you are done.

edit flag offensive delete link more

answered 2020-08-25 18:45:02 +0200

mmarco gravatar image


I am the maintainer of libbraiding. If the changes you want to make are relevant, you can try to make a pull request with them and I might merge them and release a new version.

If you just want to try some things in your machine, maybe the simplest way is to compile libbraiding with your changes with the usual cycle:

autoreconf --install

and then use the generated files in the lib/.libs directory to replace the corresponding ones in the /local/lib/ directroy of your sage installation.

edit flag offensive delete link more


If the changes you make also affect the interface of the library (that is, the name or parameters of the exposed functions), you might need to also replace the corresponding header file in the local/include directory of your sage install, and then modify the file src/sage/libs/braiding.pyxand rebuild the sage library with sage -b

mmarco gravatar imagemmarco ( 2020-08-25 18:57:42 +0200 )edit

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


Asked: 2020-08-25 17:17:09 +0200

Seen: 464 times

Last updated: Aug 25 '20