SUMMARY="Library to parse and apply unified diffs"
DESCRIPTION="Patch NG (New Generation)
Why did we fork this project?

This project is a fork from the original python-patch project.

As any other project, bugs are common during the development process, the combination of issues + \
pull requests are able to keep the constant improvement of a project.
However, both community and author need to be aligned. When users, developers, the community, \
needs a fix which are important for their projects, but there is no answer from the author, or the \
time for response is not enough, then the most plausible way is forking and continuing a parallel \
development.

That's way we forked the original and accepted most of PRs waiting for review since jun/2019 (5 \
months from now).

Features
 * Python 2 and 3 compatible
 * Automatic correction of
   ** Linefeeds according to patched file
   ** Diffs broken by stripping trailing whitespace
   ** a/ and b/ prefixes
 * Single file, which is a command line tool and a library
 * No dependencies outside Python stdlib
 * Patch format detection (SVN, HG, GIT)
 * Nice diffstat histogram
 * Linux / Windows / OS X
 * Test coverage

Things that don't work out of the box:

 * File renaming, creation and removal
 * Directory tree operations
 * Version control specific properties
 * Non-unified diff formats."
HOMEPAGE="https://github.com/conan-io/python-patch-ng"
COPYRIGHT="2019-2020 Uilian Ries
	2008-2019 Anatoly Techtonik"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="$HOMEPAGE/archive/refs/tags/$portVersion.tar.gz"
CHECKSUM_SHA256="e332ea2c2e64e95b988c6e904a51be65b80560518a9b101c604a1a4378673795"
SOURCE_DIR="python-patch-ng-$portVersion"

ARCHITECTURES="all"

PROVIDES="
	$portName = $portVersion
	"
REQUIRES="
	haiku
	"

BUILD_REQUIRES="
	haiku_devel
	"

PYTHON_PACKAGES=(python3 python38 python39)
PYTHON_VERSIONS=(3.7 3.8 3.9)
for i in "${!PYTHON_PACKAGES[@]}"; do
	pythonPackage=${PYTHON_PACKAGES[i]}
	pythonVersion=${PYTHON_VERSIONS[$i]}
	eval "PROVIDES_$pythonPackage=\"
		${portName}_$pythonPackage = $portVersion
		\""
	eval "REQUIRES_$pythonPackage=\"
		haiku
		cmd:python$pythonVersion
		\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done

INSTALL()
{
	for i in "${!PYTHON_PACKAGES[@]}"; do
		pythonPackage=${PYTHON_PACKAGES[i]}
		pythonVersion=${PYTHON_VERSIONS[$i]}

		python=python$pythonVersion
		installLocation=$prefix/lib/$python/vendor-packages/
		export PYTHONPATH=$installLocation:$PYTHONPATH
		mkdir -p $installLocation
		rm -rf build
		$python setup.py build install \
			--root=/ --prefix=$prefix

		packageEntries  $pythonPackage \
			$prefix/lib/python*
	done
}
