Maybe better to use something like https://docs.python.org/3/library/tarfile.html instead of calling some "outside" utilities?
This might be safer (command injection) and maybe more reliable.
However I don't know what I would have chosen and hindsight is always 20/20 and there might be other external commands and requirements...