build: accept both python 3 and python 2
authorAlexey Sheplyakov <asheplyakov@altlinux.org>
Sun, 23 Aug 2020 07:28:07 +0000 (11:28 +0400)
committerAlexey Sheplyakov <asheplyakov@altlinux.org>
Mon, 24 Aug 2020 12:37:35 +0000 (16:37 +0400)
This makes building GiNaC a bit easier for users of "old" distributions
where python 3 is not installed by default (Ubuntu 16.04), or even not
available (CentOS 7).

Scripts themselves work just fine with python 2.7 and python 3.x, so
only minor changes to CMakeLists.txt are required (autotools scripts
already handle python2/3)

CMakeLists.txt
INSTALL
doc/CMakeLists.txt
ginac/CMakeLists.txt
ginac/function.py [changed mode: 0755->0644]
ginsh/CMakeLists.txt
ginsh/ginsh_fcn_help.py [changed mode: 0755->0644]
ginsh/ginsh_op_help.py
scripts/fixupind.py [changed mode: 0755->0644]
scripts/yaptu.py

index cdb18f092cdecc1222de3daaf94e1deeb5be5d3c..7989df14386a53183b1ee88055ef0496f6046fd2 100644 (file)
@@ -167,6 +167,14 @@ endif()
 
 find_program(MAKEINFO makeinfo)
 find_program(FIG2DEV fig2dev)
+find_program(PYTHON python)
+if (NOT PYTHON)
+       find_program(PYTHON python3)
+endif()
+if (NOT PYTHON)
+       message(FATAL_ERROR "Python version 3 or 2 is required")
+endif()
+
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 add_definitions(-DHAVE_CONFIG_H)
diff --git a/INSTALL b/INSTALL
index 3a0dc2bb3fc3e8b59a3411dda3d54e5b82b93c34..1a0eb81c8db0468a1c3e924d472785e16b023500 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -27,7 +27,8 @@ Known not to work with:
  - GCC < 4.6.0 due to missing C++-11 support
 
 If you install from git, you also need GNU autoconf (>=2.59), automake (>=1.8),
-libtool (>= 1.5), python3, bison (>= 2.3), flex (>= 2.5.33) to be installed.
+libtool (>= 1.5), python (version 2.7 or 3.x), bison (>= 2.3), flex (>= 2.5.33)
+to be installed.
 
 
 INSTALLATION
index 22e300bdd06a41e1cdc26aeb749988522a09a9d8..e42e6bda8d5c38c4ed3f95d950c028e07e95efc3 100644 (file)
@@ -45,7 +45,7 @@ macro(pdflatex_process texfile)
        add_custom_command(
                OUTPUT ${_ind}
                COMMAND ${MAKEINDEX_COMPILER} ${_idx}
-               COMMAND python3 ${_fixupind} ${_idx}
+               COMMAND ${PYTHON} ${_fixupind} ${_idx}
                WORKING_DIRECTORY ${_dirname}
                DEPENDS ${texfile} ${_idx}
                COMMENT "MAKEINDEX ${_basename}.idx")
index 1bad4ce7886b417e5bb42c21b6f6a9de8589c514..07d8530ecae6b3a7ca1a08f0e98d022a6737cbab 100644 (file)
@@ -168,11 +168,11 @@ install(FILES ${ginaclib_public_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/gin
 
 add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/function.h
-       COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy
+       COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy ${CMAKE_CURRENT_SOURCE_DIR}/function.py)
 
 add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/function.cpp
-       COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.cpp ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy
+       COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.cpp ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy
        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy ${CMAKE_CURRENT_SOURCE_DIR}/function.py)
 
old mode 100755 (executable)
new mode 100644 (file)
index 63012a2..f7dc7d4
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+
 # encoding: utf-8
 
 maxargs = 14
index 9f4c0a8f8ea1f4bf659abb16f60b39163ea8ade4..46de38bff386820f0ee32b56a377b34e650073e6 100644 (file)
@@ -40,13 +40,13 @@ endif()
 
 add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_fcn_help.h
-       COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py -o ginsh_fcn_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
+       COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py -o ginsh_fcn_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 
 add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_op_help.h
-       COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py -o ginsh_op_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
+       COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py -o ginsh_op_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 
old mode 100755 (executable)
new mode 100644 (file)
index 1c7ea49..edc675b
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+
 # encoding: utf-8
 # Convert help for ginsh functions from man page to C source
 import sys, re, optparse
index f09325728623d9fa6fbf078ee16c5419e6d06fb0..a38697f1452bc071dddc7476561f6b13879b1bba 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+
 # encoding: utf-8
 # Convert help for ginsh operators from man page to C source
 import sys, re, optparse
old mode 100755 (executable)
new mode 100644 (file)
index ac2c4b9..0e781c0
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+
 # encoding: utf-8
 # TeX Live 2012 seems to dislike files produces by doxygen (1.8.x.y)
 # In particular, makeindex(1) program creates invalid index entries like
@@ -11,7 +11,7 @@ import sys, os, re
 
 def fixupind(fname):
        """ Fix \\hyperpage{NNN_} entries in the ind file @var{fname} """
-       tmpout = fname + '.tmp' 
+       tmpout = fname + '.tmp'
        inp = open(fname)
        out = open(tmpout, 'wt')
        rx = re.compile('(hyperpage)[{]([0-9]+)[_][}]')
index 734d748a02dc6af8dec3e3a8ae4d6de6ec096a6e..bc0d4f85785ccf89538fdb1a8b2eeb90af080b84 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+
 """
 Yet Another Python Templating Utility, Version 1.2, by Alex Martelli.
 Distributed under PSF license (http://docs.python.org/license.html).