forked from iipeace/guider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
91 lines (79 loc) · 2.8 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import site, os, sys, shutil
from distutils.core import setup
setup(
name = 'guider',
version = '3.9.5',
license = 'GPL2',
description = 'A system-wide analyzer of performance',
author = 'Peace Lee',
author_email = '[email protected]',
url = 'https://github.com/iipeace/guider',
download_url = 'https://github.com/iipeace/guider/archive/master.zip',
keywords = ['guider', 'linux', 'analyzer', 'performance', 'profile', 'trace', 'kernel'],
packages = ['guider'],
scripts = ['guider/guider'],
classifiers = [
'Environment :: Console',
'Programming Language :: Python',
'Operating System :: Android',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Natural Language :: English',
'Topic :: Software Development :: Debuggers',
'Topic :: Software Development :: Embedded Systems',
'Topic :: System :: Filesystems',
'Topic :: System :: Monitoring',
'Topic :: System :: Operating System Kernels',
],
)
# make guider directory #
try:
desPath = '%s/share/guider' % sys.prefix
pycDesPath = '%s/guider.pyc' % desPath
os.mkdir(desPath)
except:
pass
# search package path #
for path in site.getsitepackages():
# check path #
if not os.path.isdir('%s/guider' % path):
continue
# set pyc source path #
pycSrcPath = '%s/guider/guider.pyc' % path
try:
# prepare source pyc file #
pycTmpDir = '%s/guider/__pycache__/' % path
if os.path.isdir(pycTmpDir):
for cache in os.listdir(pycTmpDir):
if not cache.startswith('guider'):
continue
# rename cpython-format name #
pycTmpFile = '%s%s' % (pycTmpDir, cache)
os.rename(pycTmpFile, pycSrcPath)
# check pyc source file #
if not os.path.isfile(pycSrcPath):
continue
# remove old pyc file #
if os.path.isfile(pycDesPath):
os.unlink(pycDesPath)
# create pyc destination path #
os.symlink(pycSrcPath, pycDesPath)
print("Wrote %s and linked it to %s successfully" % \
(pycSrcPath, pycDesPath))
except:
err = sys.exc_info()[1]
try:
if len(err.args) == 0 or err.args[0] == 0:
#print(sys.exc_info()[0].__name__)
continue
errRes = ' '.join(list(map(str, err.args)))
print("[ERROR] Fail to write %s and link it to %s" % \
(pycSrcPath, pycDesPath))
except:
pass
'''
pypi upload command
# python setup.py sdist upload -r pypitest
# python setup.py sdist upload -r https://upload.pypi.org/legacy/
'''