Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/kde:master commit in: dev-python/parse_cmake/files/, dev-python/parse_cmake/
Date: Sat, 14 Sep 2019 15:50:39
Message-Id: 1568475460.2a108e673d95c095fd5be61183050fd1d245f349.asturm@gentoo
1 commit: 2a108e673d95c095fd5be61183050fd1d245f349
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 14 15:37:40 2019 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 14 15:37:40 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/kde.git/commit/?id=2a108e67
7
8 dev-python/parse_cmake: Add upstream python3 fix
9
10 Package-Manager: Portage-2.3.76, Repoman-2.3.17
11 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
12
13 .../files/parse_cmake-0.4.1-python3-fix.patch | 110 +++++++++++++++++++++
14 dev-python/parse_cmake/parse_cmake-0.4.1-r1.ebuild | 26 +++++
15 2 files changed, 136 insertions(+)
16
17 diff --git a/dev-python/parse_cmake/files/parse_cmake-0.4.1-python3-fix.patch b/dev-python/parse_cmake/files/parse_cmake-0.4.1-python3-fix.patch
18 new file mode 100644
19 index 0000000000..c9e6d8859c
20 --- /dev/null
21 +++ b/dev-python/parse_cmake/files/parse_cmake-0.4.1-python3-fix.patch
22 @@ -0,0 +1,110 @@
23 +From 51daaefdfd68ee805bc5380f68ae88a32ef72a72 Mon Sep 17 00:00:00 2001
24 +From: Jeff Quast <contact@×××××××××.com>
25 +Date: Thu, 22 Mar 2018 17:46:26 -0700
26 +Subject: [PATCH] Bugfix python3 entry point for cmake_pprint (#2)
27 +
28 +* Update cmake_pprint.py
29 +
30 +* pprint doesn't make a difference
31 +
32 +* update flake8 test from rosdep repository
33 +
34 +* py2.7 fix
35 +
36 +* ignore some rules
37 +---
38 + parse_cmake/cmake_pprint.py | 4 +--
39 + tests/test_code_format.py | 57 ++++++++++++++++++++++++++++++-------
40 + 2 files changed, 48 insertions(+), 13 deletions(-)
41 +
42 +diff --git a/parse_cmake/cmake_pprint.py b/parse_cmake/cmake_pprint.py
43 +index 18e4e9e..d6865ef 100644
44 +--- a/parse_cmake/cmake_pprint.py
45 ++++ b/parse_cmake/cmake_pprint.py
46 +@@ -18,7 +18,7 @@
47 + import argparse
48 + import sys
49 +
50 +-import parsing as cmp
51 ++from .parsing import parse
52 +
53 +
54 + def main():
55 +@@ -40,7 +40,7 @@ def main():
56 + for (name, file) in files:
57 + with file:
58 + input = file.read()
59 +- tree = cmp.parse(input, path=name)
60 ++ tree = parse(input, path=name)
61 + if args.tree:
62 + # Print out AST
63 + print(repr(tree))
64 +diff --git a/tests/test_code_format.py b/tests/test_code_format.py
65 +index 287e6e1..9ab09e2 100644
66 +--- a/tests/test_code_format.py
67 ++++ b/tests/test_code_format.py
68 +@@ -12,18 +12,53 @@
69 + # See the License for the specific language governing permissions and
70 + # limitations under the License.
71 +
72 +-import flake8.engine
73 ++from __future__ import print_function
74 ++
75 + import os
76 ++import sys
77 ++
78 ++# flake8 doesn't support Python < 2.7 anymore
79 ++if sys.version_info[0] > 2 or sys.version_info[1] >= 7:
80 ++ from flake8.api.legacy import get_style_guide
81 ++else:
82 ++ get_style_guide = None
83 +
84 +
85 + def test_flake8():
86 +- """Test source code for pyFlakes and PEP8 conformance"""
87 +- flake8style = flake8.engine.StyleGuide(max_line_length=100)
88 +- report = flake8style.options.report
89 +- report.start()
90 +- this_dir = os.path.dirname(os.path.abspath(__file__))
91 +- flake8style.input_dir(os.path.join(this_dir, '..', 'parse_cmake'))
92 +- report.stop()
93 +- assert report.total_errors == 0, \
94 +- ("Found '{0}' code style errors (and warnings)."
95 +- .format(report.total_errors))
96 ++ if get_style_guide is None:
97 ++ # skip test on Python 2.6 and older
98 ++ return
99 ++
100 ++ style_guide = get_style_guide(
101 ++ exclude=[],
102 ++ ignore=[
103 ++ 'E731', # ignore assign lambda warning
104 ++ 'E226', # ignore whitespace around arithmetic operators
105 ++ 'E305', # ignore whitespace before/after functions rule
106 ++ 'D', # ignore documentation related warnings
107 ++ 'I', # ignore import order related warnings
108 ++ 'N802', # ignore presence of upper case in function names
109 ++ ],
110 ++ max_line_length=100,
111 ++ max_complexity=10,
112 ++ show_source=True,
113 ++ )
114 ++
115 ++ stdout = sys.stdout
116 ++ sys.stdout = sys.stderr
117 ++ # implicitly calls report_errors()
118 ++ report = style_guide.check_files([
119 ++ os.path.dirname(os.path.dirname(__file__)),
120 ++ ])
121 ++ sys.stdout = stdout
122 ++
123 ++ if report.total_errors:
124 ++ # output summary with per-category counts
125 ++ print()
126 ++ report._application.formatter.show_statistics(report._stats)
127 ++ print(
128 ++ 'flake8 reported {report.total_errors} errors'
129 ++ .format_map(locals()), file=sys.stderr)
130 ++
131 ++ assert not report.total_errors, \
132 ++ 'flake8 reported {report.total_errors} errors'.format(**locals())
133
134 diff --git a/dev-python/parse_cmake/parse_cmake-0.4.1-r1.ebuild b/dev-python/parse_cmake/parse_cmake-0.4.1-r1.ebuild
135 new file mode 100644
136 index 0000000000..cc2187f798
137 --- /dev/null
138 +++ b/dev-python/parse_cmake/parse_cmake-0.4.1-r1.ebuild
139 @@ -0,0 +1,26 @@
140 +# Copyright 1999-2019 Gentoo Authors
141 +# Distributed under the terms of the GNU General Public License v2
142 +
143 +EAPI=7
144 +
145 +PYTHON_COMPAT=( python2_7 python3_{6,7} )
146 +inherit distutils-r1
147 +
148 +DESCRIPTION="Parser for CMakeLists.txt files"
149 +HOMEPAGE="https://pypi.python.org/pypi/parse_cmake/"
150 +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
151 +
152 +LICENSE="Apache-2.0"
153 +SLOT="0"
154 +KEYWORDS="~amd64"
155 +IUSE=""
156 +
157 +BDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
158 +
159 +PATCHES=( "${FILESDIR}/${P}-python3-fix.patch" )
160 +
161 +src_prepare() {
162 + distutils-r1_src_prepare
163 + sed -i setup.py -e "s/'pyPEG2'//" || die
164 + mv tests tests-hidden || die
165 +}