Skip to content

Commit

Permalink
python: PyPi setup
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Jul 27, 2016
1 parent ae94ae9 commit f19be80
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ build*/
samples/sample
_sample*.txt
tmp
MANIFEST
40 changes: 40 additions & 0 deletions bindings/python/README.pypi-src
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions bindings/python/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.pypi-src
36 changes: 24 additions & 12 deletions bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
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.
Expand Down Expand Up @@ -55,20 +55,28 @@ 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"))
src.extend(glob.glob("../../*.cpp"))
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))
Expand Down Expand Up @@ -125,7 +133,10 @@ def build_libraries(self, libraries):
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":
Expand All @@ -134,16 +145,17 @@ def build_libraries(self, libraries):
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

Expand Down

0 comments on commit f19be80

Please sign in to comment.