python: drop python2 support

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3674>
This commit is contained in:
Eric Engestrom 2020-02-02 18:25:47 +00:00 committed by Marge Bot
parent dac09a3119
commit f1eae2f8bb
63 changed files with 10 additions and 144 deletions

View File

@ -22,7 +22,6 @@
"""Script to install megadriver symlinks for meson.""" """Script to install megadriver symlinks for meson."""
from __future__ import print_function
import argparse import argparse
import os import os

View File

@ -20,7 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
from __future__ import print_function
import os import os

View File

@ -24,8 +24,6 @@
Script that generates the mapping from Gallium PIPE_FORMAT_xxx to GFX10_FORMAT_xxx enums. Script that generates the mapping from Gallium PIPE_FORMAT_xxx to GFX10_FORMAT_xxx enums.
""" """
from __future__ import absolute_import, division, print_function, unicode_literals
import json import json
import mako.template import mako.template
import os import os

View File

@ -1,5 +1,3 @@
from __future__ import print_function, division, unicode_literals
CopyRight = ''' CopyRight = '''
/* /*
* Copyright 2015-2019 Advanced Micro Devices, Inc. * Copyright 2015-2019 Advanced Micro Devices, Inc.

View File

@ -33,8 +33,6 @@ Notes about deduced register types as well as the output JSON are printed on
stdout. stdout.
""" """
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import defaultdict from collections import defaultdict
import json import json
import re import re

View File

@ -1,5 +1,3 @@
from __future__ import absolute_import, division, print_function, unicode_literals
COPYRIGHT = ''' COPYRIGHT = '''
/* /*
* Copyright 2015-2019 Advanced Micro Devices, Inc. * Copyright 2015-2019 Advanced Micro Devices, Inc.

View File

@ -28,8 +28,6 @@ Helper script to merge register database JSON files.
Will merge the given JSON files and output the result on stdout. Will merge the given JSON files and output the result on stdout.
""" """
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import defaultdict from collections import defaultdict
import json import json
import re import re

View File

@ -30,8 +30,6 @@ This script is included for reference -- we should be able to remove this in
the future. the future.
""" """
from __future__ import absolute_import, division, print_function, unicode_literals
import json import json
import math import math
import re import re

View File

@ -24,8 +24,6 @@
Python package containing common tools for manipulating register JSON. Python package containing common tools for manipulating register JSON.
""" """
from __future__ import absolute_import, division, print_function, unicode_literals
import itertools import itertools
import json import json
import re import re

View File

@ -22,9 +22,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import xml.parsers.expat import xml.parsers.expat
import re import re
import sys import sys

View File

@ -21,7 +21,6 @@
"""Run glcpp tests with various line endings.""" """Run glcpp tests with various line endings."""
from __future__ import print_function
import argparse import argparse
import difflib import difflib
import errno import errno

View File

@ -19,7 +19,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
from __future__ import print_function
import sys import sys
import subprocess import subprocess
import tempfile import tempfile

View File

@ -21,7 +21,6 @@
"""Script to generate and run glsl optimization tests.""" """Script to generate and run glsl optimization tests."""
from __future__ import print_function
import argparse import argparse
import difflib import difflib
import errno import errno

View File

@ -29,10 +29,6 @@
import re import re
import sys import sys
if sys.version_info >= (3, 0, 0):
STRING_TYPE = str
else:
STRING_TYPE = unicode
def check_sexp(sexp): def check_sexp(sexp):
"""Verify that the argument is a proper sexp. """Verify that the argument is a proper sexp.
@ -44,7 +40,7 @@ def check_sexp(sexp):
if isinstance(sexp, list): if isinstance(sexp, list):
for s in sexp: for s in sexp:
check_sexp(s) check_sexp(s)
elif not isinstance(sexp, (STRING_TYPE, bytes)): elif not isinstance(sexp, (str, bytes)):
raise Exception('Not a sexp: {0!r}'.format(sexp)) raise Exception('Not a sexp: {0!r}'.format(sexp))
def parse_sexp(sexp): def parse_sexp(sexp):
@ -75,7 +71,7 @@ def sexp_to_string(sexp):
"""Convert a sexp, represented as nested lists containing strings, """Convert a sexp, represented as nested lists containing strings,
into a single string of the form parseable by mesa. into a single string of the form parseable by mesa.
""" """
if isinstance(sexp, STRING_TYPE): if isinstance(sexp, str):
return sexp return sexp
if isinstance(sexp, bytes): if isinstance(sexp, bytes):
return sexp.encode('utf-8') return sexp.encode('utf-8')

View File

@ -19,7 +19,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
from __future__ import print_function
import argparse import argparse
import errno import errno
import os import os

View File

@ -23,7 +23,6 @@
# Authors: # Authors:
# Jason Ekstrand (jason@jlekstrand.net) # Jason Ekstrand (jason@jlekstrand.net)
from __future__ import print_function
import ast import ast
from collections import defaultdict from collections import defaultdict
import itertools import itertools
@ -60,15 +59,6 @@ def get_c_opcode(op):
else: else:
return 'nir_op_' + op return 'nir_op_' + op
if sys.version_info < (3, 0):
integer_types = (int, long)
string_type = unicode
else:
integer_types = (int, )
string_type = str
_type_re = re.compile(r"(?P<type>int|uint|bool|float)?(?P<bits>\d+)?") _type_re = re.compile(r"(?P<type>int|uint|bool|float)?(?P<bits>\d+)?")
def type_bits(type_str): def type_bits(type_str):
@ -107,9 +97,9 @@ class Value(object):
return Expression(val, name_base, varset) return Expression(val, name_base, varset)
elif isinstance(val, Expression): elif isinstance(val, Expression):
return val return val
elif isinstance(val, string_type): elif isinstance(val, str):
return Variable(val, name_base, varset) return Variable(val, name_base, varset)
elif isinstance(val, (bool, float) + integer_types): elif isinstance(val, (bool, float, int)):
return Constant(val, name_base) return Constant(val, name_base)
def __init__(self, val, name, type_str): def __init__(self, val, name, type_str):
@ -246,7 +236,7 @@ class Constant(Value):
def hex(self): def hex(self):
if isinstance(self.value, (bool)): if isinstance(self.value, (bool)):
return 'NIR_TRUE' if self.value else 'NIR_FALSE' return 'NIR_TRUE' if self.value else 'NIR_FALSE'
if isinstance(self.value, integer_types): if isinstance(self.value, int):
return hex(self.value) return hex(self.value)
elif isinstance(self.value, float): elif isinstance(self.value, float):
i = struct.unpack('Q', struct.pack('d', self.value))[0] i = struct.unpack('Q', struct.pack('d', self.value))[0]
@ -265,7 +255,7 @@ class Constant(Value):
def type(self): def type(self):
if isinstance(self.value, (bool)): if isinstance(self.value, (bool)):
return "nir_type_bool" return "nir_type_bool"
elif isinstance(self.value, integer_types): elif isinstance(self.value, int):
return "nir_type_int" return "nir_type_int"
elif isinstance(self.value, float): elif isinstance(self.value, float):
return "nir_type_float" return "nir_type_float"

View File

@ -1,5 +1,3 @@
from __future__ import print_function
template = """\ template = """\
/* Copyright (C) 2015 Broadcom /* Copyright (C) 2015 Broadcom
* *

View File

@ -1,5 +1,3 @@
from __future__ import print_function
import re import re
from nir_opcodes import opcodes from nir_opcodes import opcodes
from nir_opcodes import type_has_size, type_size, type_sizes, type_base_type from nir_opcodes import type_has_size, type_size, type_sizes, type_base_type

View File

@ -23,8 +23,6 @@
# Authors: # Authors:
# Connor Abbott (cwabbott0@gmail.com) # Connor Abbott (cwabbott0@gmail.com)
from __future__ import print_function
from nir_opcodes import opcodes, type_sizes from nir_opcodes import opcodes, type_sizes
from mako.template import Template from mako.template import Template

View File

@ -1,5 +1,3 @@
from __future__ import print_function
template = """\ template = """\
/* Copyright (C) 2014 Connor Abbott /* Copyright (C) 2014 Connor Abbott
* *

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Jason Ekstrand (jason@jlekstrand.net) # Jason Ekstrand (jason@jlekstrand.net)
from __future__ import print_function
from collections import OrderedDict from collections import OrderedDict
import nir_algebraic import nir_algebraic
from nir_opcodes import type_sizes from nir_opcodes import type_sizes

View File

@ -20,8 +20,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import print_function
import argparse import argparse
import sys import sys

View File

@ -20,8 +20,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import print_function
import argparse import argparse
import sys import sys

View File

@ -1,5 +1,3 @@
from __future__ import print_function
copyright = ''' copyright = '''
/* /*
* Copyright 2009 VMware, Inc. * Copyright 2009 VMware, Inc.

View File

@ -1,5 +1,3 @@
from __future__ import print_function
copyright = ''' copyright = '''
/* /*
* Copyright 2009 VMware, Inc. * Copyright 2009 VMware, Inc.

View File

@ -1,5 +1,3 @@
from __future__ import print_function
CopyRight = ''' CopyRight = '''
/* /*
* Copyright 2015 Advanced Micro Devices, Inc. * Copyright 2015 Advanced Micro Devices, Inc.

View File

@ -20,7 +20,6 @@
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Python source # Python source
from __future__ import print_function
import os import os
import sys import sys
import re import re

View File

@ -20,9 +20,7 @@
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Python source # Python source
# Compatible with Python2.X and Python3.X
from __future__ import print_function
import itertools import itertools
import os import os
import sys import sys

View File

@ -20,7 +20,6 @@
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Python source # Python source
from __future__ import print_function
import os import os
import errno import errno
import sys import sys

View File

@ -20,7 +20,6 @@
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Python source # Python source
from __future__ import print_function
import os import os
import sys import sys
import knob_defs import knob_defs

View File

@ -19,7 +19,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import print_function
import os, sys, re import os, sys, re
from gen_common import * from gen_common import *
from argparse import FileType from argparse import FileType

View File

@ -19,7 +19,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import print_function
import os, sys, re import os, sys, re
from gen_common import * from gen_common import *
from argparse import FileType from argparse import FileType

View File

@ -31,8 +31,6 @@
# amplitude slightly. Apparently this also minimizes the error function, # amplitude slightly. Apparently this also minimizes the error function,
# reducing the maximum error from 0.00006 to about 0.00003. # reducing the maximum error from 0.00006 to about 0.00003.
from __future__ import print_function
import argparse import argparse
import sys import sys

View File

@ -19,10 +19,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import argparse import argparse
import os import os
import xml.parsers.expat import xml.parsers.expat

View File

@ -1,8 +1,5 @@
#encoding=utf-8 #encoding=utf-8
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import argparse import argparse
import ast import ast
import xml.parsers.expat import xml.parsers.expat

View File

@ -22,7 +22,6 @@
# IN THE SOFTWARE. # IN THE SOFTWARE.
# #
from __future__ import print_function
import sys import sys
import zlib import zlib
import xml.etree.ElementTree as et import xml.etree.ElementTree as et

View File

@ -21,18 +21,14 @@
"""Generates isl_format_layout.c.""" """Generates isl_format_layout.c."""
from __future__ import absolute_import, division, print_function
import argparse import argparse
import csv import csv
import re import re
from mako import template from mako import template
# Load the template, ensure that __future__.division is imported, and set the # Load the template and set the bytes encoding to be utf-8.
# bytes encoding to be utf-8. This last bit is important to getting simple TEMPLATE = template.Template(output_encoding='utf-8',
# consistent behavior for python 3 when we get there.
TEMPLATE = template.Template(future_imports=['division'],
output_encoding='utf-8',
text="""\ text="""\
/* This file is autogenerated by gen_format_layout.py. DO NOT EDIT! */ /* This file is autogenerated by gen_format_layout.py. DO NOT EDIT! */

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import gl_XML, glX_XML import gl_XML, glX_XML

View File

@ -26,8 +26,6 @@
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
# Jeremy Kolb <jkolb@brandeis.edu> # Jeremy Kolb <jkolb@brandeis.edu>
from __future__ import division, print_function
import argparse import argparse
import gl_XML, glX_XML, glX_proto_common, license import gl_XML, glX_XML, glX_proto_common, license

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import sys, string import sys, string

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import license import license

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
from collections import OrderedDict from collections import OrderedDict
from decimal import Decimal from decimal import Decimal
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import gl_XML, glX_XML import gl_XML, glX_XML

View File

@ -25,8 +25,6 @@
# Authors: # Authors:
# Zack Rusin <zack@kde.org> # Zack Rusin <zack@kde.org>
from __future__ import print_function
import argparse import argparse
import license import license

View File

@ -24,8 +24,6 @@
# _mesa_initialize_exec_table(). It is responsible for populating all # _mesa_initialize_exec_table(). It is responsible for populating all
# entries in the "exec" dispatch table that aren't dynamic. # entries in the "exec" dispatch table that aren't dynamic.
from __future__ import print_function
import argparse import argparse
import collections import collections
import license import license

View File

@ -29,8 +29,6 @@
# Based on code ogiginally by: # Based on code ogiginally by:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import license import license

View File

@ -20,8 +20,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import print_function
import contextlib import contextlib
import getopt import getopt
import gl_XML import gl_XML

View File

@ -20,8 +20,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import print_function
import getopt import getopt
import gl_XML import gl_XML
import license import license

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import license import license

View File

@ -25,8 +25,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import gl_XML import gl_XML

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import copy import copy

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import argparse import argparse
import license import license

View File

@ -23,8 +23,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
from __future__ import print_function
import argparse import argparse
import license import license

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Ian Romanick <idr@us.ibm.com> # Ian Romanick <idr@us.ibm.com>
from __future__ import print_function
import copy import copy
class type_node(object): class type_node(object):

View File

@ -24,8 +24,6 @@
# Authors: # Authors:
# Chia-I Wu <olv@lunarg.com> # Chia-I Wu <olv@lunarg.com>
from __future__ import print_function
import sys import sys
# make it possible to import glapi # make it possible to import glapi
import os import os

View File

@ -21,8 +21,6 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import division, print_function
import format_parser as parser import format_parser as parser
import sys import sys

View File

@ -28,8 +28,6 @@
# Generate a C header file containing hash tables of glGet parameter # Generate a C header file containing hash tables of glGet parameter
# names for each GL API. The generated file is to be included by glGet.c # names for each GL API. The generated file is to be included by glGet.c
from __future__ import print_function
import os, sys, getopt import os, sys, getopt
from collections import defaultdict from collections import defaultdict
import get_hash_params import get_hash_params

