Skip to content

Commit 0cdf006

Browse files
committed
Do not install patch.py by default
It has deprecated regexes and needs some love to maintain Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent ad47ed2 commit 0cdf006

File tree

7 files changed

+26
-8
lines changed

7 files changed

+26
-8
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
Changelog
22
=========
33

4-
v30.0.0 (next)
4+
v31.0.0
5+
--------
6+
7+
- Do not install patch.py by default. Instead this is now an extra
8+
9+
10+
v30.0.0
511
--------
612

713
- Update to the latest skeleton. The virtualenv is now created under the venv

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CLI_ARGS=$1
2929

3030
# Requirement arguments passed to pip and used by default or with --dev.
3131
REQUIREMENTS="--editable .[full] --constraint requirements.txt"
32-
DEV_REQUIREMENTS="--editable .[full,testing] --constraint requirements.txt --constraint requirements-dev.txt"
32+
DEV_REQUIREMENTS="--editable .[full,testing,patch] --constraint requirements.txt --constraint requirements-dev.txt"
3333
DOCS_REQUIREMENTS="--editable .[docs] --constraint requirements.txt"
3434

3535
# where we create a virtualenv

configure.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
@rem # Requirement arguments passed to pip and used by default or with --dev.
2929
set "REQUIREMENTS=--editable .[full] --constraint requirements.txt"
30-
set "DEV_REQUIREMENTS=--editable .[full,testing] --constraint requirements.txt --constraint requirements-dev.txt"
30+
set "DEV_REQUIREMENTS=--editable .[full,testing,patch] --constraint requirements.txt --constraint requirements-dev.txt"
3131
set "DOCS_REQUIREMENTS=--editable .[docs] --constraint requirements.txt"
3232

3333
@rem # where we create a virtualenv

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ install_requires =
7070
commoncode >= 21.5.25
7171
plugincode >= 21.1.21
7272
typecode >= 21.6.1
73-
patch >= 1.16
74-
7573

7674

7775
[options.packages.find]
@@ -84,6 +82,9 @@ full =
8482
extractcode_libarchive >= 3.5.1.210525
8583
typecode[full] >= 21.6.1
8684

85+
patch =
86+
patch >= 1.16
87+
8788
testing =
8889
pytest >= 6, != 7.0.0
8990
pytest-xdist >= 2

src/extractcode/archive.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,5 +1194,11 @@ def try_to_extract(location, target_dir, extractor):
11941194
QCOWHandler,
11951195
VMDKHandler,
11961196
VirtualBoxHandler,
1197-
PatchHandler,
11981197
]
1198+
1199+
# only support extracting patches if patch is installed. This is not a default
1200+
try:
1201+
import patch as _pythonpatch
1202+
archive_handlers.append(PatchHandler)
1203+
except:
1204+
pass

src/extractcode/patch.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import logging
1212
import os.path
1313

14-
import patch as pythonpatch
15-
1614
from commoncode import paths
1715
from commoncode import fileutils
1816
from commoncode import text
@@ -136,6 +134,7 @@ def patch_info(location):
136134
137135
Raise an exception if the file is not a patch file or cannot be parsed.
138136
"""
137+
import patch as pythonpatch
139138
patchset = pythonpatch.fromfile(location)
140139
if not patchset:
141140
msg = 'Unable to parse patch file: %(location)s' % locals()

tests/test_patch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
from extractcode import patch
1919

20+
try:
21+
import patch as _pythonpatch
22+
except ImportError:
23+
import pytest
24+
pytestmark = pytest.mark.skipif(True, reason="Run only if patch is installed.")
25+
2026

2127
class TestIsPatch(FileBasedTesting):
2228
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

0 commit comments

Comments
 (0)