temp dir
comtihon opened this issue · 5 comments
hi!
It will be very useful (at least for me), if there would be user_temp_dir
or system_temp_dir
.
Are there any plans to add one?
Thanks!
Hi Comithon,
I'm not really clear on how we could set the proper defaults particularly on linx/Mac. For example on linux /tmp and /var/tmp are recommended for inter-process communications, not for temp files in general. We could use the user_data_dir potentially? Not really sure of all the implications here.
Windows is straight forward though. I'd have to look into macOS.
I'd love to hear some opinions on this for the various platforms before I code it up.
Hi,
From my point of view - system_temp_dir
should use ``something like /tmp
on linux/mac. I don't know if same directory exists in Windows.
And `user_temp_dir` should rely on user_data_dir.
According to the Linux FHS, /tmp and /var/tmp would both be appropriate. /tmp is available "for programs that require temporary files" and /var/tmp/ is the same for files that are expected to survive a reboot.
macOS shares the same definitions (according to man hier
) with /tmp defined simply as "temporary files" and /var/tmp defined as 'temporary files that are kept between system reboots."
I would expect in both cases for code to honor the contents of the TMP or TEMP environment variable first (if that exists) and fall back on /tmp or /var/tmp secondarily. For user temp directory in macOS the contents of TMPDIR should be used, which is dynamically generated by the OS as a secure location only accessible by the current user.
Isn't this in most cases already solved by tempfile
from the standard library?
https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir
Already supported by standard library in python 2 and 3.