forked from allenai/ScienceWorld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
52 lines (44 loc) · 1.85 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
import os.path, sys
import re
import subprocess
import zipfile
from setuptools import setup
BASEPATH = os.path.dirname(os.path.abspath(__file__))
JAR_FILE = 'scienceworld.jar'
JAR_PATH = os.path.join(BASEPATH, 'scienceworld', JAR_FILE)
# Extract ScienceWorld version from JAR file metadata
contents = zipfile.ZipFile(JAR_PATH).open('META-INF/MANIFEST.MF').read().decode('utf-8')
VERSION = re.search(r'\bSpecification-Version: (.*)\b', contents).group(1)
OBJECTS_LUT_FILE = "object_type_ids.tsv"
TASKS_JSON_FILE = "tasks.json"
if not os.path.isfile(JAR_PATH):
print('ERROR: Unable to find required library:', JAR_PATH)
sys.exit(1)
# Based on https://github.com/microsoft/DeepSpeed/blob/28dfca8a13313b570e1ad145cf14476d8d5d8e16/setup.py#L170-L184
# Write out version/git info
git_hash_cmd = "git rev-parse --short HEAD"
try:
result = subprocess.check_output(git_hash_cmd, shell=True)
git_hash = result.decode('utf-8').strip()
VERSION += f'+{git_hash}'
except subprocess.CalledProcessError:
pass
with open(os.path.join('scienceworld', 'version.py'), 'w') as f:
f.write(f'__version__ = {VERSION!r}\n')
setup(name='scienceworld',
version=VERSION,
description='ScienceWorld: An interactive text environment to study AI agents on accomplishing tasks from the standardized elementary science curriculum.',
author='Peter Jansen',
packages=['scienceworld'],
include_package_data=True,
package_dir={'scienceworld': 'scienceworld'},
package_data={'scienceworld': [JAR_FILE, OBJECTS_LUT_FILE, TASKS_JSON_FILE]},
url="https://scienceworld.github.io",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
python_requires='>=3.7',
install_requires=open('requirements.txt').readlines(),
extras_require={
'webserver': open('requirements.txt').readlines() + ['pywebio'],
},
)