提交 fe50ef92 authored 作者: abalkin's avatar abalkin

More python 3.x fixes:

* Suppress 2to3's "next" fixer that conflicts with having non-iterator attributes called "next." Rely on six.next instead. * added python 3 version of hash_from_code.
上级 5704378e
...@@ -14,6 +14,10 @@ try: ...@@ -14,6 +14,10 @@ try:
except ImportError: except ImportError:
from distutils.core import setup from distutils.core import setup
try: try:
from distutils.util import Mixin2to3
from lib2to3.refactor import get_fixers_from_package
Mixin2to3.fixer_names = [f for f in get_fixers_from_package('lib2to3.fixes')
if f != 'lib2to3.fixes.fix_next']
from distutils.command.build_py import build_py_2to3 \ from distutils.command.build_py import build_py_2to3 \
as build_py as build_py
from distutils.command.build_scripts import build_scripts_2to3 \ from distutils.command.build_scripts import build_scripts_2to3 \
......
...@@ -13,8 +13,13 @@ from itertools import izip ...@@ -13,8 +13,13 @@ from itertools import izip
import numpy import numpy
if sys.version_info[:2] >= (3, 0):
import hashlib
def hash_from_code(msg):
return hashlib.md5(msg.encode()).hexdigest()
if sys.version_info[:2] >= (2, 5): elif sys.version_info[:2] >= (2, 5):
import hashlib import hashlib
def hash_from_code(msg): def hash_from_code(msg):
......
...@@ -13,7 +13,7 @@ import subprocess ...@@ -13,7 +13,7 @@ import subprocess
import sys import sys
import tempfile import tempfile
import time import time
from six import b from six import b, next
import distutils.sysconfig import distutils.sysconfig
...@@ -918,7 +918,7 @@ class ModuleCache(object): ...@@ -918,7 +918,7 @@ class ModuleCache(object):
# If we do, then there is no need to even compile it. # If we do, then there is no need to even compile it.
duplicated_module = False duplicated_module = False
# The first compilation step is to yield the source code. # The first compilation step is to yield the source code.
src_code = compile_steps.next() src_code = next(compile_steps)
module_hash = get_module_hash(src_code, key) module_hash = get_module_hash(src_code, key)
# The op has c_code, so take the lock. # The op has c_code, so take the lock.
...@@ -973,7 +973,7 @@ class ModuleCache(object): ...@@ -973,7 +973,7 @@ class ModuleCache(object):
try: try:
# The module should be returned by the last # The module should be returned by the last
# step of the compilation. # step of the compilation.
module = compile_steps.next() module = next(compile_steps)
except StopIteration: except StopIteration:
break break
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论