You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that we support a "strip=1" feature so that one does not need to go "cd zlib-1.2.3" after extraction. To support this, the code would likely look something like this (this seems to be OK looking briefly at Python/Lib/tarfile.py):
def remove_prefix(tarinfo):
tarinfo.path = pjoin(os.path.split(tarinfo.path)[strip:]) # but raise error if there are fewer components
tar = tarfile.open("sample.tar.gz")
tar.extractall(members=(remove_prefix(tarinfo) for tarinfo in tar))
tar.close()
Note: in test_source_cache.py, make_mock_archive/make_temporary_tarball should be modified to put items into a sub-directory to test the strip feature.
The text was updated successfully, but these errors were encountered:
Currently GNU tar with the --strip-components option is needed, it would be better to use the builtin tarfile module.
There's prior art in "distlib" (in util.py) for supporting extraction of different extraction schemes:
https://bitbucket.org/vinay.sajip/distlib/src/393ccd9db71b2c77ed3973fc33bd5d28b090174b/distlib/util.py?at=default
Note that we support a "strip=1" feature so that one does not need to go "cd zlib-1.2.3" after extraction. To support this, the code would likely look something like this (this seems to be OK looking briefly at Python/Lib/tarfile.py):
Note: in test_source_cache.py, make_mock_archive/make_temporary_tarball should be modified to put items into a sub-directory to test the strip feature.
The text was updated successfully, but these errors were encountered: