Skip to content

Commit 5d093da

Browse files
committed
deprecate Python2
replaced PYTHON_INTERPRETER with python3
1 parent ca22c02 commit 5d093da

25 files changed

+41
-100
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -157,39 +157,6 @@ jobs:
157157
working-directory: ${{ github.workspace }}/build
158158
run: ctest --output-on-failure
159159

160-
Python2:
161-
needs: [ShellCheck, Pylint]
162-
runs-on: ubuntu-latest
163-
container:
164-
image: centos:8
165-
steps:
166-
- uses: actions/checkout@v4
167-
168-
- uses: actions/cache@v4
169-
with:
170-
path: ${{ env.DEP_INSTALL_PREFIX }}
171-
key: ${{ runner.os }}-Python2
172-
173-
- name: CentOS 8 Prerequisites
174-
run: contrib/CI/centos8.sh
175-
176-
- name: Install Python 2
177-
run: yum -y install python2
178-
179-
- name: Configure CMake For Core Tests
180-
run: |
181-
mkdir -p build
182-
cd build
183-
cmake .. ${{ env.COMMON_CONFIG }} -DPYTHON_INTERPRETER=python2
184-
185-
- name: Build
186-
working-directory: ${{ github.workspace }}/build
187-
run: make -j
188-
189-
- name: Test
190-
working-directory: ${{ github.workspace }}/build
191-
run: ctest --output-on-failure
192-
193160
TestDirectory:
194161
needs: [ShellCheck, Pylint]
195162
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,8 @@ else()
206206
message(STATUS "Not compiling C++ sources")
207207
endif()
208208

209-
# Python is required
210-
if (CMAKE_VERSION VERSION_GREATER "3.12.0")
211-
find_package(Python REQUIRED COMPONENTS Interpreter)
212-
else()
213-
find_program(Python NAMES python python3 python2) # REQUIRED option was not added until 3.18
214-
if (NOT Python)
215-
message(FATAL_ERROR "Python not found")
216-
endif()
217-
execute_process(COMMAND ${Python} --version
218-
OUTPUT_VARIABLE Python_VERSION_STDOUT
219-
ERROR_VARIABLE Python_VERSION_STDERR
220-
OUTPUT_STRIP_TRAILING_WHITESPACE
221-
ERROR_STRIP_TRAILING_WHITESPACE)
222-
string(REGEX REPLACE "^Python " "" Python_VERSION "${Python_VERSION_STDOUT}${Python_VERSION_STDERR}")
223-
string(REPLACE "." ";" Python_VERSION_LIST ${Python_VERSION})
224-
list(GET Python_VERSION_LIST 0 Python_VERSION_MAJOR)
225-
message(STATUS "Found Python: ${Python} (found version \"${Python_VERSION}\") found components: Interpreter")
226-
endif()
227-
228-
set(PYTHON_INTERPRETER "python${Python_VERSION_MAJOR}" CACHE STRING "Python Interpreter")
229-
message(STATUS "Using Python Interpreter: ${PYTHON_INTERPRETER}")
209+
# Python3 is required
210+
find_package(Python3 REQUIRED COMPONENTS Interpreter REQUIRED)
230211

231212
# require find_program to return executables with -r+x permissions
232213
if (POLICY CMP0109)
@@ -572,7 +553,7 @@ if (RPMBUILD)
572553
set(CPACK_RPM_PACKAGE_LICENSE "BSD/LANL")
573554
set(CPACK_RPM_PACKAGE_VENDOR "LANL")
574555
set(CPACK_RPM_PACKAGE_URL "https://github.com/mar-file-system/GUFI")
575-
set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, ${PYTHON_INTERPRETER}, coreutils")
556+
set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, python3-pip, coreutils")
576557
set(CPACK_RPM_PACKAGE_RELOCATABLE On)
577558
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${ARCH}")
578559
set(CPACK_RPM_Server_FILE_NAME "gufi-server-${GUFI_VERSION}.${ARCH}.rpm")
@@ -582,7 +563,7 @@ if (RPMBUILD)
582563
if (CLIENT)
583564
set(CPACK_RPM_Client_FILE_NAME "gufi-client-${GUFI_VERSION}.${ARCH}.rpm")
584565
# python libraries are installed through pip, and won't be found by rpm
585-
set(CPACK_RPM_Client_PACKAGE_REQUIRES "${PYTHON_INTERPRETER}, openssh, ${PYTHON_INTERPRETER}-pip")
566+
set(CPACK_RPM_Client_PACKAGE_REQUIRES "python3, python3-pip, openssh")
586567
set(CPACK_RPM_Client_PACKAGE_SUMMARY "GUFI Client RPM")
587568
endif()
588569

contrib/CI/rpms.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ dnf install -y gufi-server-*.rpm
8888
dnf autoremove -y GUFI-Server
8989

9090
# upgrade pip to get the latest Python dependencies
91-
@PYTHON_INTERPRETER@ -m pip install --upgrade pip
91+
python3 -m pip install --upgrade pip
9292

9393
# install the client RPM
9494
dnf install -y gufi-client-*.rpm

contrib/gentrace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

contrib/hashes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

contrib/longitudinal_snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

contrib/trace_anonymizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

docs/latex/sections/dependencies.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ \subsection{System Tools}
103103
\hline
104104
Make & Yes & \\
105105
\hline
106-
Python & Yes & Python 2.7 or Python 3 \\
106+
Python & Yes & Python 3+ \\
107107
\hline
108108
pip & No & Used for installing and client dependencies \\
109109
\hline

scripts/gufi_client

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#
@@ -64,8 +64,8 @@
6464
import subprocess
6565
import sys
6666

67-
if (sys.version_info.major < 3) or ((sys.version_info.major == 3) and sys.version_info.minor < 3):
68-
from pipes import quote as sanitize
67+
if (sys.version_info.major == 3) and (sys.version_info.minor < 3):
68+
from pipes import quote as sanitize # pylint: disable=deprecated-module
6969
else:
7070
from shlex import quote as sanitize # new in Python 3.3
7171

scripts/gufi_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#
@@ -67,7 +67,7 @@
6767
import re
6868
import sys
6969

70-
if (sys.version_info.major < 3) or ((sys.version_info.major == 3) and sys.version_info.minor < 3):
70+
if (sys.version_info.major == 3) and (sys.version_info.minor < 3):
7171
from pipes import quote as sanitize # pylint: disable=deprecated-module
7272
else:
7373
from shlex import quote as sanitize # new in Python 3.3

scripts/gufi_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

scripts/gufi_find

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

scripts/gufi_getfattr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

scripts/gufi_ls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

scripts/gufi_stat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

scripts/gufi_stats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

scripts/querydbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

test/regression/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ configure_file(gufi_tool.py.in gufi_tool.py @ONLY)
145145
configure_file(gufi_vt.common gufi_vt.common @ONLY)
146146

147147
# check for SQLAlchemy and add test if found
148-
execute_process(COMMAND "${PYTHON_INTERPRETER}" -c "import sqlalchemy"
148+
execute_process(COMMAND python3 -c "import sqlalchemy"
149149
RESULT_VARIABLE SQLALCHEMY_RC
150150
OUTPUT_QUIET ERROR_QUIET)
151151
if (SQLALCHEMY_RC EQUAL 0)
@@ -158,7 +158,7 @@ if (SQLALCHEMY_RC EQUAL 0)
158158
configure_file(gufi_vt_sqlalchemy.py.in gufi_vt_sqlalchemy.py @ONLY)
159159

160160
# check for pugsql and add test if found
161-
execute_process(COMMAND "${PYTHON_INTERPRETER}" -c "import pugsql"
161+
execute_process(COMMAND python3 -c "import pugsql"
162162
RESULT_VARIABLE PUGSQL_RC
163163
OUTPUT_QUIET ERROR_QUIET)
164164
if (PUGSQL_RC EQUAL 0)

test/regression/gufi_tool.py.in

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#
@@ -86,25 +86,18 @@ TOOLS = {
8686
# import a tool by path (default: the scripts directory)
8787
# needed for duplicate filenames or files without the .py extension
8888
def import_tool(tool, filename):
89-
if sys.version_info.major < 3: # pylint: disable=no-else-return
90-
import imp # pylint: disable=deprecated-module,import-outside-toplevel
91-
92-
return imp.load_source(tool, filename)
9389
# https://csatlas.com/python-import-file-module/
94-
elif sys.version_info.major >= 3:
95-
# pylint: disable=import-outside-toplevel
96-
import importlib.machinery
97-
import importlib.util
98-
from pathlib import Path
99-
100-
# Import mymodule
101-
loader = importlib.machinery.SourceFileLoader(tool, filename)
102-
spec = importlib.util.spec_from_loader(tool, loader)
103-
script = importlib.util.module_from_spec(spec)
104-
loader.exec_module(script)
105-
return script
90+
# pylint: disable=import-outside-toplevel
91+
import importlib.machinery
92+
import importlib.util
93+
from pathlib import Path
10694

107-
return None
95+
# Import mymodule
96+
loader = importlib.machinery.SourceFileLoader(tool, filename)
97+
spec = importlib.util.spec_from_loader(tool, loader)
98+
script = importlib.util.module_from_spec(spec)
99+
loader.exec_module(script)
100+
return script
108101

109102
if __name__ == '__main__':
110103
parser = argparse.ArgumentParser(description='GUFI Testing Tool Selector', add_help=False)

test/regression/gufi_vt_pugsql.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

test/regression/gufi_vt_sqlalchemy.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

test/regression/hexlify.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

test/regression/setup.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ PWD="$(pwd)"
187187

188188
# generate a fake config file
189189
# shellcheck disable=SC2046
190-
CONFIG="$(@PYTHON_INTERPRETER@ -c 'import gufi_tool, os; print(os.path.realpath(gufi_tool.CONFIG_PATH))')"
190+
CONFIG="$(python3 -c 'import gufi_tool, os; print(os.path.realpath(gufi_tool.CONFIG_PATH))')"
191191
(
192192
echo "Threads=1"
193193
echo "Query=${GUFI_QUERY}"

test/unit/python/test_gufi_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

test/unit/python/test_gufi_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env @PYTHON_INTERPRETER@
1+
#!/usr/bin/env python3
22
# This file is part of GUFI, which is part of MarFS, which is released
33
# under the BSD license.
44
#

0 commit comments

Comments
 (0)