Skip to content

Add extra_requires for system provided plugins #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
35 changes: 35 additions & 0 deletions .github/workflows/test-ci-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test CI Mac

on: [push, pull_request]

jobs:
build:
runs-on: macos-latest

strategy:
max-parallel: 4
matrix:
python-version: ["3.10", "3.11"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
brew update
brew install p7zip libarchive libmagic

- name: Set up venv
run: |
python3 -m venv venv
source venv/bin/activate
pip install -e .[system_provided,testing]

- name: Run tests
run: venv/bin/pytest -n 3 -vvs .
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ chardet==5.0.0
charset-normalizer==2.1.0
click==8.1.3
colorama==0.4.5
commoncode==31.0.2
commoncode==31.2.1
construct==2.10.68
container-inspector==31.1.0
cryptography==37.0.4
Expand Down
7 changes: 6 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ python_requires = >=3.7
install_requires =
attrs >= 18.1,!=20.1.0;python_version<'3.11'
attrs >= 22.1.0;python_version>='3.11'
commoncode >= 31.0.2
commoncode >= 31.2.1
plugincode >= 32.0.0
typecode >= 30.0.1

Expand All @@ -81,6 +81,11 @@ full =
extractcode_libarchive >= 3.5.1.210525
typecode[full] >= 30.0.1

system_provided =
extractcode_7z_system_provided >= 32.0.0
extractcode_libarchive_system_provided >= 32.0.0
typecode_libmagic_system_provided >= 32.0.0

patch =
patch >= 1.16

Expand Down
18 changes: 8 additions & 10 deletions src/extractcode/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,26 @@
import os
from collections import namedtuple

from commoncode import fileutils
from commoncode import filetype
from commoncode import fileutils
from commoncode import functional
from commoncode.ignore import is_ignored
from typecode import contenttype

from extractcode import all_kinds
from extractcode import regular
from extractcode import package
from extractcode import docs
from extractcode import regular_nested
from extractcode import file_system
from extractcode import patches
from extractcode import special_package

from extractcode import libarchive2
from extractcode import package
from extractcode import patch
from extractcode import patches
from extractcode import regular
from extractcode import regular_nested
from extractcode import sevenzip
from extractcode import special_package
from extractcode import vmimage

from extractcode.uncompress import uncompress_gzip
from extractcode.uncompress import uncompress_bzip2
from extractcode.uncompress import uncompress_gzip

logger = logging.getLogger(__name__)
TRACE = False
Expand Down Expand Up @@ -1096,7 +1094,7 @@ def try_to_extract(location, target_dir, extractor):
# note that there are v1, v2 and v3 formats.
name='QEMU QCOW2 disk image',
filetypes=('qemu qcow2 image', 'qemu qcow image',),
mimetypes=('application/octet-stream',),
mimetypes=('application/octet-stream', 'application/x-qemu-disk'),
extensions=('.qcow2', '.qcow', '.qcow2c', '.img',),
kind=file_system,
extractors=[extract_vm_image],
Expand Down
1,444 changes: 722 additions & 722 deletions tests/data/patch/patches/windows/plugin explorer.patch.expected

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions tests/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@
from pathlib import Path

import pytest

from commoncode import date as commoncode_date
from commoncode import fileutils
from commoncode.system import on_linux
from commoncode.system import on_mac
from commoncode.system import on_macos_arm64
from commoncode.system import on_windows
from commoncode.testcase import is_same

from extractcode_assert_utils import BaseArchiveTestCase
from extractcode_assert_utils import check_files
from extractcode_assert_utils import check_size
from extractcode_assert_utils import to_posix

import extractcode
from extractcode import archive
from extractcode import ExtractErrorFailedToExtract
from extractcode import archive
from extractcode import libarchive2
from extractcode import sevenzip

Expand Down Expand Up @@ -291,9 +290,11 @@ def test_7zip_extract_can_extract_to_relative_paths(self):
# The setup is a tad complex because we want to have a relative dir
# to the base dir where we run tests from, i.e. the git checkout dir.
# To use relative paths, we use our tmp dir at the root of the code tree
from os.path import join, abspath
import tempfile
import shutil
import tempfile
from os.path import abspath
from os.path import join

from extractcode.sevenzip import extract

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

test_file = self.get_test_loc('archive/rpm/xz-compressed-cpio.rpm')
# this will return an extractor that extracts twice
Expand Down Expand Up @@ -1689,8 +1692,11 @@ def test_extract_rar_with_invalid_path(self):
def test_extract_rar_with_trailing_data(self):
test_file = self.get_test_loc('archive/rar/rar_trailing.rar')
test_dir = self.get_temp_dir()
expected = Exception('Unknown error')
self.assertRaisesInstance(expected, archive.extract_rar, test_file, test_dir)
if on_macos_arm64:
archive.extract_rar(test_file, test_dir)
else:
expected = Exception('Unknown error')
self.assertRaisesInstance(expected, archive.extract_rar, test_file, test_dir)
result = os.path.join(test_dir, 'd', 'b', 'a.txt')
assert os.path.exists(result)

Expand Down
3 changes: 2 additions & 1 deletion tests/test_vmimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
import pytest

from commoncode.system import on_linux
from commoncode.system import on_ubuntu_22

from extractcode_assert_utils import BaseArchiveTestCase
from extractcode_assert_utils import check_files

from extractcode import vmimage


@pytest.mark.skipif(not on_linux, reason='Only linux supports image extraction')
@pytest.mark.skipif((not on_linux) or on_ubuntu_22, reason='Only linux supports image extraction, kernel is unreadable on Ubuntu 22.04')
class TestExtractVmImage(BaseArchiveTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

Expand Down
Loading