Skip to content

Commit 8b82ce6

Browse files
committed
Add extra_requires for system provided plugins
* Update test results Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent 37197c2 commit 8b82ce6

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ full =
8181
extractcode_libarchive >= 3.5.1.210525
8282
typecode[full] >= 30.0.1
8383

84+
system_provided =
85+
extractcode_7z_system_provided
86+
extractcode_libarchive_system_provided
87+
typecode_libmagic_system_provided
88+
8489
patch =
8590
patch >= 1.16
8691

src/extractcode/archive.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,26 @@
1111
import os
1212
from collections import namedtuple
1313

14-
from commoncode import fileutils
1514
from commoncode import filetype
15+
from commoncode import fileutils
1616
from commoncode import functional
1717
from commoncode.ignore import is_ignored
1818
from typecode import contenttype
1919

2020
from extractcode import all_kinds
21-
from extractcode import regular
22-
from extractcode import package
2321
from extractcode import docs
24-
from extractcode import regular_nested
2522
from extractcode import file_system
26-
from extractcode import patches
27-
from extractcode import special_package
28-
2923
from extractcode import libarchive2
24+
from extractcode import package
3025
from extractcode import patch
26+
from extractcode import patches
27+
from extractcode import regular
28+
from extractcode import regular_nested
3129
from extractcode import sevenzip
30+
from extractcode import special_package
3231
from extractcode import vmimage
33-
34-
from extractcode.uncompress import uncompress_gzip
3532
from extractcode.uncompress import uncompress_bzip2
33+
from extractcode.uncompress import uncompress_gzip
3634

3735
logger = logging.getLogger(__name__)
3836
TRACE = False
@@ -1096,7 +1094,7 @@ def try_to_extract(location, target_dir, extractor):
10961094
# note that there are v1, v2 and v3 formats.
10971095
name='QEMU QCOW2 disk image',
10981096
filetypes=('qemu qcow2 image', 'qemu qcow image',),
1099-
mimetypes=('application/octet-stream',),
1097+
mimetypes=('application/octet-stream', 'application/x-qemu-disk'),
11001098
extensions=('.qcow2', '.qcow', '.qcow2c', '.img',),
11011099
kind=file_system,
11021100
extractors=[extract_vm_image],

tests/test_archive.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@
1212
from pathlib import Path
1313

1414
import pytest
15-
1615
from commoncode import date as commoncode_date
1716
from commoncode import fileutils
1817
from commoncode.system import on_linux
1918
from commoncode.system import on_mac
2019
from commoncode.system import on_windows
2120
from commoncode.testcase import is_same
22-
2321
from extractcode_assert_utils import BaseArchiveTestCase
2422
from extractcode_assert_utils import check_files
2523
from extractcode_assert_utils import check_size
2624
from extractcode_assert_utils import to_posix
2725

2826
import extractcode
29-
from extractcode import archive
3027
from extractcode import ExtractErrorFailedToExtract
28+
from extractcode import archive
3129
from extractcode import libarchive2
3230
from extractcode import sevenzip
3331

@@ -291,9 +289,11 @@ def test_7zip_extract_can_extract_to_relative_paths(self):
291289
# The setup is a tad complex because we want to have a relative dir
292290
# to the base dir where we run tests from, i.e. the git checkout dir.
293291
# To use relative paths, we use our tmp dir at the root of the code tree
294-
from os.path import join, abspath
295-
import tempfile
296292
import shutil
293+
import tempfile
294+
from os.path import abspath
295+
from os.path import join
296+
297297
from extractcode.sevenzip import extract
298298

299299
test_file = self.get_test_loc('archive/relative_path/basic.zip', copy=True)
@@ -1649,9 +1649,11 @@ def test_extract_twice_can_extract_to_relative_paths(self):
16491649
# The setup is a tad complex because we want to have a relative dir
16501650
# to the base dir where we run tests from, i.e. the git checkout dir
16511651
# To use relative paths, we use our tmp dir at the root of the code tree
1652-
from os.path import join, abspath, exists
16531652
import shutil
16541653
import tempfile
1654+
from os.path import abspath
1655+
from os.path import exists
1656+
from os.path import join
16551657

16561658
test_file = self.get_test_loc('archive/rpm/xz-compressed-cpio.rpm')
16571659
# this will return an extractor that extracts twice
@@ -1689,8 +1691,11 @@ def test_extract_rar_with_invalid_path(self):
16891691
def test_extract_rar_with_trailing_data(self):
16901692
test_file = self.get_test_loc('archive/rar/rar_trailing.rar')
16911693
test_dir = self.get_temp_dir()
1692-
expected = Exception('Unknown error')
1693-
self.assertRaisesInstance(expected, archive.extract_rar, test_file, test_dir)
1694+
if on_mac:
1695+
archive.extract_rar(test_file, test_dir)
1696+
else:
1697+
expected = Exception('Unknown error')
1698+
self.assertRaisesInstance(expected, archive.extract_rar, test_file, test_dir)
16941699
result = os.path.join(test_dir, 'd', 'b', 'a.txt')
16951700
assert os.path.exists(result)
16961701

0 commit comments

Comments
 (0)