pykd

Форк
0
/
setup.py 
128 строк · 4.3 Кб
1
from setuptools import setup
2
from wheel.bdist_wheel import bdist_wheel
3

4
import os
5
import shutil
6
import zipfile
7
import sys
8
import itertools
9

10
_name = "pykd"
11
_desc = "python windbg extension"
12
_version = '0.3.5.0'
13

14
def getReleaseSrc():
15
    return 'Release_Static_%d.%d' % sys.version_info[0:2]
16

17
if "bdist_wheel" in sys.argv:
18

19
    # remove build catalog
20
    build_dir = os.path.join(os.path.curdir, 'build' )
21
    if os.path.exists(build_dir):
22
        shutil.rmtree(build_dir)
23

24
    # make package catalog
25
    package_dir = os.path.join(os.path.curdir, _name )
26
    if os.path.exists(package_dir):
27
        shutil.rmtree(package_dir)
28
    os.mkdir(package_dir)
29

30
    shutil.copy("__init__.py", package_dir)
31

32
    bin_dir = os.path.join( os.path.curdir, '..', 'kdlibcpp/bin')
33
    pykd_dir =  os.path.join( os.path.curdir, '..', 'out')
34
    if "--plat-name=win32" in sys.argv:
35
        bin_dir = os.path.join( bin_dir, 'x86')
36
        pykd_dir = os.path.join(pykd_dir, 'Win32', getReleaseSrc())
37
    elif "--plat-name=win-amd64" in sys.argv:
38
        bin_dir = os.path.join( bin_dir, 'x64')
39
        pykd_dir = os.path.join(pykd_dir, 'X64', getReleaseSrc())
40
    else:
41
        assert(0)
42

43
    assert(os.path.isdir(bin_dir))
44

45
    for binFile in  [ f for f in os.listdir(bin_dir) if not os.path.isdir(f) ]:
46
        shutil.copy( os.path.join(bin_dir, binFile), os.path.join(package_dir, binFile) )
47

48
    shutil.copy( os.path.join(pykd_dir, 'pykd.pyd'), os.path.join(package_dir, 'pykd.pyd') )
49

50
    setup(
51
        name = _name,
52
        version = _version,
53
        description = _desc,
54
       # cmdclass = { 'bdist_wheel' : bdist_wheel },
55
        packages = ['pykd'],
56
        package_dir = {'pykd': package_dir},
57
        package_data = { 'pykd' :["*.pyd", "*.dll"]},
58
        include_package_data=True,
59
        zip_safe = False
60
        )
61

62
elif "bdist_zip" in sys.argv:
63

64
    #make package catalog
65

66
    if "--plat-name=win32" in sys.argv:
67
        plat_name="win32"
68
    elif "--plat-name=win-amd64" in sys.argv:
69
        plat_name="win-amd64"
70

71
    package_dir = os.path.join(os.path.curdir, _name )
72
    if os.path.exists(package_dir):
73
        shutil.rmtree(package_dir)
74
    os.mkdir(package_dir)
75

76
    bin_dir = os.path.join( os.path.curdir, '..', 'kdlibcpp/bin')
77
    pykd_dir =  os.path.join( os.path.curdir, '..', 'out')
78
    if plat_name=="win32":
79
        bin_dir = os.path.join( bin_dir, 'x86')
80
        pykd_dir = os.path.join(pykd_dir, 'Win32', getReleaseSrc())
81
    elif plat_name=="win-amd64":
82
        bin_dir = os.path.join( bin_dir, 'x64')
83
        pykd_dir = os.path.join(pykd_dir, 'X64', getReleaseSrc())
84
    else:
85
        assert(0)
86

87
    pyver="%d%d" % sys.version_info[0:2]
88

89
    zip_str = "pykd-%s-cp%s-%s" % ( _version, pyver, plat_name )
90
    zip_name = zip_str + ".zip"
91

92
    assert(os.path.isdir(bin_dir))
93

94
    for binFile in  [ f for f in os.listdir(bin_dir) if not os.path.isdir(f) ]:
95
        shutil.copy( os.path.join(bin_dir, binFile), os.path.join(package_dir, binFile) )
96

97
    shutil.copy( os.path.join(pykd_dir, 'pykd.pyd'), os.path.join(package_dir, 'pykd.pyd') )
98

99
    dist_dir = os.path.join(os.path.curdir, 'dist')
100
    if not os.path.exists(dist_dir):
101
        os.mkdir(dist_dir)
102

103
    with zipfile.ZipFile(os.path.join(os.path.curdir, 'dist', zip_name), mode='w' ) as archive:
104
        for srcFile in os.listdir(package_dir):
105
            print( "zipped %s" % (srcFile) )
106
            archive.write( os.path.join(package_dir, srcFile), compress_type = zipfile.ZIP_DEFLATED)
107

108
    print("OK")
109
    
110
elif "bdist_pdb" in sys.argv:
111

112
    #make pdb archive
113
    pyVersion = ('2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12')
114
    platform = ('Win32', 'x64')
115
    
116
    pdbFiles = [ os.path.join( platform, 'Release_Static_' + version, 'pykd.pdb') for version, platform in itertools.product( pyVersion, platform ) ]
117
    
118
    zip_name = "pykd-%s-symbols.zip" %  _version
119
    
120
    with zipfile.ZipFile(os.path.join(os.path.curdir, 'dist', zip_name), mode='w' ) as archive:
121
        for pdbFile in pdbFiles:
122
            print( "zipped %s" % (pdbFile) )
123
            archive.write( os.path.join(os.path.curdir, '..', 'out', pdbFile), pdbFile, compress_type = zipfile.ZIP_DEFLATED)
124
    
125
    #pdbFileList = [ os.path.join( os.path.curdir, '..', 'out', fileName) for fileName in (
126
    
127

128
    pass
129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.