diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f4474f7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: python + +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + +branches: + only: + - master + +install: + - wget "http://repo.continuum.io/pkgs/free/linux-64/llvm-3.2-0.tar.bz2" + - tar -xjf llvm-3.2-0.tar.bz2 + - PATH+=":`pwd`/bin" + - export LD_LIBRARY_PATH="`pwd`/lib" + - export LLVM_CONFIG_PATH="`pwd`/bin/llvm-config" + - $LLVM_CONFIG_PATH --cflags # test llvm-config + - export LLVMPY_DYNLINK=1 + - python setup.py install -q + +script: cd ~; python -c "import sys;import llvm;sys.exit(0 if llvm.test() == 0 else 1)" + diff --git a/llpython/byte_control.py b/llpython/byte_control.py index 9df6d5c..acd5a41 100644 --- a/llpython/byte_control.py +++ b/llpython/byte_control.py @@ -1,12 +1,12 @@ #! /usr/bin/env python # ______________________________________________________________________ - +from __future__ import absolute_import import opcode -import opcode_util +from . import opcode_util import pprint -from bytecode_visitor import BasicBlockVisitor, BenignBytecodeVisitorMixin -from control_flow import ControlFlowGraph +from .bytecode_visitor import BasicBlockVisitor, BenignBytecodeVisitorMixin +from .control_flow import ControlFlowGraph # ______________________________________________________________________ diff --git a/llpython/byte_flow.py b/llpython/byte_flow.py index 4a878b2..2201791 100644 --- a/llpython/byte_flow.py +++ b/llpython/byte_flow.py @@ -1,11 +1,11 @@ #! /usr/bin/env python # ______________________________________________________________________ - +from __future__ import absolute_import import dis import opcode -from bytecode_visitor import BasicBlockVisitor -import opcode_util +from .bytecode_visitor import BasicBlockVisitor +from . import opcode_util # ______________________________________________________________________ diff --git a/llpython/byte_translator.py b/llpython/byte_translator.py index 3922099..9b6d2de 100644 --- a/llpython/byte_translator.py +++ b/llpython/byte_translator.py @@ -4,19 +4,19 @@ ''' # ______________________________________________________________________ # Module imports - +from __future__ import absolute_import import opcode import types import logging import llvm.core as lc -import opcode_util -import bytetype -from bytecode_visitor import BytecodeFlowVisitor -from byte_flow import BytecodeFlowBuilder -from byte_control import ControlFlowBuilder -from phi_injector import PhiInjector, synthetic_opname +from . import opcode_util +from . import bytetype +from .bytecode_visitor import BytecodeFlowVisitor +from .byte_flow import BytecodeFlowBuilder +from .byte_control import ControlFlowBuilder +from .phi_injector import PhiInjector, synthetic_opname # ______________________________________________________________________ # Module data diff --git a/llpython/bytecode_visitor.py b/llpython/bytecode_visitor.py index dcc3a0c..009d1a0 100644 --- a/llpython/bytecode_visitor.py +++ b/llpython/bytecode_visitor.py @@ -1,10 +1,10 @@ #! /usr/bin/env python # ______________________________________________________________________ - +from __future__ import absolute_import import itertools import opcode -from opcode_util import itercode +from .opcode_util import itercode # ______________________________________________________________________ diff --git a/llpython/gen_bytecode_visitor.py b/llpython/gen_bytecode_visitor.py index 7f922e2..b29bc56 100644 --- a/llpython/gen_bytecode_visitor.py +++ b/llpython/gen_bytecode_visitor.py @@ -1,7 +1,7 @@ #! /usr/bin/env python # ______________________________________________________________________ - -import opcode_util +from __future__ import absolute_import +from . import opcode_util # ______________________________________________________________________ diff --git a/llpython/nobitey.py b/llpython/nobitey.py index 014216b..68bde5f 100644 --- a/llpython/nobitey.py +++ b/llpython/nobitey.py @@ -1,6 +1,6 @@ #! /usr/bin/env python # ______________________________________________________________________ - +from __future__ import absolute_import import sys import os.path import imp @@ -10,9 +10,8 @@ import types import llvm.core as lc import llvm.ee as le -import bytetype -import byte_translator -from pyaddfunc import pyaddfunc +from . import bytetype, byte_translator +from .pyaddfunc import pyaddfunc LLVM_TO_INT_PARSE_STR_MAP = { 8 : 'b', diff --git a/llpython/phi_injector.py b/llpython/phi_injector.py index 6cccb66..ee28ab5 100644 --- a/llpython/phi_injector.py +++ b/llpython/phi_injector.py @@ -1,7 +1,7 @@ #! /usr/bin/env python # ______________________________________________________________________ -from bytecode_visitor import BytecodeFlowVisitor, BenignBytecodeVisitorMixin +from .bytecode_visitor import BytecodeFlowVisitor, BenignBytecodeVisitorMixin # ______________________________________________________________________ diff --git a/llvm/__init__.py b/llvm/__init__.py index e3e785f..8f71446 100644 --- a/llvm/__init__.py +++ b/llvm/__init__.py @@ -34,9 +34,11 @@ class LLVMException(Exception): def test(verbosity=1): """test(verbosity=1) -> TextTestResult - Run self-test, and return unittest.runner.TextTestResult object. + Run self-test, and return the number of failures + errors """ from llvm.test_llvmpy import run - return run(verbosity=verbosity) + result = run(verbosity=verbosity) + + return len(result.failures) + len(result.errors) diff --git a/llvm_cbuilder/builder.py b/llvm_cbuilder/builder.py index 9b970f4..648f384 100644 --- a/llvm_cbuilder/builder.py +++ b/llvm_cbuilder/builder.py @@ -14,7 +14,9 @@ from . import shortnames as types ### class FunctionAlreadyExists(NameError): - pass + + def __init__(self, func): + self.func = func def _is_int(ty): return isinstance(ty, lc.IntegerType) @@ -830,7 +832,7 @@ class CDefinition(object): try: func = self.define(module) except FunctionAlreadyExists as e: - (func,) = e + func = e.func return func def __getattr__(self, attr): diff --git a/llvmpy/include/python3adapt.h b/llvmpy/include/python3adapt.h index 5b19ebe..db7f28d 100644 --- a/llvmpy/include/python3adapt.h +++ b/llvmpy/include/python3adapt.h @@ -9,13 +9,10 @@ #define PyBytes_FromStringAndSize PyString_FromStringAndSize #define PyBytes_FromString PyString_FromString -#endif - -#if (PY_VERSION_HEX >= 0x03000000) +#else #define PyString_Check PyUnicode_Check #define PyString_Size PyUnicode_GET_SIZE -#define PyString_AsString PyUnicode_AsUTF8 #define PyString_FromStringAndSize PyUnicode_FromStringAndSize #define PyString_FromString PyUnicode_FromString @@ -27,6 +24,12 @@ #define PyFile_Check(x) (1) +#if (PY_VERSION_HEX < 0x03030000) +#define PyString_AsString _PyUnicode_AsString +#else +#define PyString_AsString PyUnicode_AsUTF8 #endif -#endif //PYTHON3ADAPT_H \ No newline at end of file +#endif // (PY_VERSION_HEX < 0x03000000) + +#endif //PYTHON3ADAPT_H