Merge pull request #4858 from sloriot/Doc-fix_filter_script_for_python3

Python 3 doc build compatibility
This commit is contained in:
Laurent Rineau 2020-07-22 16:54:41 +02:00
commit 88a3aab077
3 changed files with 11 additions and 23 deletions

View File

@ -1,9 +1,3 @@
#!/bin/sh
if which python2 2>/dev/null >/dev/null; then
exec python2 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1"
elif which python2.7 2>/dev/null >/dev/null; then
exec python2.7 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1"
elif which python2.6 2>/dev/null >/dev/null; then
exec python2.6 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1"
fi
exec ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1"

View File

@ -1,18 +1,6 @@
@echo off
@where /q python
if not errorlevel 1 ( set python=python )
@where /q python2
if not errorlevel 1 ( set python=python2 )
@where /q python2.6
if not errorlevel 1 ( set python=python2.6 )
@where /q python2.7
if not errorlevel 1 ( set python=python2.7 )
:go
%python% ${CMAKE_BINARY_DIR}/pkglist_filter.py %1
${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/pkglist_filter.py %1
@echo on

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import codecs
import re
@ -28,10 +28,16 @@ def main(argv):
for l in pkgdesc:
do_print = do_print or re.match(".*cgalPkgDescriptionBegin.*", l)
if(do_print):
sys.stdout.write(l.encode('utf-8'))
if hasattr(sys.stdout, 'buffer'):
sys.stdout.buffer.write(l.encode('utf-8')) #python3
else:
sys.stdout.write(l.encode('utf-8')) #python2
do_print = do_print and (not re.match(".*cgalPkgDescriptionEnd.*", l))
else:
sys.stdout.write(line.encode('utf-8'))
if hasattr(sys.stdout, 'buffer'):
sys.stdout.buffer.write(line.encode('utf-8')) #python3
else:
sys.stdout.write(line.encode('utf-8')) #python2
if __name__ == "__main__":
main(sys.argv)