Skip to content

Commit 7057c3c

Browse files
committed
Add setup file
- Add setup.py (setuptools) - Update LICENSE with Conan MIT - Fix patch - Update README file with fork description Signed-off-by: Uilian Ries <uilianries@gmail.com>
1 parent ea1d35b commit 7057c3c

File tree

4 files changed

+205
-30
lines changed

4 files changed

+205
-30
lines changed

doc/LICENSE renamed to LICENSE

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,34 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
THE SOFTWARE.
23+
24+
----
25+
26+
The MIT License (MIT)
27+
28+
Copyright (c) 2019 JFrog LTD
29+
30+
31+
32+
Permission is hereby granted, free of charge, to any person obtaining a copy
33+
of this software and associated documentation files (the "Software"), to deal
34+
in the Software without restriction, including without limitation the rights
35+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36+
copies of the Software, and to permit persons to whom the Software is
37+
furnished to do so, subject to the following conditions:
38+
39+
40+
41+
The above copyright notice and this permission notice shall be included in
42+
all copies or substantial portions of the Software.
43+
44+
45+
46+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
52+
THE SOFTWARE.
53+

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
Library to parse and apply unified diffs.
1+
[![PyPI](https://img.shields.io/pypi/v/patch-ng)](https://pypi.python.org/pypi/patch-ng)
22

3-
[![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)
3+
## Patch NG (New Generation)
4+
5+
#### Library to parse and apply unified diffs.
6+
7+
#### Why did we fork this project?
8+
9+
This project is a fork from the original [python-patch](https://github.com/techtonik/python-patch) project.
10+
11+
As any other project, bugs are common during the development process, the combination of issues + pull requests are
12+
able to keep the constant improvement of a project. However, both community and author need to be aligned. When users,
13+
developers, the community, needs a fix which are important for their projects, but there is no answer from the author,
14+
or the time for response is not enough, then the most plausible way is forking and continuing a parallel development.
15+
16+
That's way we forked the original and accepted most of PRs waiting for review since jun/2019 (5 months from now).
417

518
### Features
619

@@ -32,8 +45,8 @@ module without external dependencies.
3245
patch.py diff.patch
3346

3447
You can also run the .zip file.
35-
36-
python patch-1.16.zip diff.patch
48+
49+
python patch-1.17.zip diff.patch
3750

3851
### Installation
3952

@@ -42,13 +55,11 @@ and use it from here. This setup will always be repeatable. But if
4255
you need to add `patch` module as a dependency, make sure to use strict
4356
specifiers to avoid hitting an API break when version 2 is released:
4457

45-
pip install "patch==1.*"
58+
pip install "patch-ng"
4659

4760

4861
### Other stuff
4962

5063
* [CHANGES](doc/CHANGES.md)
51-
* [LICENSE](doc/LICENSE)
64+
* [LICENSE: MIT](LICENSE)
5265
* [CREDITS](doc/CREDITS)
53-
54-
* [test coverage](http://techtonik.github.io/python-patch/tests/coverage/)

patch.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,33 @@
77
Copyright (c) 2008-2016 anatoly techtonik
88
Available under the terms of MIT license
99
10+
---
11+
The MIT License (MIT)
12+
13+
Copyright (c) 2019 JFrog LTD
14+
15+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
16+
and associated documentation files (the "Software"), to deal in the Software without
17+
restriction, including without limitation the rights to use, copy, modify, merge, publish,
18+
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
19+
Software is furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all copies or
22+
substantial portions of the Software.
23+
24+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
25+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
26+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
27+
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
SOFTWARE.
1030
"""
1131
from __future__ import print_function
1232

13-
__author__ = "anatoly techtonik <techtonik@gmail.com>"
14-
__version__ = "1.16"
33+
__author__ = "Conan.io <info@conan.io>"
34+
__version__ = "1.17"
1535
__license__ = "MIT"
16-
__url__ = "https://github.com/techtonik/python-patch"
36+
__url__ = "https://github.com/conan-io/python-patch"
1737

1838
import copy
1939
import logging
@@ -894,25 +914,12 @@ def apply(self, strip=0, root=None):
894914

895915
filenameo, filenamen = self.findfiles(old, new)
896916

897-
if not filename:
898-
if "dev/null" in old:
899-
# this is a file creation
900-
filename = self._strip_prefix(new)
901-
# I wish there would be something more clean to get the full contents
902-
new_file = "".join(s[1:] for s in p.hunks[0].text)
903-
with open(filename, "wb") as f:
904-
f.write(new_file)
905-
continue
906-
elif "dev/null" in new:
907-
# this is a file removal
908-
os.remove(self._strip_prefix(old))
909-
continue
910-
else:
911-
warning("source/target file does not exist:\n --- %s\n +++ %s" % (old, new))
912-
errors += 1
913-
continue
914-
if not isfile(filename):
915-
warning("not a file - %s" % filename)
917+
if not filenameo or not filenamen:
918+
warning("source/target file does not exist:\n --- %s\n +++ %s" % (old, new))
919+
errors += 1
920+
continue
921+
if not isfile(filenameo):
922+
warning("not a file - %s" % filenameo)
916923
errors += 1
917924
continue
918925

setup.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
"""A setuptools based setup module.
2+
See:
3+
https://packaging.python.org/en/latest/distributing.html
4+
https://github.com/pypa/sampleproject
5+
"""
6+
7+
# Always prefer setuptools over distutils
8+
import re
9+
import os
10+
from setuptools import setup, find_packages
11+
# To use a consistent encoding
12+
from codecs import open
13+
14+
15+
here = os.path.abspath(os.path.dirname(__file__))
16+
17+
# Get the long description from the README file
18+
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
19+
long_description = f.read()
20+
21+
22+
def get_requires(filename):
23+
requirements = []
24+
with open(filename) as req_file:
25+
for line in req_file.read().splitlines():
26+
if not line.strip().startswith("#"):
27+
requirements.append(line)
28+
return requirements
29+
30+
31+
def load_version():
32+
"""Loads a file content"""
33+
filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
34+
"patch.py"))
35+
with open(filename, "rt") as version_file:
36+
content = version_file.read()
37+
version = re.search('__version__ = "([0-9a-z.-]+)"', content).group(1)
38+
return version
39+
40+
setup(
41+
name='patch-ng',
42+
# Versions should comply with PEP440. For a discussion on single-sourcing
43+
# the version across setup.py and the project code, see
44+
# https://packaging.python.org/en/latest/single_source_version.html
45+
version=load_version(),
46+
47+
# This is an optional longer description of your project that represents
48+
# the body of text which users will see when they visit PyPI.
49+
#
50+
# Often, this is the same as your README, so you can just read it in from
51+
# that file directly (as we have already done above)
52+
#
53+
# This field corresponds to the "Description" metadata field:
54+
# https://packaging.python.org/specifications/core-metadata/#description-optional
55+
long_description=long_description, # Optional
56+
57+
description='Library to parse and apply unified diffs.',
58+
59+
# The project's main homepage.
60+
url='https://github.com/conan-io/python-patch',
61+
62+
# Author details
63+
author='Conan.io',
64+
author_email='info@conan.io',
65+
66+
# Choose your license
67+
license='MIT',
68+
69+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
70+
classifiers=[
71+
'Development Status :: 5 - Production/Stable',
72+
'Intended Audience :: Developers',
73+
'Topic :: Software Development :: Build Tools',
74+
'License :: OSI Approved :: MIT License',
75+
'Programming Language :: Python :: 2',
76+
'Programming Language :: Python :: 2.7',
77+
'Programming Language :: Python :: 3',
78+
],
79+
80+
# What does your project relate to?
81+
keywords=['patch', 'parse', 'diff', 'strip', 'diffstat'],
82+
83+
# You can just specify the packages manually here if your project is
84+
# simple. Or you can use find_packages().
85+
# packages=find_packages(exclude=['tests']),
86+
87+
# Alternatively, if you want to distribute just a my_module.py, uncomment
88+
# this:
89+
py_modules=["patch"],
90+
91+
# List run-time dependencies here. These will be installed by pip when
92+
# your project is installed. For an analysis of "install_requires" vs pip's
93+
# requirements files see:
94+
# https://packaging.python.org/en/latest/requirements.html
95+
# install_requires=get_requires('requirements.txt'),
96+
97+
# List additional groups of dependencies here (e.g. development
98+
# dependencies). You can install these using the following syntax,
99+
# for example:
100+
# $ pip install -e .[dev,test]
101+
#extras_require={
102+
# 'test': get_requires(os.path.join('tests', 'requirements_test.txt'))
103+
#},
104+
105+
# If there are data files included in your packages that need to be
106+
# installed, specify them here. If using Python 2.6 or less, then these
107+
# have to be included in MANIFEST.in as well.
108+
package_data={
109+
'': ['*.md'],
110+
},
111+
112+
# Although 'package_data' is the preferred approach, in some case you may
113+
# need to place data files outside of your packages. See:
114+
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
115+
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
116+
# data_files=[('my_data', ['data/data_file'])],
117+
118+
# To provide executable scripts, use entry points in preference to the
119+
# "scripts" keyword. Entry points provide cross-platform support and allow
120+
# pip to create the appropriate form of executable for the target platform.
121+
#entry_points={
122+
# 'console_scripts': [
123+
# 'patch.py=patch',
124+
# ],
125+
#},
126+
)

0 commit comments

Comments
 (0)