Enable absolute imports, true division, & print()

These have no effect in Python 3.x, they are the default. Enabling them
in Python 2.x, enabling them in Python 2.x allows single source
compatiblity.
This commit is contained in:
Alex Willmer 2019-05-10 21:13:32 +01:00
parent 55280a73ee
commit 0f3cadcc3e
17 changed files with 43 additions and 7 deletions

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os import os
import os.path import os.path
import platform import platform
@ -43,9 +46,9 @@ env['prefix'] = os.path.abspath(env['prefix'])
if 'DESTDIR' in env: if 'DESTDIR' in env:
env['DESTDIR'] = os.path.abspath(env['DESTDIR']) env['DESTDIR'] = os.path.abspath(env['DESTDIR'])
if rel_prefix: if rel_prefix:
print >>sys.stderr, '--!!-- You used a relative prefix with a DESTDIR. This is probably not what you' print('--!!-- You used a relative prefix with a DESTDIR. This is probably not what you', file=sys.stderr)
print >>sys.stderr, '--!!-- you want; files will be installed in' print('--!!-- you want; files will be installed in', file=sys.stderr)
print >>sys.stderr, '--!!-- %s' % (calcInstallPath('$prefix'),) print('--!!-- %s' % (calcInstallPath('$prefix'),), file=sys.stderr)
env['libpath'] = calcInstallPath('$prefix', 'lib') env['libpath'] = calcInstallPath('$prefix', 'lib')

View file

@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function
Import('env') Import('env')
example = env.Clone() example = env.Clone()

View file

@ -10,7 +10,7 @@
# base64_sem1.py and base64_sem2.py for examples how to attach appropriate # base64_sem1.py and base64_sem2.py for examples how to attach appropriate
# semantic actions to the grammar. # semantic actions to the grammar.
from __future__ import print_function from __future__ import absolute_import, division, print_function
import sys import sys

View file

@ -13,7 +13,7 @@
# transform the parse tree in small steps in a bottom-up fashion. Compare # transform the parse tree in small steps in a bottom-up fashion. Compare
# base64_sem2.py for an alternative approach using a single top-level action. # base64_sem2.py for an alternative approach using a single top-level action.
from __future__ import print_function from __future__ import absolute_import, division, print_function
import functools import functools
import sys import sys

View file

@ -14,7 +14,7 @@
# for an alternative approach using a fine-grained piece-by-piece # for an alternative approach using a fine-grained piece-by-piece
# transformation. # transformation.
from __future__ import print_function from __future__ import absolute_import, division, print_function
import functools import functools
import sys import sys

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os.path import os.path
Import('env testruns') Import('env testruns')

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os.path import os.path
Import("env libhammer_shared testruns targets") Import("env libhammer_shared testruns targets")

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os.path import os.path
Import("env libhammer_shared testruns targets") Import("env libhammer_shared testruns targets")

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os.path import os.path
Import("env libhammer_shared testruns targets") Import("env libhammer_shared testruns targets")

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os, os.path import os, os.path
Import('env libhammer_shared testruns') Import('env libhammer_shared testruns')

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os, os.path import os, os.path
Import('env libhammer_shared testruns targets') Import('env libhammer_shared testruns targets')

View file

@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function
import unittest import unittest
import hammer as h import hammer as h

View file

@ -1,4 +1,7 @@
# -*- python -*- # -*- python -*-
from __future__ import absolute_import, division, print_function
import os.path import os.path
Import("env libhammer_shared testruns targets") Import("env libhammer_shared testruns targets")

View file

@ -21,4 +21,6 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from csharp import exists, generate from __future__ import absolute_import, division, print_function
from .csharp import exists, generate

View file

@ -30,6 +30,8 @@
# This is an attempt to meld to two based initially on the Microsoft C# tool with amendmnets from the Mono # This is an attempt to meld to two based initially on the Microsoft C# tool with amendmnets from the Mono
# tool. # tool.
from __future__ import absolute_import, division, print_function
import os.path import os.path
import SCons.Builder import SCons.Builder
import SCons.Node.FS import SCons.Node.FS

View file

@ -25,6 +25,8 @@
# This C# Tool for Mono taken from http://www.scons.org/wiki/CsharpBuilder. # This C# Tool for Mono taken from http://www.scons.org/wiki/CsharpBuilder.
from __future__ import absolute_import, division, print_function
import os.path import os.path
import SCons.Builder import SCons.Builder
import SCons.Node.FS import SCons.Node.FS

View file

@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function
from string import Template from string import Template
def replace_action(target, source, env): def replace_action(target, source, env):