forked from niyaton/kenja
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
129 lines (113 loc) · 5.11 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import os
import sys
import hashlib
import urllib
import subprocess
import glob
from tarfile import open as tarfile_open
from setuptools import setup, find_packages
kenja_version = '0.6-122-gbd1964f'
data_files = [("kenja", ["kenja/readme_for_historage.txt"])]
def copy_java_parser():
parser_path = 'kenja/lib/java/java-parser.jar'
parser_location = 'https://github.com/niyaton/kenja-java-parser/releases/download/0.5/kenja-java-parser-0.5-jar-with-dependencies.jar'
parser_digest = '3686529db9d36d5ef5d7425692d95aea'
confirm_text = None
if not os.path.exists(parser_path):
confirm_text = "{0} does not exist. Do you want to download it?[y/n]".format(parser_path)
elif hashlib.md5(open(parser_path).read()).hexdigest() != parser_digest:
confirm_text = "{0} is different from designated parser script. Do you want to overwrite it?[y/n]".format(parser_path)
if confirm_text is not None:
print(confirm_text)
choice = raw_input().lower()
yes = set(['yes', 'y', 'ye'])
no = set(['no', 'n'])
if choice in yes:
urllib.urlretrieve(parser_location, parser_path)
digest = hashlib.md5(open(parser_path).read()).hexdigest()
if parser_digest != digest:
print("md5 hash of {0} is incorrect! remove it and try again.".format(parser_path))
sys.exit(1)
if not os.path.exists(parser_path):
print("java parser will not be installed.")
print("You should disable java parser when you run kenja")
else:
data_files.append(("kenja/lib/java", ["kenja/lib/java/java-parser.jar"]))
def copy_csharp_parser():
parser_path = 'kenja/lib/csharp/kenja-csharp-parser.exe'
parser_digest = 'a3dfac7de0406e961d0c47f95d9bc522'
parser_location = 'https://github.com/sdlab-naist/kenja-csharp-parser/releases/download/0.1/kenja-csharp-parser-0.1.tar.gz'
parser_tar_digest = '583013bc78b3f1f158f094baa37b0808'
confirm_text = None
if not os.path.exists(parser_path):
confirm_text = "{0} does not exist. Do you want to download it?[y/n]".format(parser_path)
elif hashlib.md5(open(parser_path).read()).hexdigest() != parser_digest:
confirm_text = "{0} is different from designated parser script. Do you want to overwrite it?[y/n]".format(parser_path)
if confirm_text is not None:
print(confirm_text)
choice = raw_input().lower()
yes = set(['yes', 'y', 'ye'])
no = set(['no', 'n'])
if choice in yes:
(filename, _) = urllib.urlretrieve(parser_location)
digest = hashlib.md5(open(filename, 'rb').read()).hexdigest()
if parser_tar_digest != digest:
print("md5 hash of {0} is incorrect! remove it and try again.".format(filename))
sys.exit(1)
tarfile = tarfile_open(filename, 'r')
tarfile.extractall('kenja/lib/csharp')
if not os.path.exists(parser_path):
print("java parser will not be installed.")
print("You should disable java parser when you run kenja")
else:
data_files.append(("kenja/lib/csharp", glob.glob("kenja/lib/csharp/*")))
copy_java_parser()
copy_csharp_parser()
try:
kenja_version = subprocess.check_output(["git", "describe"]).rstrip()
except subprocess.CalledProcessError, e:
pass
setup(name='kenja',
version=kenja_version,
description='A Refactoring Detection tool powered by Historage',
author='Kenji Fujiwara',
author_email='kenji-f@is.naist.jp',
url='https://github.com/niyaton/kenja',
packages=find_packages(),
data_files=data_files,
entry_points={
'console_scripts': [
'kenja.historage.convert = kenja.convert:convert',
'kenja.historage.parse = kenja.convert:parse',
'kenja.historage.construct = kenja.convert:construct',
'kenja.detection.extract_method = kenja.refactoring_detection:main',
'kenja.detection.pull_up_method = kenja.pull_up_method:main',
'kenja.debug.check_duplicate_entry = kenja.git.detect_duplicate_entry:main',
'kenja.debug.check_historage_equivalence = kenja.git.diff:main'
]
},
install_requires=[
"pyrem_torq",
"GitPython==0.3.6",
"kenja-python-parser"
],
dependency_links=[
'https://github.com/tos-kamiya/pyrem_torq/tarball/master#egg=pyrem_torq',
'https://github.com/sdlab-naist/kenja-python-parser/tarball/master#egg=kenja-python-parser'
],
license="MIT license",
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: Science/Resarch',
'License :: OSI Approved :: MIT License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Java',
'Topic :: Scientific/Engineering :: Information Analysis',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities'
]
)