Skip to content

Commit 2882c29

Browse files
authored
Merge pull request #3788 from Flamefire/python27
clean up code that was only there to support Python 2.6 + avoid syntax warnings when parsing py2vs3/py.p2 with Python 3.x
2 parents 1a26053 + 912f1a3 commit 2882c29

File tree

13 files changed

+37
-40
lines changed

13 files changed

+37
-40
lines changed

.github/workflows/unit_tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ jobs:
101101
# and are only run after the PR gets merged
102102
GITHUB_TOKEN: ${{secrets.CI_UNIT_TESTS_GITHUB_TOKEN}}
103103
run: |
104-
# only install GitHub token when testing with Lmod 8.x + Python 3.6 or 3.9, to avoid hitting GitHub rate limit;
104+
# only install GitHub token when testing with Lmod 8.x + Python 3.6 or 3.9, to avoid hitting GitHub rate limit
105105
# tests that require a GitHub token are skipped automatically when no GitHub token is available
106106
if [[ "${{matrix.modules_tool}}" =~ 'Lmod-8' ]] && [[ "${{matrix.python}}" =~ 3.[69] ]]; then
107107
if [ ! -z $GITHUB_TOKEN ]; then
108-
SET_KEYRING="import keyrings.alt.file; keyring.set_keyring(keyrings.alt.file.PlaintextKeyring())";
109-
python -c "import keyring; $SET_KEYRING; keyring.set_password('github_token', 'easybuild_test', '$GITHUB_TOKEN')";
108+
SET_KEYRING="import keyrings.alt.file; keyring.set_keyring(keyrings.alt.file.PlaintextKeyring())"
109+
python -c "import keyring; $SET_KEYRING; keyring.set_password('github_token', 'easybuild_test', '$GITHUB_TOKEN')"
110110
fi
111111
echo "GitHub token installed!"
112112
else
@@ -191,7 +191,17 @@ jobs:
191191
# run test suite
192192
python -O -m test.framework.suite 2>&1 | tee test_framework_suite.log
193193
# try and make sure output of running tests is clean (no printed messages/warnings)
194-
IGNORE_PATTERNS="no GitHub token available|skipping SvnRepository test|requires Lmod as modules tool|stty: 'standard input': Inappropriate ioctl for device|CryptographyDeprecationWarning: Python 3.[56]|from cryptography.* import |CryptographyDeprecationWarning: Python 2|Blowfish|GC3Pie not available, skipping test|CryptographyDeprecationWarning: TripleDES has been moved|algorithms.TripleDES"
194+
IGNORE_PATTERNS="no GitHub token available"
195+
IGNORE_PATTERNS+="|skipping SvnRepository test"
196+
IGNORE_PATTERNS+="|requires Lmod as modules tool"
197+
IGNORE_PATTERNS+="|stty: 'standard input': Inappropriate ioctl for device"
198+
IGNORE_PATTERNS+="|CryptographyDeprecationWarning: Python 3.[56]"
199+
IGNORE_PATTERNS+="|from cryptography.* import "
200+
IGNORE_PATTERNS+="|CryptographyDeprecationWarning: Python 2"
201+
IGNORE_PATTERNS+="|Blowfish"
202+
IGNORE_PATTERNS+="|GC3Pie not available, skipping test"
203+
IGNORE_PATTERNS+="|CryptographyDeprecationWarning: TripleDES has been moved"
204+
IGNORE_PATTERNS+="|algorithms.TripleDES"
195205
# '|| true' is needed to avoid that GitHub Actions stops the job on non-zero exit of grep (i.e. when there are no matches)
196206
PRINTED_MSG=$(egrep -v "${IGNORE_PATTERNS}" test_framework_suite.log | grep '\.\n*[A-Za-z]' || true)
197207
test "x$PRINTED_MSG" = "x" || (echo "ERROR: Found printed messages in output of test suite" && echo "${PRINTED_MSG}" && exit 1)

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import functools
4747
import os
4848
import re
49+
from collections import OrderedDict
4950
from contextlib import contextmanager
5051

5152
import easybuild.tools.filetools as filetools
@@ -74,7 +75,7 @@
7475
from easybuild.tools.module_naming_scheme.utilities import avail_module_naming_schemes, det_full_ec_version
7576
from easybuild.tools.module_naming_scheme.utilities import det_hidden_modname, is_valid_module_name
7677
from easybuild.tools.modules import modules_tool, NoModulesTool
77-
from easybuild.tools.py2vs3 import OrderedDict, create_base_metaclass, string_type
78+
from easybuild.tools.py2vs3 import create_base_metaclass, string_type
7879
from easybuild.tools.systemtools import check_os_dependency, pick_dep_version
7980
from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME, is_system_toolchain
8081
from easybuild.tools.toolchain.toolchain import TOOLCHAIN_CAPABILITIES, TOOLCHAIN_CAPABILITY_CUDA

easybuild/framework/easyconfig/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import re
4646
import sys
4747
import tempfile
48+
from collections import OrderedDict
4849

4950
from easybuild.base import fancylogger
5051
from easybuild.framework.easyconfig import EASYCONFIGS_PKG_SUBDIR
@@ -64,7 +65,6 @@
6465
from easybuild.tools.github import fetch_easyconfigs_from_pr, fetch_pr_data
6566
from easybuild.tools.github import fetch_files_from_commit, fetch_files_from_pr
6667
from easybuild.tools.multidiff import multidiff
67-
from easybuild.tools.py2vs3 import OrderedDict
6868
from easybuild.tools.toolchain.toolchain import is_system_toolchain
6969
from easybuild.tools.toolchain.utilities import search_toolchain
7070
from easybuild.tools.utilities import only_if_module_is_available, quote_str

