Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
How to preserve pip install temporary directory for error analyse?
Here I am trying to install a pip package.
While installation, pip tries to compile something.
With meson.
Meson calls cmake.
Cmake fails on a missing dependency.
Then, meson fails on the failed cmake.
Then, pip fails on the failed meson.
Then, pip deletes the temporary directory for the compilation and exits.
On this way, I can not see the meson logs, exactly what failed.
How to break this chain? I believe, pip should not deleted anything if I specify it on this way.
1 answer
Honestly I have a solution, but honestly I could not give a medal for their work to the pip devs.
-
Pip has a
--no-clean
flag. On the docs, it preserves the temporary directories for further analyse. In the reality, it preserves only some of them, and the others will be still deleted. But that is a good first try - if you have luck, you can find what you want to. -
Somewhere I have also read, pip actually has configuration files, whose pathes you can get with the command
pip config -v list
. It has a .ini syntax and there are multiple places where you can ask pip to not delete things. -
And this is what I have done. I have executed pip with hooking the deletion-related libc calls to a doing-nothing function. On this way, pip could not delete anything, note it might cause problems in the compilation, but it is also a working method. The steps are:
3.1. Create a .c file with this, for example with the name hook.c
:
int unlink(char* path) {
return 0;
}
int unlinkat(int dirfd, char* pathname, int flags) {
return 0;
}
int rmdir(char* path) {
return 0;
}
Then compile it to shared lib with the command gcc -shared -o hook.so hook.c
.
Now, if you execute any command by prefixing it with a LD_PRELOAD=/path/to/hook.so pip ....
, then it won't be able to delete anything any more. But it will think, it could. All the file or directory related libc calls will return success - but actually without doing anything.
1 comment thread