Skip to content

Commit

Permalink
Fix downloading packages from Simplepypi (#1851)
Browse files Browse the repository at this point in the history
* fix downloading packages from simplepypi

* unused code removed

* remove unused imports
  • Loading branch information
leftys authored Jan 31, 2020
1 parent 4687ef8 commit d331535
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions poetry/utils/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import tarfile
import zipfile

from bz2 import BZ2File
from gzip import GzipFile
from typing import Dict
from typing import List
from typing import Union
Expand Down Expand Up @@ -114,27 +112,21 @@ def inspect_sdist(
# Still not dependencies found
# So, we unpack and introspect
suffix = file_path.suffix
gz = None
if suffix == ".zip":
tar = zipfile.ZipFile(str(file_path))
else:
if suffix == ".bz2":
gz = BZ2File(str(file_path))
suffixes = file_path.suffixes
if len(suffixes) > 1 and suffixes[-2] == ".tar":
suffix = ".tar.bz2"
else:
gz = GzipFile(str(file_path))
suffix = ".tar.gz"

tar = tarfile.TarFile(str(file_path), fileobj=gz)
tar = tarfile.open(str(file_path))

try:
tar.extractall(os.path.join(str(file_path.parent), "unpacked"))
finally:
if gz:
gz.close()

tar.close()

unpacked = file_path.parent / "unpacked"
Expand Down

0 comments on commit d331535

Please sign in to comment.