python: make setup.py support pre-built Windows core
diff --git a/bindings/python/PKG-INFO b/bindings/python/PKG-INFO.src
similarity index 100%
rename from bindings/python/PKG-INFO
rename to bindings/python/PKG-INFO.src
diff --git a/bindings/python/prebuilt/win32/capstone.dll b/bindings/python/prebuilt/win32/capstone.dll
deleted file mode 100644
index d987590..0000000
--- a/bindings/python/prebuilt/win32/capstone.dll
+++ /dev/null
Binary files differ
diff --git a/bindings/python/prebuilt/win64/capstone.dll b/bindings/python/prebuilt/win64/capstone.dll
deleted file mode 100644
index d987590..0000000
--- a/bindings/python/prebuilt/win64/capstone.dll
+++ /dev/null
Binary files differ
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 12a1130..e25178a 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -13,6 +13,9 @@
 from distutils.core import setup
 from distutils.sysconfig import get_python_lib
 
+# prebuilt libraries for Windows - for sdist
+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
 SYSTEM = sys.platform
@@ -22,6 +25,10 @@
 
 SETUP_DATA_FILES = []
 
+# adapted from commit e504b81 of Nguyen Tan Cong
+# Reference: https://docs.python.org/2/library/platform.html#cross-platform
+is_64bits = sys.maxsize > 2**32
+
 def copy_sources():
     """Copy the C sources into the source directory.
     This rearranges the source files under the python distribution
@@ -84,6 +91,16 @@
         build_clib.finalize_options(self)
 
     def build_libraries(self, libraries):
+        if SYSTEM == "win32":
+            # if Windows prebuilt library is available, then include it
+            if is_64bits and os.path.exists(PATH_LIB64):
+                SETUP_DATA_FILES.append(PATH_LIB64)
+                return
+            elif os.path.exists(PATH_LIB32):
+                SETUP_DATA_FILES.append(PATH_LIB32)
+                return
+
+        # build library from source if src/ is existent
         if not os.path.exists('src'):
             return
 
diff --git a/bindings/python/setup_prebuilt_windows.py b/bindings/python/setup_prebuilt_windows.py
deleted file mode 100644
index e277d3a..0000000
--- a/bindings/python/setup_prebuilt_windows.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env python
-import os
-import sys
-
-from distutils.core import setup
-from distutils.sysconfig import get_python_lib
-
-
-VERSION = '3.0.1'
-
-# Reference: https://docs.python.org/2/library/platform.html#cross-platform
-is_64bits = sys.maxsize > 2**32
-
-SITE_PACKAGES = os.path.join(get_python_lib(), "capstone")
-
-SETUP_DATA_FILES = []
-
-if is_64bits:
-    SETUP_DATA_FILES.append("prebuilt/win64/capstone.dll")
-else:
-    SETUP_DATA_FILES.append("prebuilt/win32/capstone.dll")
-
-setup(
-    provides=['capstone'],
-    packages=['capstone'],
-    name='capstone',
-    version=VERSION,
-    author='Nguyen Anh Quynh',
-    author_email='aquynh@gmail.com',
-    description='Capstone disassembly engine',
-    url='http://www.capstone-engine.org',
-    classifiers=[
-        'License :: OSI Approved :: BSD License',
-        'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 3',
-    ],
-    data_files=[(SITE_PACKAGES, SETUP_DATA_FILES)],
-)
\ No newline at end of file