From 16193abc2e657522cf4274d47a661576b2ce9e35 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 13 Aug 2016 14:01:24 +0300 Subject: [PATCH 01/19] other/pack.py: Also allow ' as version string quote --- other/pack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/other/pack.py b/other/pack.py index 8ed523e..d4a5bd9 100755 --- a/other/pack.py +++ b/other/pack.py @@ -15,7 +15,8 @@ def get_version(path): line = line.decode('cp437') if '__version__' in line: # __version__ = "0.9" - return line.split('"')[1] + delim = '\"' if '\"' in line else '\'' + return line.split(delim)[1] def zipadd(archive, filename, newname): '''Add filename to archive. `newname` is required. Otherwise From 2f2cd97321cce63bea04b499c1f474a6b6d1d115 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 13 Aug 2016 15:33:07 +0300 Subject: [PATCH 02/19] other/pack: Move __main__.py template to inside pack.py --- other/pack.mainpy.tpl | 4 ---- other/pack.py | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 other/pack.mainpy.tpl diff --git a/other/pack.mainpy.tpl b/other/pack.mainpy.tpl deleted file mode 100644 index fa4b7a0..0000000 --- a/other/pack.mainpy.tpl +++ /dev/null @@ -1,4 +0,0 @@ -import sys - -import {{ module }} -sys.exit({{ module }}.main()) diff --git a/other/pack.py b/other/pack.py index d4a5bd9..5165f1f 100755 --- a/other/pack.py +++ b/other/pack.py @@ -40,24 +40,34 @@ def __init__(self, templates='.'): self.path = templates + '/' self.tag = re.compile('{{ *(?P\w+) *}}') - def render(self, template, vardict=None, **kwargs): + def render(self, tplfile, vardict=None, **kwargs): """returns unicode str""" + tpltext = open(self.path + tplfile).read() + return self.render_string(tpltext, vardict, **kwargs) + + def render_string(self, tpltext, vardict=None, **kwargs): data = vardict or {} data.update(kwargs) def lookup(match): return data[match.group('tag')] - tpl = open(self.path + template).read() if not self.PY3K: - return unicode(self.tag.sub(lookup, tpl)) + return unicode(self.tag.sub(lookup, tpltext)) else: - return self.tag.sub(lookup, tpl) + return self.tag.sub(lookup, tpltext) # --- BASE = os.path.abspath(os.path.dirname(__file__)) +MAINTPL = """\ +import sys + +import {{ module }} +sys.exit({{ module }}.main()) +""" + if __name__ == '__main__': if not sys.argv[1:]: sys.exit("usage: pack.py ") @@ -74,7 +84,7 @@ def lookup(match): zf = zipadd(packname, modpath, os.path.basename(modpath)) print("[*] Making %s executable" % (packname)) # http://techtonik.rainforce.org/2015/01/shipping-python-tools-in-executable-zip.html - text = MiniJinja(BASE).render('pack.mainpy.tpl', module=modname) + text = MiniJinja(BASE).render_string(MAINTPL, module=modname) zf.writestr('__main__.py', text) print("[*] Making %s installable" % (packname)) text2 = MiniJinja(BASE).render('pack.setuppy.tpl', module=modname, version=version) From 78c233ad9c79abd2916b98bd79176f674cf4c415 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 13 Aug 2016 17:12:02 +0300 Subject: [PATCH 03/19] other/README.md: Add instruction on how to use pack.py --- other/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 other/README.md diff --git a/other/README.md b/other/README.md new file mode 100644 index 0000000..d6f9a51 --- /dev/null +++ b/other/README.md @@ -0,0 +1 @@ +See ../doc/RELEASING for pack.py instructions. \ No newline at end of file From bf7d4d3422b0e6a35a58f849e45974314afb38f9 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 13 Aug 2016 17:15:28 +0300 Subject: [PATCH 04/19] other/pack.py: It is a package, not just .zip file --- other/pack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/pack.py b/other/pack.py index 5165f1f..2162bce 100755 --- a/other/pack.py +++ b/other/pack.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Wrap Python module into executable .zip file +Wrap Python module into executable .zip package Public domain work by: anatoly techtonik From 823350b07a723ae1d850b89dbd44d0f7bac4f543 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 13 Aug 2016 22:03:15 +0300 Subject: [PATCH 05/19] other/pack: Read __author__ field from given module --- other/pack.py | 35 +++++++++++++++++++++++++---------- other/pack.setuppy.tpl | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/other/pack.py b/other/pack.py index 2162bce..cdf4585 100755 --- a/other/pack.py +++ b/other/pack.py @@ -1,6 +1,15 @@ #!/usr/bin/env python """ -Wrap Python module into executable .zip package +Wrap Python module into executable .zip package. + +Extracts required meta-data (author|maintainer, name, version, +url) and optional fields (description) from module without +importing it. + + * [x] name, version + * [x] author + * [ ] url + * [ ] description (first line of module docstring) Public domain work by: anatoly techtonik @@ -8,12 +17,12 @@ import os import sys -def get_version(path): - '''Read version info from a file without importing it''' +def get_field(path, name='__version__'): + '''Read named string from module without importing it''' for line in open(path, 'rb'): # Decode to unicode for PY2/PY3 in a fail-safe way line = line.decode('cp437') - if '__version__' in line: + if name in line: # __version__ = "0.9" delim = '\"' if '\"' in line else '\'' return line.split(delim)[1] @@ -73,21 +82,27 @@ def lookup(match): sys.exit("usage: pack.py ") modpath = sys.argv[1] - modname = os.path.basename(modpath)[:-3] # also strip extension - version = get_version(modpath) - if version == None: + tplvars = dict( + module = os.path.basename(modpath)[:-3], # also strip extension + version = get_field(modpath, '__version__'), + author = get_field(modpath, '__author__') + ) + + if tplvars['version'] == None: sys.exit("error: no __version__ specifier found in %s" % modpath) - packname = modname + "-" + version + ".zip" + if tplvars['author'] == None: + sys.exit("error: no __author__ specifier found in %s" % modpath) + packname = tplvars['module'] + "-" + tplvars['version'] + ".zip" print("[*] Packing %s into %s" % (modpath, packname)) if os.path.exists(packname): os.remove(packname) zf = zipadd(packname, modpath, os.path.basename(modpath)) print("[*] Making %s executable" % (packname)) # http://techtonik.rainforce.org/2015/01/shipping-python-tools-in-executable-zip.html - text = MiniJinja(BASE).render_string(MAINTPL, module=modname) + text = MiniJinja(BASE).render_string(MAINTPL, **tplvars) zf.writestr('__main__.py', text) print("[*] Making %s installable" % (packname)) - text2 = MiniJinja(BASE).render('pack.setuppy.tpl', module=modname, version=version) + text2 = MiniJinja(BASE).render('pack.setuppy.tpl', **tplvars) zf.writestr('setup.py', text2) print("[*] Making %s uploadable to PyPI" % (packname)) zf.writestr('PKG-INFO', '') diff --git a/other/pack.setuppy.tpl b/other/pack.setuppy.tpl index b82c24d..37f2efa 100644 --- a/other/pack.setuppy.tpl +++ b/other/pack.setuppy.tpl @@ -3,7 +3,7 @@ from distutils.core import setup setup( name='{{ module }}', version='{{ version }}', - author='anatoly techtonik ', + author='{{ author }}', url='https://github.com/techtonik/python-patch/', description='Patch utility to apply unified diffs', From d855b0c1f72507396209ebacac06d7d9d140708b Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 13 Aug 2016 22:40:59 +0300 Subject: [PATCH 06/19] other/pack: Read license info from module --- other/pack.py | 4 +++- other/pack.setuppy.tpl | 2 +- patch.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/other/pack.py b/other/pack.py index cdf4585..63688ba 100755 --- a/other/pack.py +++ b/other/pack.py @@ -8,6 +8,7 @@ * [x] name, version * [x] author + * [x] license * [ ] url * [ ] description (first line of module docstring) @@ -85,7 +86,8 @@ def lookup(match): tplvars = dict( module = os.path.basename(modpath)[:-3], # also strip extension version = get_field(modpath, '__version__'), - author = get_field(modpath, '__author__') + author = get_field(modpath, '__author__'), + license = get_field(modpath, '__license__') ) if tplvars['version'] == None: diff --git a/other/pack.setuppy.tpl b/other/pack.setuppy.tpl index 37f2efa..9501916 100644 --- a/other/pack.setuppy.tpl +++ b/other/pack.setuppy.tpl @@ -7,7 +7,7 @@ setup( url='https://github.com/techtonik/python-patch/', description='Patch utility to apply unified diffs', - license='MIT', + license='{{ license }}', py_modules=['{{ module }}'], diff --git a/patch.py b/patch.py index 45c5a48..b515dcc 100755 --- a/patch.py +++ b/patch.py @@ -14,6 +14,7 @@ __author__ = "anatoly techtonik " __version__ = "1.16" +__license__ = "MIT" import copy import logging From ada3bfd74049ef1614c980f4050b026695f16c2f Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 14 Aug 2016 10:03:49 +0300 Subject: [PATCH 07/19] other/pack: Read description from module --- other/pack.py | 17 ++++++++++++++++- other/pack.setuppy.tpl | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/other/pack.py b/other/pack.py index 63688ba..ce5cc48 100755 --- a/other/pack.py +++ b/other/pack.py @@ -28,6 +28,20 @@ def get_field(path, name='__version__'): delim = '\"' if '\"' in line else '\'' return line.split(delim)[1] +def get_description(path): + '''Return first non-empty line from module docstring''' + mf = open(path, 'rb') + for i, line in enumerate(mf): + if i > 10: + # stop looking after 10 lines + break + line = line.decode('utf-8').strip() + if '"""' in line or "'''" in line: + while line.strip('\n\t\r \'\"') == '': + line = mf.next() + line = line.decode('utf-8').strip() + return line + def zipadd(archive, filename, newname): '''Add filename to archive. `newname` is required. Otherwise zipfile may create unsafe entries, such as "../patch.py". @@ -87,7 +101,8 @@ def lookup(match): module = os.path.basename(modpath)[:-3], # also strip extension version = get_field(modpath, '__version__'), author = get_field(modpath, '__author__'), - license = get_field(modpath, '__license__') + license = get_field(modpath, '__license__'), + description = get_description(modpath) ) if tplvars['version'] == None: diff --git a/other/pack.setuppy.tpl b/other/pack.setuppy.tpl index 9501916..f4e9694 100644 --- a/other/pack.setuppy.tpl +++ b/other/pack.setuppy.tpl @@ -6,7 +6,7 @@ setup( author='{{ author }}', url='https://github.com/techtonik/python-patch/', - description='Patch utility to apply unified diffs', + description='{{ description }}', license='{{ license }}', py_modules=['{{ module }}'], From a40d7a2226c02b6da1fb8394a714848814454b65 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 14 Aug 2016 10:06:38 +0300 Subject: [PATCH 08/19] other/pack: Read package URL from module --- other/pack.py | 1 + other/pack.setuppy.tpl | 2 +- patch.py | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/other/pack.py b/other/pack.py index ce5cc48..249f7dd 100755 --- a/other/pack.py +++ b/other/pack.py @@ -102,6 +102,7 @@ def lookup(match): version = get_field(modpath, '__version__'), author = get_field(modpath, '__author__'), license = get_field(modpath, '__license__'), + url = get_field(modpath, '__url__'), description = get_description(modpath) ) diff --git a/other/pack.setuppy.tpl b/other/pack.setuppy.tpl index f4e9694..e04a8db 100644 --- a/other/pack.setuppy.tpl +++ b/other/pack.setuppy.tpl @@ -4,7 +4,7 @@ setup( name='{{ module }}', version='{{ version }}', author='{{ author }}', - url='https://github.com/techtonik/python-patch/', + url='{{ url }}', description='{{ description }}', license='{{ license }}', diff --git a/patch.py b/patch.py index b515dcc..4b82af0 100755 --- a/patch.py +++ b/patch.py @@ -7,14 +7,13 @@ Copyright (c) 2008-2016 anatoly techtonik Available under the terms of MIT license - https://github.com/techtonik/python-patch/ - """ from __future__ import print_function __author__ = "anatoly techtonik " __version__ = "1.16" __license__ = "MIT" +__url__ = "https://github.com/techtonik/python-patch" import copy import logging From 3181d3a8c3f08a49c2bcaaa21bb7a02d44edb28b Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 14 Aug 2016 11:22:21 +0300 Subject: [PATCH 09/19] other/pack: Python 3 compatibility --- other/pack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/pack.py b/other/pack.py index 249f7dd..f94efb4 100755 --- a/other/pack.py +++ b/other/pack.py @@ -38,7 +38,7 @@ def get_description(path): line = line.decode('utf-8').strip() if '"""' in line or "'''" in line: while line.strip('\n\t\r \'\"') == '': - line = mf.next() + line = next(mf) line = line.decode('utf-8').strip() return line From d91e495583e22c8c6e241527f259919a4117ba51 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 14 Aug 2016 11:24:37 +0300 Subject: [PATCH 10/19] other/pack: Move pack.setuppy.tpl into pack.py --- other/pack.py | 27 ++++++++++++++++++++++++--- other/pack.setuppy.tpl | 18 ------------------ 2 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 other/pack.setuppy.tpl diff --git a/other/pack.py b/other/pack.py index f94efb4..d5abd70 100755 --- a/other/pack.py +++ b/other/pack.py @@ -9,8 +9,8 @@ * [x] name, version * [x] author * [x] license - * [ ] url - * [ ] description (first line of module docstring) + * [x] url + * [x] description (first line of module docstring) Public domain work by: anatoly techtonik @@ -92,6 +92,27 @@ def lookup(match): sys.exit({{ module }}.main()) """ +SETUPTPL = """\ +from distutils.core import setup + +setup( + name='{{ module }}', + version='{{ version }}', + author='{{ author }}', + url='{{ url }}', + + description='{{ description }}', + license='{{ license }}', + + py_modules=['{{ module }}'], + + classifiers=[ + 'Classifier: Programming Language :: Python :: 2', + 'Classifier: Programming Language :: Python :: 3', + ], +) +""" + if __name__ == '__main__': if not sys.argv[1:]: sys.exit("usage: pack.py ") @@ -120,7 +141,7 @@ def lookup(match): text = MiniJinja(BASE).render_string(MAINTPL, **tplvars) zf.writestr('__main__.py', text) print("[*] Making %s installable" % (packname)) - text2 = MiniJinja(BASE).render('pack.setuppy.tpl', **tplvars) + text2 = MiniJinja(BASE).render_string(SETUPTPL, **tplvars) zf.writestr('setup.py', text2) print("[*] Making %s uploadable to PyPI" % (packname)) zf.writestr('PKG-INFO', '') diff --git a/other/pack.setuppy.tpl b/other/pack.setuppy.tpl deleted file mode 100644 index e04a8db..0000000 --- a/other/pack.setuppy.tpl +++ /dev/null @@ -1,18 +0,0 @@ -from distutils.core import setup - -setup( - name='{{ module }}', - version='{{ version }}', - author='{{ author }}', - url='{{ url }}', - - description='{{ description }}', - license='{{ license }}', - - py_modules=['{{ module }}'], - - classifiers=[ - 'Classifier: Programming Language :: Python :: 2', - 'Classifier: Programming Language :: Python :: 3', - ], -) From 7bdb53188a1a7a3b86d2fe589687ff4b6402941a Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Thu, 15 Sep 2016 15:31:36 +0300 Subject: [PATCH 11/19] doc: Diff evolution to VCS era added file removal --- doc/evolution-notes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/evolution-notes.txt b/doc/evolution-notes.txt index 784f5e6..7c544c2 100644 --- a/doc/evolution-notes.txt +++ b/doc/evolution-notes.txt @@ -13,6 +13,7 @@ patchset evolution 2. copy file 2. copy and rename 2. move and rename +2. remove file 3. know file attributes 3. know file mime-type From 76f0205f67bb31cfd5f8fc0d9a4b84a1f385c8dd Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Thu, 15 Sep 2016 22:38:19 +0300 Subject: [PATCH 12/19] other/pack.py: Moved to https://pypi.python.org/pypi/pypack --- doc/RELEASING | 3 +- other/README.md | 1 - other/pack.py | 149 ------------------------------------------------ 3 files changed, 2 insertions(+), 151 deletions(-) delete mode 100644 other/README.md delete mode 100755 other/pack.py diff --git a/doc/RELEASING b/doc/RELEASING index e0e4d7d..f367207 100644 --- a/doc/RELEASING +++ b/doc/RELEASING @@ -1,6 +1,7 @@ * [ ] Pack .zip archive - python ./other/pack.py patch.py + pip install pypack + python -m pypack patch.py * [ ] Write changelog diff --git a/other/README.md b/other/README.md deleted file mode 100644 index d6f9a51..0000000 --- a/other/README.md +++ /dev/null @@ -1 +0,0 @@ -See ../doc/RELEASING for pack.py instructions. \ No newline at end of file diff --git a/other/pack.py b/other/pack.py deleted file mode 100755 index d5abd70..0000000 --- a/other/pack.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env python -""" -Wrap Python module into executable .zip package. - -Extracts required meta-data (author|maintainer, name, version, -url) and optional fields (description) from module without -importing it. - - * [x] name, version - * [x] author - * [x] license - * [x] url - * [x] description (first line of module docstring) - -Public domain work by: - anatoly techtonik -""" -import os -import sys - -def get_field(path, name='__version__'): - '''Read named string from module without importing it''' - for line in open(path, 'rb'): - # Decode to unicode for PY2/PY3 in a fail-safe way - line = line.decode('cp437') - if name in line: - # __version__ = "0.9" - delim = '\"' if '\"' in line else '\'' - return line.split(delim)[1] - -def get_description(path): - '''Return first non-empty line from module docstring''' - mf = open(path, 'rb') - for i, line in enumerate(mf): - if i > 10: - # stop looking after 10 lines - break - line = line.decode('utf-8').strip() - if '"""' in line or "'''" in line: - while line.strip('\n\t\r \'\"') == '': - line = next(mf) - line = line.decode('utf-8').strip() - return line - -def zipadd(archive, filename, newname): - '''Add filename to archive. `newname` is required. Otherwise - zipfile may create unsafe entries, such as "../patch.py". - Returns open ZipFile object. - ''' - import zipfile - zf = zipfile.ZipFile(archive, 'a', zipfile.ZIP_DEFLATED) - zf.write(filename, newname) - return zf - -class MiniJinja(object): - """Template engine that knows how to render {{ tag }}""" - - def __init__(self, templates='.'): - """templates - template path""" - import re - import sys - self.PY3K = sys.version_info[0] == 3 - - self.path = templates + '/' - self.tag = re.compile('{{ *(?P\w+) *}}') - - def render(self, tplfile, vardict=None, **kwargs): - """returns unicode str""" - tpltext = open(self.path + tplfile).read() - return self.render_string(tpltext, vardict, **kwargs) - - def render_string(self, tpltext, vardict=None, **kwargs): - data = vardict or {} - data.update(kwargs) - - def lookup(match): - return data[match.group('tag')] - - if not self.PY3K: - return unicode(self.tag.sub(lookup, tpltext)) - else: - return self.tag.sub(lookup, tpltext) - -# --- - -BASE = os.path.abspath(os.path.dirname(__file__)) - -MAINTPL = """\ -import sys - -import {{ module }} -sys.exit({{ module }}.main()) -""" - -SETUPTPL = """\ -from distutils.core import setup - -setup( - name='{{ module }}', - version='{{ version }}', - author='{{ author }}', - url='{{ url }}', - - description='{{ description }}', - license='{{ license }}', - - py_modules=['{{ module }}'], - - classifiers=[ - 'Classifier: Programming Language :: Python :: 2', - 'Classifier: Programming Language :: Python :: 3', - ], -) -""" - -if __name__ == '__main__': - if not sys.argv[1:]: - sys.exit("usage: pack.py ") - - modpath = sys.argv[1] - tplvars = dict( - module = os.path.basename(modpath)[:-3], # also strip extension - version = get_field(modpath, '__version__'), - author = get_field(modpath, '__author__'), - license = get_field(modpath, '__license__'), - url = get_field(modpath, '__url__'), - description = get_description(modpath) - ) - - if tplvars['version'] == None: - sys.exit("error: no __version__ specifier found in %s" % modpath) - if tplvars['author'] == None: - sys.exit("error: no __author__ specifier found in %s" % modpath) - packname = tplvars['module'] + "-" + tplvars['version'] + ".zip" - print("[*] Packing %s into %s" % (modpath, packname)) - if os.path.exists(packname): - os.remove(packname) - zf = zipadd(packname, modpath, os.path.basename(modpath)) - print("[*] Making %s executable" % (packname)) - # http://techtonik.rainforce.org/2015/01/shipping-python-tools-in-executable-zip.html - text = MiniJinja(BASE).render_string(MAINTPL, **tplvars) - zf.writestr('__main__.py', text) - print("[*] Making %s installable" % (packname)) - text2 = MiniJinja(BASE).render_string(SETUPTPL, **tplvars) - zf.writestr('setup.py', text2) - print("[*] Making %s uploadable to PyPI" % (packname)) - zf.writestr('PKG-INFO', '') - zf.close() - From c9402be37c365e1bdf4aef07dcfa8c9ab3dab47f Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Thu, 15 Sep 2016 23:17:59 +0300 Subject: [PATCH 13/19] .travis.yml: Test packaging --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 71b8bb6..19851de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,11 @@ python: install: - pip install coverage + - pip install pypack script: # run tests with coverage - coverage run tests/run_tests.py - coverage report -m + # test distribution packaging + - python -m pypack patch.py From 327a55f7ffe911bd5fd4c065322e56a12cd7768a Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 28 Aug 2019 16:18:01 +0300 Subject: [PATCH 14/19] README.md Update Travis shield to point to master See also https://github.com/badges/shields/issues/3928 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da1f0c2..69da404 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Library to parse and apply unified diffs. -[![Build Status](https://img.shields.io/travis/techtonik/python-patch.svg)](https://travis-ci.org/techtonik/python-patch) +[![Build Status](https://img.shields.io/travis/techtonik/python-patch/master)](https://travis-ci.org/techtonik/python-patch/branches) ### Features From eea59a880f9ffb5b480bcd53451316181847e90c Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 28 Aug 2019 17:08:43 +0300 Subject: [PATCH 15/19] .travis.yml: Update Python versions and remove 2.6 Python 2.6 is not among supported Python anymore https://docs.travis-ci.com/user/languages/python/ --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19851de..356b919 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,13 @@ language: python python: - - "2.6" - "2.7" - "3.3" - "3.4" - "3.5" - - "3.5-dev" # 3.5 development branch - - "nightly" # currently points to 3.6-dev + - "3.6" + - "3.7" + - "3.7-dev" + - "3.8-dev" install: - pip install coverage From b51b431a97f5055286d16d14efc845f9531d96fb Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 28 Aug 2019 17:29:33 +0300 Subject: [PATCH 16/19] README.md Add PyPI badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 69da404..6cca3fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Library to parse and apply unified diffs. -[![Build Status](https://img.shields.io/travis/techtonik/python-patch/master)](https://travis-ci.org/techtonik/python-patch/branches) +[![Build Status](https://img.shields.io/travis/techtonik/python-patch/master)](https://travis-ci.org/techtonik/python-patch/branches) [![PyPI](https://img.shields.io/pypi/v/patch)](https://pypi.python.org/pypi/patch) ### Features From e49bf35f96ac5e44251d5b6d0b98a09e09cfecdb Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 28 Aug 2019 17:35:04 +0300 Subject: [PATCH 17/19] .travis.yml: Python 3.3 is phased out https://docs.travis-ci.com/user/languages/python/ Builds are still failing for other 3.x versions https://travis-ci.org/techtonik/python-patch/builds/577891154 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 356b919..286ed03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" From 33bda09082b4391e3729c363cb39e10886233b6e Mon Sep 17 00:00:00 2001 From: ossdev07 <39188636+ossdev07@users.noreply.github.com> Date: Fri, 20 Dec 2019 14:57:31 +0530 Subject: [PATCH 18/19] Add arm64 jobs --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 286ed03..239708f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,12 @@ python: - "3.7" - "3.7-dev" - "3.8-dev" - + +os: linux +arch: + - amd64 + - arm64 + install: - pip install coverage - pip install pypack From 249e2af7f372d4b6e6621902e6d3c2a2dfbe5e5d Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Sun, 23 Feb 2020 21:04:45 +0530 Subject: [PATCH 19/19] Fix deprecation warnings due to invalid escape sequences. --- patch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patch.py b/patch.py index 4b82af0..4775d70 100755 --- a/patch.py +++ b/patch.py @@ -337,7 +337,7 @@ def lineno(self): hunkparsed = False # state after successfully parsed hunk # regexp to match start of hunk, used groups - 1,3,4,6 - re_hunk_start = re.compile(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@") + re_hunk_start = re.compile(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@") self.errors = 0 # temp buffers for header and filenames info @@ -516,7 +516,7 @@ def lineno(self): filenames = False headscan = True else: - re_filename = b"^\+\+\+ ([^\t]+)" + re_filename = br"^\+\+\+ ([^\t]+)" match = re.match(re_filename, line) if not match: warning("skipping invalid patch - no target filename at line %d" % (lineno+1)) @@ -542,7 +542,7 @@ def lineno(self): continue if hunkhead: - match = re.match(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line) + match = re.match(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line) if not match: if not p.hunks: warning("skipping invalid patch with no hunks for file %s" % p.source)