1SUMMARY="Fast C based HTML 5 parsing for python"
2DESCRIPTION="A fast implementation of the HTML 5 parsing spec for Python. \
3Parsing is done in C using a variant of the gumbo parser. The gumbo parse \
4tree is then transformed into an lxml tree, also in C, yielding parse times \
5that can be a thirtieth of the html5lib parse times. That is a speedup of \
630x. This differs, for instance, from the gumbo python bindings, where the \
7initial parsing is done in C but the transformation into the final tree \
8is done in python."
9HOMEPAGE="https://html5-parser.readthedocs.io/
10	https://pypi.python.org/pypi/html5-parser/"
11COPYRIGHT="2017 Kovid Goyal
12	2010, 2011 Google Inc.
13	2015-2016 Kevin B. Hendricks, Stratford Ontario
14	2008-2009 Bjoern Hoehrmann"
15LICENSE="Apache v2"
16REVISION="2"
17SOURCE_URI="https://files.pythonhosted.org/packages/source/h/html5-parser/html5-parser-$portVersion.tar.gz"
18CHECKSUM_SHA256="f9294418c0da95c2d5facc19d3dc32941093a6b8e3b3e4b36cc7b5a1697fbca4"
19SOURCE_DIR="html5-parser-$portVersion"
20
21ARCHITECTURES="all !x86_gcc2"
22SECONDARY_ARCHITECTURES="x86"
23
24PROVIDES="
25	html5_parser$secondaryArchSuffix = $portVersion
26	"
27REQUIRES="
28	haiku$secondaryArchSuffix
29	"
30
31BUILD_REQUIRES="
32	haiku${secondaryArchSuffix}_devel
33	devel:libxml2$secondaryArchSuffix
34	"
35BUILD_PREREQUIRES="
36	cmd:gcc$secondaryArchSuffix
37	cmd:pkg_config$secondaryArchSuffix
38	"
39
40PYTHON_PACKAGES=(python39 python310)
41PYTHON_VERSIONS=(3.9 3.10)
42for i in "${!PYTHON_PACKAGES[@]}"; do
43	pythonPackage=${PYTHON_PACKAGES[i]}
44	pythonVersion=${PYTHON_VERSIONS[$i]}
45
46	eval "PROVIDES_$pythonPackage=\"
47		${portName}_$pythonPackage = $portVersion
48		\""
49	if [ "$targetArchitecture" = "x86_gcc2" ]; then
50		eval "PROVIDES_$pythonPackage+=\"
51			html5_parser_$pythonPackage = $portVersion
52			\""
53	fi
54	eval "REQUIRES_$pythonPackage=\"
55		haiku$secondaryArchSuffix
56		chardet_$pythonPackage
57		lxml${secondaryArchSuffix}_$pythonPackage
58		lib:libpython$pythonVersion$secondaryArchSuffix
59		\""
60
61	BUILD_REQUIRES+="
62		setuptools_$pythonPackage
63		"
64	BUILD_PREREQUIRES+="
65		cmd:python$pythonVersion
66		"
67	TEST_REQUIRES+="
68		${portName}_$pythonPackage
69		beautifulsoup_$pythonPackage
70		chardet_$pythonPackage
71		lxml${secondaryArchSuffix}_$pythonPackage
72		"
73done
74
75
76BUILD()
77{
78	for i in "${!PYTHON_PACKAGES[@]}"; do
79		pythonPackage=${PYTHON_PACKAGES[i]}
80		pythonVersion=${PYTHON_VERSIONS[$i]}
81
82		rm -rf "$sourceDir"-$pythonPackage
83		cp -a "$sourceDir" "$sourceDir"-$pythonPackage
84		cd "$sourceDir"-$pythonPackage
85
86		python=python$pythonVersion
87		$python setup.py build
88	done
89}
90
91
92INSTALL()
93{
94	for i in "${!PYTHON_PACKAGES[@]}"; do
95		pythonPackage=${PYTHON_PACKAGES[i]}
96		pythonVersion=${PYTHON_VERSIONS[$i]}
97
98		cd "$sourceDir"-$pythonPackage
99
100		python=python$pythonVersion
101		installLocation=$prefix/lib/$python/vendor-packages
102		export PYTHONPATH=$installLocation
103
104		mkdir -p "$installLocation"
105
106		$python setup.py install \
107			--root=/ --prefix="$prefix"
108
109		packageEntries $pythonPackage \
110			"$prefix"/lib/$python
111	done
112
113	cd "$sourceDir"
114	install -m 755 -d "$docDir"
115	install -m 644 -t "$docDir" README.rst
116}
117
118
119TEST()
120{
121	for i in "${!PYTHON_PACKAGES[@]}"; do
122		pythonPackage=${PYTHON_PACKAGES[i]}
123		pythonVersion=${PYTHON_VERSIONS[$i]}
124
125		cd "$sourceDir"-$pythonPackage
126
127		python=python$pythonVersion
128		$python run_tests.py
129	done
130}
131