Skip to content

Commit e182fad

Browse files
committed
Use stream open option on tarfile and pipe output from subprocess directly. Restores Python 2.6 support.
1 parent 8d27f0a commit e182fad

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

setuptools_scm/git.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from .utils import do_ex, trace, has_command, _normalized
22
from .version import meta
3-
import io
43

54
from os.path import isfile, join
65
import subprocess
76
import sys
8-
from tarfile import TarFile
7+
import tarfile
98
import warnings
109

1110
FILES_COMMAND = sys.executable + ' -m setuptools_scm.git'
@@ -120,9 +119,10 @@ def parse(root, describe_command=DEFAULT_DESCRIBE, pre_parse=warn_on_shallow):
120119
def _list_files_in_archive():
121120
"""List the files that 'git archive' generates.
122121
"""
123-
# TarFile wants a seekable stream.
124-
stream = io.BytesIO(subprocess.check_output(['git', 'archive', 'HEAD']))
125-
for name in TarFile(fileobj=stream).getnames():
122+
cmd = ['git', 'archive', 'HEAD']
123+
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
124+
tf = tarfile.open(fileobj=proc.stdout, mode='r|*')
125+
for name in tf.getnames():
126126
print(name)
127127

128128

0 commit comments

Comments
 (0)