How can I correctly rebuild a Python library with C/CFFI components?

32 Views Asked by At

I am trying to work on a branch of a popular repository, which I link here: https://github.com/whatf0xx/pycryptodome/tree/undigest

As you can see, I have made 3 small commits so far, adding a C function that just returns an int, and the Python wrapper to let me call it.

In a separate folder, I created a venv so I could test some stuff out, and then in that venv I run

pip install -e /path/to/the/forked/local/repo.

Initially, this then works correctly, and I can import the library and run the functions, and I get the result I expect. However, if I at this point go into the library (the fork off of pycryptodome) and update the C function (to return 1 instead of 0, for example), that change is never reflected in the testing venv.

I tried pip uninstall and then adding the repo again, but this doesn't help. The only thing that seems to work is if I totally uninstall the repo from my computer, and then pulling it down in the updated state from GitHub does cause the repo to rebuild correctly, and I see the 'new' behaviour implemented.

I'm not sure if this is a problem with the way I am managing the packages with pip. My suspicion is that the C files are getting cached once they are compiled, and this cache is never updated when I call

pip install -e /path/to/the/forked/local/repo

a second time, so that's why the C function's behaviour is't updated.

I'm really not sure what to attach here to make the problem any clearer, so please let me know what I can show you to help solve this problem. I kind of suspect it's something obvious, because this seems like a pretty normal use case for developing a Python library with CFFI C functions speeding things up. Thanks!

0

There are 0 best solutions below