Skip to content
Snippets Groups Projects
Commit f19be804 authored by Nguyen Anh Quynh's avatar Nguyen Anh Quynh
Browse files

python: PyPi setup

parent ae94ae9e
No related branches found
No related tags found
No related merge requests found
...@@ -20,3 +20,4 @@ build*/ ...@@ -20,3 +20,4 @@ build*/
samples/sample samples/sample
_sample*.txt _sample*.txt
tmp tmp
MANIFEST
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.
[metadata]
description-file = README.pypi-src
...@@ -19,12 +19,12 @@ from distutils.sysconfig import get_python_lib ...@@ -19,12 +19,12 @@ from distutils.sysconfig import get_python_lib
PATH_LIB64 = "prebuilt/win64/keystone.dll" PATH_LIB64 = "prebuilt/win64/keystone.dll"
PATH_LIB32 = "prebuilt/win32/keystone.dll" PATH_LIB32 = "prebuilt/win32/keystone.dll"
# package name can be 'keystone' or 'keystone-windows' # package name can be 'keystone-engine' or 'keystone-engine-windows'
PKG_NAME = 'keystone' PKG_NAME = 'keystone-engine'
if os.path.exists(PATH_LIB64) and os.path.exists(PATH_LIB32): 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 SYSTEM = sys.platform
# virtualenv breaks import, but get_python_lib() will work. # virtualenv breaks import, but get_python_lib() will work.
...@@ -55,7 +55,7 @@ def copy_sources(): ...@@ -55,7 +55,7 @@ def copy_sources():
except (IOError, OSError): except (IOError, OSError):
pass pass
dir_util.copy_tree("../../arch", "src/arch/") dir_util.copy_tree("../../llvm", "src/llvm/")
dir_util.copy_tree("../../include", "src/include/") dir_util.copy_tree("../../include", "src/include/")
src.extend(glob.glob("../../*.h")) src.extend(glob.glob("../../*.h"))
...@@ -63,12 +63,20 @@ def copy_sources(): ...@@ -63,12 +63,20 @@ def copy_sources():
src.extend(glob.glob("../../*.inc")) src.extend(glob.glob("../../*.inc"))
src.extend(glob.glob("../../*.def")) 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("../../*.TXT")) src.extend(glob.glob("../../*.TXT"))
src.extend(glob.glob("../../COPYING"))
src.extend(glob.glob("../../LICENSE*")) src.extend(glob.glob("../../LICENSE*"))
src.extend(glob.glob("../../EXCEPTIONS-CLIENT"))
src.extend(glob.glob("../../README.md")) src.extend(glob.glob("../../README.md"))
src.extend(glob.glob("../../RELEASE_NOTES")) 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: for filename in src:
outpath = os.path.join("./src/", os.path.basename(filename)) outpath = os.path.join("./src/", os.path.basename(filename))
...@@ -125,7 +133,10 @@ class custom_build_clib(build_clib): ...@@ -125,7 +133,10 @@ class custom_build_clib(build_clib):
for (lib_name, build_info) in libraries: for (lib_name, build_info) in libraries:
log.info("building '%s' library", lib_name) log.info("building '%s' library", lib_name)
# cd src/build
os.chdir("src") os.chdir("src")
os.mkdir("build")
os.chdir("build")
# platform description refers at https://docs.python.org/2/library/sys.html#sys.platform # platform description refers at https://docs.python.org/2/library/sys.html#sys.platform
if SYSTEM == "cygwin": if SYSTEM == "cygwin":
...@@ -134,16 +145,17 @@ class custom_build_clib(build_clib): ...@@ -134,16 +145,17 @@ class custom_build_clib(build_clib):
os.system("KEYSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw64") os.system("KEYSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw64")
else: else:
os.system("KEYSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw32") 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 else: # Unix
os.chmod("make.sh", stat.S_IREAD|stat.S_IEXEC) os.chmod("../make-share.sh", stat.S_IREAD|stat.S_IEXEC)
os.system("KEYSTONE_BUILD_CORE_ONLY=yes ./make.sh") os.system("../make-share.sh lib_only")
if SYSTEM == "darwin": if SYSTEM == "darwin":
SETUP_DATA_FILES.append("src/libkeystone.dylib") SETUP_DATA_FILES.append("src/build/llvm/lib/libkeystone.dylib")
else: # Non-OSX 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: except:
pass pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment