Skip to content

Commit

Permalink
Cython: update installation and tests to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
danghvu committed Sep 29, 2014
1 parent d7e42b7 commit ebeec9d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 3 additions & 1 deletion bindings/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ install_cython:
cp setup_cython.py $(OBJDIR)
cp pyx/ccapstone* $(OBJDIR)/pyx/
cp capstone/__init__.py $(OBJDIR)/pyx/__init__.py
cp capstone/capstone.py $(OBJDIR)/pyx/capstone.pyx
cp capstone/arm.py $(OBJDIR)/pyx/arm.pyx
cp capstone/arm_const.py $(OBJDIR)/pyx/arm_const.pyx
cp capstone/arm64.py $(OBJDIR)/pyx/arm64.pyx
Expand All @@ -41,7 +40,10 @@ install_cython:
cp capstone/x86_const.py $(OBJDIR)/pyx/x86_const.pyx
cp capstone/xcore.py $(OBJDIR)/pyx/xcore.pyx
cp capstone/xcore_const.py $(OBJDIR)/pyx/xcore_const.pyx
cd $(OBJDIR) && python setup_cython.py build -b ./tmp install --home=$(OBJDIR)
mv $(OBJDIR)/build/lib/python/capstone/* capstone
cd $(OBJDIR) && python setup_cython.py build -b ./tmp install

clean:
rm -rf $(OBJDIR)
rm -f capstone/*.so
6 changes: 3 additions & 3 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_python2 = sys.version_info.major < 3
if _python2:
range = xrange
from capstone import arm, arm64, mips, ppc, sparc, systemz, x86, xcore
from . import arm, arm64, mips, ppc, sparc, systemz, x86, xcore

__all__ = [
'Cs',
Expand Down Expand Up @@ -648,7 +648,7 @@ def __init__(self, arch, mode):
self._detail = False # by default, do not produce instruction details
self._diet = cs_support(CS_SUPPORT_DIET)
self._x86reduce = cs_support(CS_SUPPORT_X86_REDUCE)

# default mnemonic for SKIPDATA
self._skipdata_mnem = ".byte"
self._skipdata = False
Expand Down Expand Up @@ -816,7 +816,7 @@ def disasm_lite(self, code, offset, count=0):
def debug():
# is Cython there?
try:
import ccapstone
from . import ccapstone
return ccapstone.debug()
except:
# no Cython, fallback to Python code below
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/pyx/ccapstone.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cimport pyx.ccapstone as cc
import capstone, ctypes
from capstone import arm, x86, mips, ppc, arm64, sparc, systemz, xcore, CsError
from . import arm, x86, mips, ppc, arm64, sparc, systemz, xcore, CsError

_diet = cc.cs_support(capstone.CS_SUPPORT_DIET)

Expand Down
12 changes: 8 additions & 4 deletions bindings/python/setup_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

compile_args = ['-O3', '-fomit-frame-pointer']

ext_modules = [ Extension("capstone.capstone", ["pyx/capstone.pyx"], extra_compile_args=compile_args),
ext_modules = [
Extension("capstone.ccapstone", ["pyx/ccapstone.pyx"], libraries=["capstone"], extra_compile_args=compile_args),
Extension("capstone.arm", ["pyx/arm.pyx"], extra_compile_args=compile_args),
Extension("capstone.arm_const", ["pyx/arm_const.pyx"], extra_compile_args=compile_args),
Expand All @@ -18,7 +18,11 @@
Extension("capstone.ppc", ["pyx/ppc.pyx"], extra_compile_args=compile_args),
Extension("capstone.ppc_const", ["pyx/ppc_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.x86", ["pyx/x86.pyx"], extra_compile_args=compile_args),
Extension("capstone.x86_const", ["pyx/x86_const.pyx"], extra_compile_args=compile_args)
Extension("capstone.x86_const", ["pyx/x86_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.sparc", ["pyx/sparc.pyx"], extra_compile_args=compile_args),
Extension("capstone.sparc_const", ["pyx/sparc_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.systemz", ["pyx/systemz.pyx"], extra_compile_args=compile_args),
Extension("capstone.sysz_const", ["pyx/sysz_const.pyx"], extra_compile_args=compile_args),
Extension("capstone.xcore", ["pyx/xcore.pyx"], extra_compile_args=compile_args),
Extension("capstone.xcore_const", ["pyx/xcore_const.pyx"], extra_compile_args=compile_args)
]
Expand All @@ -40,8 +44,8 @@
packages = ['capstone'],
name = 'capstone',
version = VERSION,
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules,
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules,
author = 'Nguyen Anh Quynh',
author_email = '[email protected]',
description = 'Capstone disassembly engine',
Expand Down
1 change: 0 additions & 1 deletion bindings/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
(CS_ARCH_XCORE, 0, XCORE_CODE, "XCore", 0),
)


# ## Test cs_disasm_quick()
def test_cs_disasm_quick():
for arch, mode, code, comment, syntax in all_tests:
Expand Down

0 comments on commit ebeec9d

Please sign in to comment.