From f19be804a9c4c72cb73e9513610f225a46ba52b8 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh <aquynh@gmail.com> Date: Thu, 28 Jul 2016 04:30:46 +0800 Subject: [PATCH] python: PyPi setup --- .gitignore | 1 + bindings/python/README.pypi-src | 40 +++++++++++++++++++++++++++++++++ bindings/python/setup.cfg | 2 ++ bindings/python/setup.py | 36 +++++++++++++++++++---------- 4 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 bindings/python/README.pypi-src create mode 100644 bindings/python/setup.cfg diff --git a/.gitignore b/.gitignore index c14decf..68653b6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ build*/ samples/sample _sample*.txt tmp +MANIFEST diff --git a/bindings/python/README.pypi-src b/bindings/python/README.pypi-src new file mode 100644 index 0000000..603dd9d --- /dev/null +++ b/bindings/python/README.pypi-src @@ -0,0 +1,40 @@ +NOTE: This PyPi package "keystone-engine" includes source code of the core of Keystone. +So installing this would also compile the core with C compiler (either "gcc" or +"msvc" on Windows). + +On Windows, CMake & MSVC needs compiler environmental setup, you would need to either +run "pip install keystone-engine" or "python setup.py install" from "Developer Command +Prompt". + +For Windows, if you do not want to compile the core, try the "keystone-engine-windows" +package instead, which already includes the prebuilt "keystone.dll" inside. + + https://pypi.python.org/pypi/keystone-engine-windows + +-------------------------------------------------------------------------------- + +Keystone is a lightweight multi-platform, multi-architecture assembler framework. +It offers some unparalleled features: + +- Multi-architecture, with support for Arm, Arm64 (AArch64/Armv8), Hexagon, Mips, PowerPC, Sparc, SystemZ & X86 (include 16/32/64bit). +- Clean/simple/lightweight/intuitive architecture-neutral API. +- Implemented in C/C++ languages, with bindings for Python, NodeJS, Ruby, Go, Rust, Haskell & OCaml available. +- Native support for Windows & \*nix (with Mac OSX, Linux, *BSD & Solaris confirmed). +- Thread-safe by design. +- Open source - with a dual license. + +Further information is available at http://www.keystone-engine.org + + +[License] + +Keystone is available under a dual license: + +- Version 2 of the GNU General Public License (GPLv2). (I.e. Without the "any later version" clause.). + License information can be found in the COPYING and the EXCEPTIONS-CLIENT. + + This combination allows almost all of open source projects to use Keystone without conflicts. + +- For commercial usage in production environments, contact the authors of Keystone to buy a royalty-free license. + + See LICENSE-COM.TXT for more information. diff --git a/bindings/python/setup.cfg b/bindings/python/setup.cfg new file mode 100644 index 0000000..5e722cb --- /dev/null +++ b/bindings/python/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +description-file = README.pypi-src diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 0764c7e..ca87513 100755 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -19,12 +19,12 @@ from distutils.sysconfig import get_python_lib PATH_LIB64 = "prebuilt/win64/keystone.dll" PATH_LIB32 = "prebuilt/win32/keystone.dll" -# package name can be 'keystone' or 'keystone-windows' -PKG_NAME = 'keystone' +# package name can be 'keystone-engine' or 'keystone-engine-windows' +PKG_NAME = 'keystone-engine' if os.path.exists(PATH_LIB64) and os.path.exists(PATH_LIB32): - PKG_NAME = 'keystone-windows' + PKG_NAME = 'keystone-engine-windows' -VERSION = '0.9' +VERSION = '0.9.1-2' SYSTEM = sys.platform # virtualenv breaks import, but get_python_lib() will work. @@ -55,7 +55,7 @@ def copy_sources(): except (IOError, OSError): pass - dir_util.copy_tree("../../arch", "src/arch/") + dir_util.copy_tree("../../llvm", "src/llvm/") dir_util.copy_tree("../../include", "src/include/") src.extend(glob.glob("../../*.h")) @@ -63,12 +63,20 @@ def copy_sources(): src.extend(glob.glob("../../*.inc")) src.extend(glob.glob("../../*.def")) - src.extend(glob.glob("../../Makefile")) + src.extend(glob.glob("../../CMakeLists.txt")) + src.extend(glob.glob("../../CMakeUninstall.in")) src.extend(glob.glob("../../*.txt")) src.extend(glob.glob("../../*.TXT")) + src.extend(glob.glob("../../COPYING")) src.extend(glob.glob("../../LICENSE*")) + src.extend(glob.glob("../../EXCEPTIONS-CLIENT")) src.extend(glob.glob("../../README.md")) src.extend(glob.glob("../../RELEASE_NOTES")) + src.extend(glob.glob("../../ChangeLog")) + src.extend(glob.glob("../../SPONSORS.TXT")) + src.extend(glob.glob("../../*.cmake")) + src.extend(glob.glob("../../*.sh")) + src.extend(glob.glob("../../*.bat")) for filename in src: outpath = os.path.join("./src/", os.path.basename(filename)) @@ -125,7 +133,10 @@ class custom_build_clib(build_clib): for (lib_name, build_info) in libraries: log.info("building '%s' library", lib_name) + # cd src/build os.chdir("src") + os.mkdir("build") + os.chdir("build") # platform description refers at https://docs.python.org/2/library/sys.html#sys.platform if SYSTEM == "cygwin": @@ -134,16 +145,17 @@ class custom_build_clib(build_clib): os.system("KEYSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw64") else: os.system("KEYSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw32") - SETUP_DATA_FILES.append("src/keystone.dll") + SETUP_DATA_FILES.append("src/build/keystone.dll") else: # Unix - os.chmod("make.sh", stat.S_IREAD|stat.S_IEXEC) - os.system("KEYSTONE_BUILD_CORE_ONLY=yes ./make.sh") + os.chmod("../make-share.sh", stat.S_IREAD|stat.S_IEXEC) + os.system("../make-share.sh lib_only") if SYSTEM == "darwin": - SETUP_DATA_FILES.append("src/libkeystone.dylib") + SETUP_DATA_FILES.append("src/build/llvm/lib/libkeystone.dylib") else: # Non-OSX - SETUP_DATA_FILES.append("src/libkeystone.so") + SETUP_DATA_FILES.append("src/build/llvm/lib/libkeystone.so") - os.chdir("..") + # back to root dir + os.chdir("../..") except: pass -- GitLab