當我產生使用tar cfz cl.tar.gz Sources
相比蟒蛇shutil.make_archive ("py", "gztar", "Sources")
爲tar.gz文件,我得到不同的結果:命令行tar和shutil.make_archive之間的區別?
$ tar -tf cl.tar.gz | head -3
algorithm/
aligned_storage.hpp
algorithm/cxx11/
$ tar -tf py.tar.gz | head -3
./algorithm/
./aligned_storage.hpp
./algorithm/cxx11/
這其中大部分都沒有區別的時間;但如果您在解除阻塞時通過--strip-components
,那麼這兩個檔案的行爲會有所不同。
我真的很想從我從shell腳本中得到的python代碼中獲得相同的結構,但我不太清楚該怎麼做。我在Mac OS 10.8.1上使用Python 2.7.3,如果這有所作爲。
在Ubuntu上,我得到了兩種方法的相同格式(即用'。/')。你究竟如何創建tarball? – Hamish