easybuild/tools/build_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* Stijn De Weirdt (Ghent University)
3232
"""
3333
import time
34+
from collections import OrderedDict
3435
from easybuild.tools.filetools import det_size
35-
from easybuild.tools.py2vs3 import OrderedDict
3636
from easybuild.tools.systemtools import get_system_info
3737
from easybuild.tools.version import EASYBLOCKS_VERSION, FRAMEWORK_VERSION
3838

easybuild/tools/docs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import inspect
4141
import json
4242
import os
43+
from collections import OrderedDict
4344
from easybuild.tools import LooseVersion
4445

4546
from easybuild.base import fancylogger
@@ -60,7 +61,7 @@
6061
from easybuild.tools.config import build_option
6162
from easybuild.tools.filetools import read_file
6263
from easybuild.tools.modules import modules_tool
63-
from easybuild.tools.py2vs3 import OrderedDict, ascii_lowercase
64+
from easybuild.tools.py2vs3 import ascii_lowercase
6465
from easybuild.tools.toolchain.toolchain import DUMMY_TOOLCHAIN_NAME, SYSTEM_TOOLCHAIN_NAME, is_system_toolchain
6566
from easybuild.tools.toolchain.utilities import search_toolchain
6667
from easybuild.tools.utilities import INDENT_2SPACES, INDENT_4SPACES

easybuild/tools/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import sys
4646
import tempfile
4747
import pwd
48+
from collections import OrderedDict
4849

4950
import easybuild.tools.environment as env
5051
from easybuild.base import fancylogger # build_log should always stay there, to ensure EasyBuildLog
@@ -97,7 +98,7 @@
9798
from easybuild.tools.module_generator import ModuleGeneratorLua, avail_module_generators
9899
from easybuild.tools.module_naming_scheme.utilities import avail_module_naming_schemes
99100
from easybuild.tools.modules import Lmod
100-
from easybuild.tools.py2vs3 import OrderedDict, string_type
101+
from easybuild.tools.py2vs3 import string_type
101102
from easybuild.tools.robot import det_robot_path
102103
from easybuild.tools.run import run_cmd
103104
from easybuild.tools.package.utilities import avail_package_naming_schemes

easybuild/tools/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
* Jørgen Nordmoen (University of Oslo)
3333
"""
3434
import functools
35+
from collections import OrderedDict
3536

3637
from easybuild.tools.build_log import EasyBuildError
3738
from easybuild.tools.config import OUTPUT_STYLE_RICH, build_option, get_output_style
38-
from easybuild.tools.py2vs3 import OrderedDict
3939

4040
try:
4141
from rich.console import Console, Group

easybuild/tools/py2vs3/py2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353

5454
# reload function (built-in in Python 2)
55-
reload = reload
55+
reload = reload # noqa: F821
5656

5757
# string type that can be used in 'isinstance' calls
5858
string_type = basestring
@@ -89,9 +89,12 @@ def subprocess_terminate(proc, timeout):
8989
proc.terminate()
9090

9191

92+
# Wrapped in exec to avoid invalid syntax warnings for Python 3
93+
exec('''
9294
def raise_with_traceback(exception_class, message, traceback):
9395
"""Raise exception of specified class with given message and traceback."""
9496
raise exception_class, message, traceback # noqa: E999
97+
''')
9598

9699

97100
def extract_method_name(method_func):

easybuild/tools/systemtools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import sys
4343
import termios
4444
import warnings
45+
from collections import OrderedDict
4546
from ctypes.util import find_library
4647
from socket import gethostname
4748
from easybuild.tools.py2vs3 import subprocess_popen_text
@@ -64,7 +65,7 @@
6465
from easybuild.tools.build_log import EasyBuildError, print_warning
6566
from easybuild.tools.config import IGNORE
6667
from easybuild.tools.filetools import is_readable, read_file, which
67-
from easybuild.tools.py2vs3 import OrderedDict, string_type
68+
from easybuild.tools.py2vs3 import string_type
6869
from easybuild.tools.run import run_cmd
6970

7071

@@ -735,7 +736,6 @@ def get_os_name():
735736
# platform.linux_distribution was removed in Python 3.8,
736737
# see https://docs.python.org/2/library/platform.html#platform.linux_distribution
737738
if hasattr(platform, 'linux_distribution'):
738-
# platform.linux_distribution is more useful, but only available since Python 2.6
739739
# this allows to differentiate between Fedora, CentOS, RHEL and Scientific Linux (Rocks is just CentOS)
740740
with warnings.catch_warnings():
741741
warnings.simplefilter("ignore", category=PendingDeprecationWarning)

eb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ keyboard_interrupt() {
4040

4141
trap keyboard_interrupt SIGINT
4242

43-
# Python 2.6+ or 3.5+ required
44-
REQ_MIN_PY2VER=6
43+
# Python 2.7+ or 3.5+ required
44+
REQ_MIN_PY2VER=7
4545
REQ_MIN_PY3VER=5
4646

4747
EASYBUILD_MAIN='easybuild.main'

0 commit comments

Comments
 (0)