Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH] test_compile_modules: skip files that require newer Python version
Date: Sat, 31 Jan 2015 08:18:51
Message-Id: 1422692286-831-1-git-send-email-mgorny@gentoo.org
1 Support skipping Python modules and scripts that require newer Python
2 version than currently used during compile tests. Add a metadata db that
3 can be used to store additional information about Python files, and
4 store the required language version there.
5 ---
6 pym/portage/tests/lint/metadata.py | 11 +++++++++++
7 pym/portage/tests/lint/test_compile_modules.py | 13 +++++++++++++
8 2 files changed, 24 insertions(+)
9 create mode 100644 pym/portage/tests/lint/metadata.py
10
11 diff --git a/pym/portage/tests/lint/metadata.py b/pym/portage/tests/lint/metadata.py
12 new file mode 100644
13 index 0000000..e3f90cb
14 --- /dev/null
15 +++ b/pym/portage/tests/lint/metadata.py
16 @@ -0,0 +1,11 @@
17 +# Copyright 2015 Gentoo Foundation
18 +# Distributed under the terms of the GNU General Public License v2
19 +
20 +module_metadata = {
21 +}
22 +
23 +script_metadata = {
24 + 'socks5-server.py': {
25 + 'required_python': '3.3',
26 + },
27 +}
28 diff --git a/pym/portage/tests/lint/test_compile_modules.py b/pym/portage/tests/lint/test_compile_modules.py
29 index 4826cad..51eb8cd 100644
30 --- a/pym/portage/tests/lint/test_compile_modules.py
31 +++ b/pym/portage/tests/lint/test_compile_modules.py
32 @@ -4,9 +4,11 @@
33 import errno
34 import itertools
35 import stat
36 +import sys
37
38 from portage.const import PORTAGE_BIN_PATH, PORTAGE_PYM_PATH, PORTAGE_PYM_PACKAGES
39 from portage.tests import TestCase
40 +from portage.tests.lint.metadata import module_metadata, script_metadata
41 from portage import os
42 from portage import _encodings
43 from portage import _unicode_decode, _unicode_encode
44 @@ -30,6 +32,17 @@ class CompileModulesTestCase(TestCase):
45 st = os.lstat(x)
46 if not stat.S_ISREG(st.st_mode):
47 continue
48 +
49 + bin_path = os.path.relpath(x, PORTAGE_BIN_PATH)
50 + mod_path = os.path.relpath(x, PORTAGE_PYM_PATH)
51 +
52 + meta = module_metadata.get(mod_path) or script_metadata.get(bin_path)
53 + if meta:
54 + req_py = tuple(int(x) for x
55 + in meta.get('required_python', '0.0').split('.'))
56 + if sys.version_info < req_py:
57 + continue
58 +
59 do_compile = False
60 if x[-3:] == '.py':
61 do_compile = True
62 --
63 2.2.2

Replies