-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
98 lines (86 loc) · 2.86 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
from setuptools import setup,find_packages
import sys, platform
import os
import shutil
import json
def read(fname):
with open(fname, mode = "r", encoding = "utf-8") as f:
src = f.read()
return src
def read_requirements():
"""Parse requirements from requirements.txt."""
reqs_path = os.path.join('.', 'requirements.txt')
with open(reqs_path, 'r') as f:
requirements = [line.rstrip() for line in f]
return requirements
codemeta_json = "codemeta.json"
# Let's pickup as much metadata as we need from codemeta.json
with open(codemeta_json, mode = "r", encoding = "utf-8") as f:
src = f.read()
meta = json.loads(src)
# Let's make our symvar string
version = meta["version"]
# Now we need to pull and format our author, author_email strings.
author = ""
author_email = ""
for obj in meta["author"]:
given = obj["givenName"]
family = obj["familyName"]
email = obj["email"]
if len(author) == 0:
author = given + " " + family
else:
author = author + ", " + given + " " + family
if len(author_email) == 0:
author_email = email
else:
author_email = author_email + ", " + email
description = meta['description']
url = meta['codeRepository']
download = meta['downloadUrl']
license = meta['license']
name = meta['name']
# Setup for our Go based executable as a "data_file".
if sys.platform.startswith('win'):
exec_path = "exec/Win/eputil.exe"
OS_Classifier = "Operating System :: Microsoft :: Windows :: Windows 10"
elif sys.platform.startswith('linux'):
exec_path = "exec/Linux/eputil"
OS_Classifier = "Operating System :: POSIX :: Linux"
elif sys.platform.startswith("darwin"):
if platform.processor() == 'arm':
exec_path = "exec/MacOS-M1/eputil"
else:
exec_path = "exec/MacOS/eputil"
OS_Classifier = "Operating System :: MacOS :: MacOS X"
else:
print("Platform " + sys.platform + " not supported")
sys.exit(1)
if os.path.exists(exec_path) == False:
print("Missing executable " + exec_path + " in epxml_to_dataset module")
sys.exit(1)
#Copy exec for running locally
shutil.copy(exec_path,'epxml_support/.')
setup(
name = name,
version = version,
description = description,
author = author,
author_email = author_email,
url = url,
download_url = download,
license = license,
packages=find_packages(),
py_modules = ["caltech_thesis","caltech_authors_tech_report"],
data_files=[('.',['thesis-subjects.txt']),
('epxml_support',[exec_path])],
install_requires=read_requirements(),
classifiers = [
"Development Status :: Beta",
"Environment :: Console",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
OS_Classifier
]
)