From 35ceed7b8f05c2bd29afeb98935986b10bc190b5 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 3 Feb 2015 11:45:20 +0800 Subject: [PATCH] python: fix installer --- bindings/python/Makefile | 39 ++++++++++++++++++++---------------- bindings/python/PKG-INFO.win | 14 +++++++++++++ bindings/python/setup.py | 10 ++++++--- 3 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 bindings/python/PKG-INFO.win diff --git a/bindings/python/Makefile b/bindings/python/Makefile index 00265556..0b4d7436 100644 --- a/bindings/python/Makefile +++ b/bindings/python/Makefile @@ -44,34 +44,39 @@ install_cython: mv $(OBJDIR)/build/lib/python/capstone/* capstone cd $(OBJDIR) && python setup_cython.py build -b ./tmp install -# build Python package with source +# build & upload PyPi package with source code of the core sdist: + rm -rf src/ rm -rf prebuilt/win64/*.dll rm -rf prebuilt/win32/*.dll - rm -rf README - mv README.pypi-src README - python setup.py sdist + cp README.pypi-src README + cp PKG-INFO.src PKG-INFO + python setup.py sdist register upload -# build Python package with source +# build & upload PyPi package with source code of the core sdist3: + rm -rf src/ rm -rf prebuilt/win64/*.dll rm -rf prebuilt/win32/*.dll - rm -rf README - mv README.pypi-src README - python3 setup.py sdist + cp README.pypi-src README + cp PKG-INFO.src PKG-INFO + python3 setup.py sdist register upload -# build Python package with prebuilt core -sdist_bin: +# build & upload PyPi package with prebuilt core +# NOTE: be sure to have precompiled core under prebuilt/win*/ beforehand +sdist_win: rm -rf src/ - rm -rf README - mv README.pypi-win README - python setup.py sdist + cp README.pypi-win README + cp PKG-INFO.win PKG-INFO + python setup.py sdist register upload -# build Python package with prebuilt core -sdist3_bin: +# build & upload PyPi package with prebuilt core +# NOTE: be sure to have precompiled core under prebuilt/win*/ beforehand +sdist3_win: rm -rf src/ - mv README.pypi-win README - python3 setup.py sdist + cp README.pypi-win README + cp PKG-INFO.win PKG-INFO + python3 setup.py sdist register upload clean: rm -rf $(OBJDIR) src/ README diff --git a/bindings/python/PKG-INFO.win b/bindings/python/PKG-INFO.win new file mode 100644 index 00000000..4abb92f9 --- /dev/null +++ b/bindings/python/PKG-INFO.win @@ -0,0 +1,14 @@ +Metadata-Version: 1.3 +Name: capstone +Version: 3.0.1 +Author: Nguyen Anh Quynh +Author-email: aquynh at gmail com +Maintainer: Nguyen Anh Quynh +Maintainer-email: aquynh at gmail com +Home-page: http://www.capstone-engine.org +Download-url: www.capstone-engine.org +Summary: Capstone disassembly framework +License: BSD +Description: Capstone is a lightweight multi-platform, multi-architecture disassembly framework with some advanced features. Further information is available at the homepage http://www.capstone-engine.org +Keywords: disassembly reverse binary arm arm64 aarch64 powerpc ppc mips x86 x86_64 sparc systemz xcore +Platform: Windows MacOSX Linux NetBSD FreeBSD OpenBSD Solaris Android iOS diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 95a51cc1..1127f204 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -17,7 +17,11 @@ from distutils.sysconfig import get_python_lib PATH_LIB64 = "prebuilt/win64/capstone.dll" PATH_LIB32 = "prebuilt/win32/capstone.dll" -# platform description refers at https://docs.python.org/2/library/sys.html#sys.platform +# package name can be 'capstone' or 'capstone-win' +PKG_NAME = 'capstone' +if os.path.exists(PATH_LIB64) and os.path.exists(PATH_LIB32): + PKG_NAME = 'capstone-win' + SYSTEM = sys.platform VERSION = '4.0' @@ -68,7 +72,7 @@ class custom_sdist(sdist): def run(self): # if prebuilt libraries are existent, then do not copy source if os.path.exists(PATH_LIB64) and os.path.exists(PATH_LIB32): - return + return sdist.run(self) copy_sources() return sdist.run(self) @@ -146,7 +150,7 @@ def dummy_src(): setup( provides=['capstone'], packages=['capstone'], - name='capstone', + name=PKG_NAME, version=VERSION, author='Nguyen Anh Quynh', author_email='aquynh@gmail.com',