View File

@ -35,20 +35,11 @@
*/ */
''' '''
from __future__ import division, print_function
import sys import sys
from u_format_parse import * from u_format_parse import *
if sys.version_info < (3, 0):
integer_types = (int, long)
else:
integer_types = (int, )
def inv_swizzles(swizzles): def inv_swizzles(swizzles):
'''Return an array[4] of inverse swizzle terms''' '''Return an array[4] of inverse swizzle terms'''
'''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha''' '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
@ -220,7 +211,7 @@ def truncate_mantissa(x, bits):
'''Truncate an integer so it can be represented exactly with a floating '''Truncate an integer so it can be represented exactly with a floating
point mantissa''' point mantissa'''
assert isinstance(x, integer_types) assert isinstance(x, int)
s = 1 s = 1
if x < 0: if x < 0:
@ -244,7 +235,7 @@ def value_to_native(type, value):
'''Get the value of unity for this type.''' '''Get the value of unity for this type.'''
if type.type == FLOAT: if type.type == FLOAT:
if type.size <= 32 \ if type.size <= 32 \
and isinstance(value, integer_types): and isinstance(value, int):
return truncate_mantissa(value, 23) return truncate_mantissa(value, 23)
return value return value
if type.type == FIXED: if type.type == FIXED:

View File

@ -29,7 +29,6 @@
''' '''
from __future__ import division
import copy import copy
VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5) VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)

View File

@ -1,5 +1,3 @@
from __future__ import print_function
CopyRight = ''' CopyRight = '''
/************************************************************************** /**************************************************************************
* *

View File

@ -1,5 +1,3 @@
from __future__ import print_function
CopyRight = ''' CopyRight = '''
/************************************************************************** /**************************************************************************
* *

View File

@ -22,7 +22,6 @@
# Converts a file to a C/C++ #include containing a string # Converts a file to a C/C++ #include containing a string
from __future__ import unicode_literals
import argparse import argparse
import io import io
import os import os

View File

@ -21,7 +21,6 @@
"""Create enum to string functions for vulkan using vk.xml.""" """Create enum to string functions for vulkan using vk.xml."""
from __future__ import print_function
import argparse import argparse
import os import os
import textwrap import textwrap