Skip to content

Commit c80a3d4

Browse files
authored
Merge pull request #1345 from johnhaddon/python2Begone
Remove Python 2 support
2 parents 2a026fa + 34ff1f9 commit c80a3d4

File tree

77 files changed

+68
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+68
-347
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Breaking Changes
55
----------------
66

7+
- Python : Removed support for Python 2.
78
- Primitive : Changed `variableIndexedView()` return type from `boost::optional` to `std::optional`.
89

910
10.4.x.x (relative to 10.4.7.0)

config/ie/options

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ platform = IEEnv.platform()
6262
compiler = getOption( "COMPILER", None )
6363
compilerVersion = getOption( "COMPILER_VERSION", None )
6464
pythonVersion = getOption( "PYTHON_VERSION", None )
65-
sixVersion = getOption( "SIX_VERSION", "1.14.0" )
6665
targetApp = getOption( "APP", None )
6766

6867

@@ -232,10 +231,7 @@ else :
232231
openEXRPythonModuleDir = os.path.join( "/software", "apps", "openexr", openEXRVersion, platform, compiler, compilerVersion, "python", pythonVersion, "boost", boostVersion, "lib", "python" + pythonVersion, "site-packages" )
233232
openEXRPythonLibDir = os.path.join( "/software", "apps", "openexr", openEXRVersion, platform, compiler, compilerVersion, "python", pythonVersion, "boost", boostVersion, "lib64" )
234233

235-
PYTHONPATH = ":".join( [
236-
os.path.join( "/software", "apps", "six", sixVersion ),
237-
openEXRPythonModuleDir,
238-
] )
234+
PYTHONPATH = openEXRPythonModuleDir
239235

240236
# get the installation locations right
241237
INSTALL_PREFIX = getOption( "INSTALL_PREFIX", os.path.expanduser( "~" ) )

contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import imath
3939
import tempfile
4040
import threading
41-
import six
4241
import threading
4342
import time
4443

@@ -78,7 +77,7 @@ def testConstruction( self ) :
7877

7978
def testNonexistentFile( self ) :
8079

81-
six.assertRaisesRegex( self, RuntimeError, "Unable to open file", IECoreScene.SceneInterface.create, "noExisty.abc", IECore.IndexedIO.OpenMode.Read )
80+
self.assertRaisesRegex( RuntimeError, "Unable to open file", IECoreScene.SceneInterface.create, "noExisty.abc", IECore.IndexedIO.OpenMode.Read )
8281

8382
def testHierarchy( self ) :
8483

@@ -351,8 +350,8 @@ def testMissingArchiveBounds( self ) :
351350

352351
a = IECoreScene.SceneInterface.create( os.path.join( os.path.dirname( __file__ ), "data", "noTopLevelStoredBounds.abc" ), IECore.IndexedIO.OpenMode.Read )
353352
self.assertFalse( a.hasBound() )
354-
six.assertRaisesRegex( self, IECore.Exception, "No stored bounds available", a.boundSampleTime, 0 )
355-
six.assertRaisesRegex( self, IECore.Exception, "No stored bounds available", a.readBoundAtSample, 0 )
353+
self.assertRaisesRegex( IECore.Exception, "No stored bounds available", a.boundSampleTime, 0 )
354+
self.assertRaisesRegex( IECore.Exception, "No stored bounds available", a.readBoundAtSample, 0 )
356355

357356
def testSampleInterval( self ) :
358357

include/IECorePython/UnicodeToStringBinding.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

python/IECore/BasicPreset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
import os
3838
import re
39-
import six
4039

4140
## Implements a Preset to permit values to be saved and restored
4241
## from a Parameterised object. BasicPresets can be created either
@@ -93,7 +92,7 @@ def __init__( self, pathOrDataOrParameterised, rootParameter=None, parameters=()
9392
]
9493
)
9594

96-
if isinstance( pathOrDataOrParameterised, six.string_types ) :
95+
if isinstance( pathOrDataOrParameterised, str ) :
9796

9897
self._cob = pathOrDataOrParameterised
9998

python/IECore/ClassLoader.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@
3838
import os.path
3939
import threading
4040
from fnmatch import fnmatch
41-
42-
import six
43-
if six.PY3 :
44-
import importlib.util
45-
else :
46-
import imp
41+
import importlib.util
4742

4843
from IECore import Msg, msg, SearchPath, warning
4944

@@ -163,13 +158,9 @@ def load( self, name, version = None ) :
163158

164159
moduleName = "IECoreClassLoader" + name.replace( ".", "_" ) + str( version )
165160

166-
if six.PY3 :
167-
spec = importlib.util.spec_from_file_location( moduleName, fileName )
168-
module = importlib.util.module_from_spec( spec )
169-
spec.loader.exec_module( module )
170-
else :
171-
with open( fileName, "r" ) as fileForLoad :
172-
module = imp.load_module( moduleName, fileForLoad, fileName, ( ".py", "r", imp.PY_SOURCE ) )
161+
spec = importlib.util.spec_from_file_location( moduleName, fileName )
162+
module = importlib.util.module_from_spec( spec )
163+
spec.loader.exec_module( module )
173164

174165
if not getattr( module, nameTail, None ) :
175166
raise IOError( "File \"%s\" does not define a class named \"%s\"." % ( fileName, nameTail ) )

python/IECore/ClassVectorParameter.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#
3333
##########################################################################
3434

35-
import six
36-
3735
import IECore
3836

3937
## The ClassVectorParameter is similar to the ClassParameter but instead of holding
@@ -121,7 +119,7 @@ def setClasses( self, classes ) :
121119
# form ( classInstance, className, classVersion ).
122120
def getClass( self, parameterOrParameterName, withClassLoaderArgs=False ) :
123121

124-
if isinstance( parameterOrParameterName, six.string_types ) :
122+
if isinstance( parameterOrParameterName, str ) :
125123
parameterName = parameterOrParameterName
126124
else :
127125
parameterName = parameterOrParameterName.name
@@ -137,7 +135,7 @@ def getClass( self, parameterOrParameterName, withClassLoaderArgs=False ) :
137135
# and setClasses().
138136
def setClass( self, parameterOrParameterName, className, classVersion ) :
139137

140-
if isinstance( parameterOrParameterName, six.string_types ) :
138+
if isinstance( parameterOrParameterName, str ) :
141139
parameterName = parameterOrParameterName
142140
parameter = self.parameter( parameterOrParameterName )
143141
if not parameter :

python/IECore/ConfigLoader.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import os
3737
import os.path
3838
import sys
39-
import six
4039
import traceback
4140
import IECore
4241

@@ -48,7 +47,7 @@
4847
# \ingroup python
4948
def loadConfig( searchPaths, contextDict = {}, raiseExceptions = False, subdirectory = "" ) :
5049

51-
if isinstance( searchPaths, six.string_types ) :
50+
if isinstance( searchPaths, str ) :
5251
searchPaths = IECore.SearchPath( os.environ.get( searchPaths, "" ) )
5352

5453
paths = searchPaths.paths
@@ -74,7 +73,7 @@ def loadConfig( searchPaths, contextDict = {}, raiseExceptions = False, subdirec
7473

7574
try :
7675
with open( fullFileName ) as f :
77-
six.exec_(
76+
exec(
7877
compile( f.read(), fullFileName, "exec" ),
7978
fileContextDict, fileContextDict
8079
)

python/IECore/DataTraits.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#
3333
##########################################################################
3434

35-
import six
3635
import string
3736
import datetime
3837
import imath
@@ -55,7 +54,7 @@ def isSimpleDataType(obj):
5554
if info is None:
5655
return False
5756
# check if the element type a basic python type.
58-
if info[0] in ( bool, float, str ) + six.integer_types :
57+
if info[0] in ( bool, float, str, int ) :
5958
return True
6059
return False
6160

@@ -72,7 +71,7 @@ def isSimpleNumericDataType(obj):
7271
if info is None:
7372
return False
7473
# check if the element type a basic python type.
75-
if info[0] in ( float, ) + six.integer_types :
74+
if info[0] in ( float, int ) :
7675
return True
7776
return False
7877

python/IECore/StringUtil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838
#
3939
# \ingroup python
4040

41-
import six
42-
from six.moves.urllib.parse import quote, unquote
41+
from urllib.parse import quote, unquote
4342
import shlex
43+
import functools
4444

4545
## Returns a new string which is the old string with word wrapping
4646
# performed so that no lines are longer than width.
4747
def wrap( text, width ) :
4848

4949
# i got this off the internet. i suspect it might not be very fast
5050
# for a lot of text.
51-
return six.moves.reduce(lambda line, word, width=width: '%s%s%s' %
51+
return functools.reduce(lambda line, word, width=width: '%s%s%s' %
5252
(line,
5353
' \n'[(len(line)-line.rfind('\n')-1
5454
+ len(word.split('\n',1)[0]

0 commit comments

Comments
 (0)