2014-11-12 15:34:11 +08:00
|
|
|
from setuptools import setup
|
|
|
|
from setuptools.dist import Distribution
|
2014-11-06 17:13:23 +08:00
|
|
|
import pkg_resources
|
|
|
|
import argparse
|
2015-04-13 20:08:27 +08:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import zipfile
|
2014-11-06 17:13:23 +08:00
|
|
|
|
2015-04-13 20:08:27 +08:00
|
|
|
_name = "pykd"
|
|
|
|
_desc = "python windbg extension"
|
2015-12-16 15:47:54 +08:00
|
|
|
_version = '0.3.0.36'
|
2014-11-06 17:13:23 +08:00
|
|
|
|
2015-04-13 20:08:27 +08:00
|
|
|
def makeWheel(args):
|
2014-11-06 17:13:23 +08:00
|
|
|
|
2015-04-13 20:08:27 +08:00
|
|
|
# remove build catalog
|
|
|
|
build_dir = os.path.join(os.path.curdir, 'build' )
|
|
|
|
if os.path.exists(build_dir):
|
|
|
|
shutil.rmtree(build_dir)
|
2014-11-12 15:34:11 +08:00
|
|
|
|
2015-04-13 20:08:27 +08:00
|
|
|
# make package catalog
|
|
|
|
package_dir = os.path.join(os.path.curdir, _name )
|
|
|
|
if os.path.exists(package_dir):
|
|
|
|
shutil.rmtree(package_dir)
|
|
|
|
os.mkdir(package_dir)
|
2014-11-12 15:34:11 +08:00
|
|
|
|
2015-04-13 20:08:27 +08:00
|
|
|
with open(os.path.join(package_dir, '__init__.py'),'w') as f:
|
|
|
|
f.write("from pykd import *\n")
|
|
|
|
f.write("__version__ = pykd.__version__\n")
|
|
|
|
f.write("__file__ = pykd.__file__\n")
|
|
|
|
|
|
|
|
bin_dir = os.path.join( os.path.curdir, '..', 'bin')
|
|
|
|
pykd_dir = os.path.join( os.path.curdir, '..', 'out')
|
|
|
|
if args.plat_name == 'win32':
|
|
|
|
bin_dir = os.path.join( bin_dir, 'x86')
|
|
|
|
pykd_dir = os.path.join(pykd_dir, 'Win32', 'Release_2.7')
|
|
|
|
elif args.plat_name == 'win-amd64':
|
|
|
|
bin_dir = os.path.join( bin_dir, 'x64')
|
|
|
|
pykd_dir = os.path.join(pykd_dir, 'X64', 'Release_2.7')
|
|
|
|
else:
|
|
|
|
assert(0)
|
|
|
|
|
|
|
|
assert(os.path.isdir(bin_dir))
|
|
|
|
|
|
|
|
for binFile in [ f for f in os.listdir(bin_dir) if not os.path.isdir(f) ]:
|
|
|
|
shutil.copy( os.path.join(bin_dir, binFile), os.path.join(package_dir, binFile) )
|
|
|
|
|
|
|
|
shutil.copy( os.path.join(pykd_dir, 'pykd.pyd'), os.path.join(package_dir, 'pykd.pyd') )
|
|
|
|
|
|
|
|
class BinaryDistribution(Distribution):
|
|
|
|
def is_pure(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name = _name,
|
|
|
|
version = _version,
|
|
|
|
description = _desc,
|
|
|
|
packages = ['pykd'],
|
|
|
|
package_dir = {'pykd': package_dir},
|
|
|
|
package_data = { 'pykd' :["*.pyd", "*.dll"]},
|
|
|
|
include_package_data=True,
|
|
|
|
zip_safe = False,
|
|
|
|
distclass = BinaryDistribution,
|
|
|
|
)
|
|
|
|
|
|
|
|
def makeZip(args):
|
|
|
|
|
|
|
|
# make package catalog
|
|
|
|
package_dir = os.path.join(os.path.curdir, _name )
|
|
|
|
if os.path.exists(package_dir):
|
|
|
|
shutil.rmtree(package_dir)
|
|
|
|
os.mkdir(package_dir)
|
|
|
|
|
|
|
|
bin_dir = os.path.join( os.path.curdir, '..', 'bin')
|
|
|
|
pykd_dir = os.path.join( os.path.curdir, '..', 'out')
|
|
|
|
if args.plat_name == 'win32':
|
|
|
|
bin_dir = os.path.join( bin_dir, 'x86')
|
|
|
|
pykd_dir = os.path.join(pykd_dir, 'Win32', 'Release_2.7')
|
|
|
|
elif args.plat_name == 'win-amd64':
|
|
|
|
bin_dir = os.path.join( bin_dir, 'x64')
|
|
|
|
pykd_dir = os.path.join(pykd_dir, 'X64', 'Release_2.7')
|
|
|
|
else:
|
|
|
|
assert(0)
|
2014-11-06 17:13:23 +08:00
|
|
|
|
2015-04-15 22:19:04 +08:00
|
|
|
zip_str = "pykd-%s-py27-%s" % ( _version, args.plat_name )
|
2015-04-13 20:08:27 +08:00
|
|
|
zip_name = zip_str + ".zip"
|
|
|
|
|
|
|
|
assert(os.path.isdir(bin_dir))
|
|
|
|
|
|
|
|
for binFile in [ f for f in os.listdir(bin_dir) if not os.path.isdir(f) ]:
|
|
|
|
shutil.copy( os.path.join(bin_dir, binFile), os.path.join(package_dir, binFile) )
|
|
|
|
|
|
|
|
shutil.copy( os.path.join(pykd_dir, 'pykd.pyd'), os.path.join(package_dir, 'pykd.pyd') )
|
|
|
|
|
2015-09-09 22:48:11 +08:00
|
|
|
dist_dir = os.path.join(os.path.curdir, 'dist')
|
|
|
|
if not os.path.exists(dist_dir):
|
|
|
|
os.mkdir(dist_dir)
|
|
|
|
|
2015-04-13 20:08:27 +08:00
|
|
|
with zipfile.ZipFile(os.path.join(os.path.curdir, 'dist', zip_name), mode='w' ) as archive:
|
|
|
|
for srcFile in os.listdir(package_dir):
|
|
|
|
print "zipped %s" % (srcFile)
|
|
|
|
archive.write( os.path.join(package_dir, srcFile), compress_type = zipfile.ZIP_DEFLATED)
|
|
|
|
|
|
|
|
print "OK"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
|
|
|
subparsers = parser.add_subparsers()
|
|
|
|
wheelParser = subparsers.add_parser('bdist_wheel')
|
|
|
|
wheelParser.add_argument('--plat-name', choices = ['win32', 'win-amd64'], default=pkg_resources.get_build_platform() )
|
|
|
|
wheelParser.set_defaults(func=makeWheel)
|
|
|
|
|
|
|
|
zipParser = subparsers.add_parser('bdist_zip')
|
|
|
|
zipParser.add_argument('--plat-name', choices = ['win32', 'win-amd64'], default=pkg_resources.get_build_platform() )
|
|
|
|
zipParser.set_defaults(func=makeZip)
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
args.func(args)
|
2014-11-06 17:13:23 +08:00
|
|
|
|
2014-11-12 15:34:11 +08:00
|
|
|
|