if sys.hexversion<0x206000f:
raise ImportError('Python >= 2.6 is required to create the waf file')
-WAF='waf'
+WAF='waf3'
def b(x):
- return x
-if sys.hexversion>0x300000f:
- WAF='waf3'
- def b(x):
- return x.encode()
+ return x.encode()
def err(m):
print(('\033[91mError: %s\033[0m' % m))
for x in ('Tools', 'extras'):
os.chmod(join('waflib',x), 493)
- if sys.hexversion<0x300000f:
- sys.path = [join(dir, 'waflib')] + sys.path
- import fixpy2
- fixpy2.fixdir(dir)
-
os.remove(tmp)
os.chdir(cwd)
# TODO: make this a --option
LIB_PATH="shared"
-
-PY3 = sys.version_info[0] == 3
-
-if PY3:
-
- # helper function to get a string from a variable that maybe 'str' or
- # 'bytes' if 'bytes' then it is decoded using 'utf8'. If 'str' is passed
- # it is returned unchanged
- # Using this function is PY2/PY3 code should ensure in most cases
- # the PY2 code runs unchanged in PY2 whereas the code in PY3 possibly
- # decodes the variable (see PY2 implementation of this function below)
- def get_string(bytesorstring):
- tmp = bytesorstring
- if isinstance(bytesorstring, bytes):
- tmp = bytesorstring.decode('utf8')
- elif not isinstance(bytesorstring, str):
- raise ValueError('Expected byte of string for %s:%s' % (type(bytesorstring), bytesorstring))
- return tmp
-
-else:
-
- # Helper function to return string.
- # if 'str' or 'unicode' passed in they are returned unchanged
- # otherwise an exception is generated
- # Using this function is PY2/PY3 code should ensure in most cases
- # the PY2 code runs unchanged in PY2 whereas the code in PY3 possibly
- # decodes the variable (see PY3 implementation of this function above)
- def get_string(bytesorstring):
- tmp = bytesorstring
- if not(isinstance(bytesorstring, str) or isinstance(bytesorstring, unicode)):
- raise ValueError('Expected str or unicode for %s:%s' % (type(bytesorstring), bytesorstring))
- return tmp
+# Py3 transition helper function to get a string from a variable that
+# may be 'str' or 'bytes'. If 'bytes' then it is decoded using 'utf8'.
+# If 'str' is passed it is returned unchanged.
+def get_string(bytesorstring):
+ tmp = bytesorstring
+ if isinstance(bytesorstring, bytes):
+ tmp = bytesorstring.decode('utf8')
+ elif not isinstance(bytesorstring, str):
+ raise ValueError('Expected byte of string for %s:%s' % (type(bytesorstring), bytesorstring))
+ return tmp
# sigh, python octal constants are a mess
MODE_644 = int('644', 8)