Message Boards Message Boards

2
|
3785 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

How to clean up after a package?

Posted 9 years ago

Some packages create temporary files they work with. How can these be cleaned up automatically on kernel exit?

Related discussions:

I am aware of a number of possible solutions, but in my opinion none of them are good enough for inclusion in a published package.

  1. Set $Epilog or write into end.m (which is auto-loaded by $Epilog's default value).

    This is not good because it is hard to play well with other packages that might also modify this symbol or this file. If packages will commonly start modifying these, there will inevitably be a conflict sooner or later.

  2. Mr.Wizard's solution from the first link above. This relies on undocumented behaviour. I am not comfortable including this in a published package. It may break for unexpected reasons or it may break in future versions. I am not generally against using certain udocumented features, but I am not feeling safe enough about relying on this particular behaviour (maybe I'm wrong though).

  3. Use LibraryLink's uninitialization. This works, but requires loading a compiled library. This is much too heavyweight for a package that does not already use LibraryLink.

Is there a robust solution that is suitable for inclusion in published packages?

Why do I believe that there has to be a good way to achieve this? Because the shared libraries that Compile creates automatically with CompilationTarget -> "C" do get cleaned up in exit. There must be a mechanism in place for this.

POSTED BY: Szabolcs Horvát

Why do I believe that there has to be a good way to achieve this? Because the shared libraries that Compile creates automatically with CompilationTarget -> "C" do get cleaned up in exit. There must be a mechanism in place for this.

I don't think there is a general mechanism, this specific example of clean up is done by the kernel itself when shutting down, via a dedicated (and not top level) function.

POSTED BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract