-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
110 lines (87 loc) · 3.17 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
import os
import sys
import atexit
import tarfile
from zipfile import ZipFile
from urllib import request
from setuptools import setup, find_packages
from setuptools.command.install import install
NAME = 'tomodapi'
MALLET_URI = 'http://mallet.cs.umass.edu/dist/mallet-2.0.8.tar.gz'
MALLET_FILE = 'mallet.tar.gz'
GLOVE_URI = 'http://nlp.stanford.edu/data/glove.6B.zip'
GLOVE_FILE = 'glove.zip'
def find_module_path():
for p in sys.path:
if os.path.isdir(p) and NAME in os.listdir(p):
return os.path.join(p, NAME)
class PostInstallCommand(install):
def run(self):
# atexit.register(self.download_mallet)
# atexit.register(self.download_glove)
install.run(self)
def download_mallet(self):
main_dir = find_module_path()
os.makedirs(main_dir, exist_ok=True)
print('downloading mallet')
request.urlretrieve(MALLET_URI, MALLET_FILE)
print('extracting mallet')
tar = tarfile.open(MALLET_FILE, 'r:gz')
tar.extractall(path=main_dir)
tar.close()
print('mallet installed')
os.remove(MALLET_FILE)
def download_glove(self):
main_dir = os.path.join(find_module_path(), 'glove')
os.makedirs(main_dir, exist_ok=True)
print('downloading glove')
request.urlretrieve(GLOVE_URI, GLOVE_FILE)
print('extracting glove')
with ZipFile(GLOVE_FILE, 'r') as file:
file.extractall(path=main_dir)
print('glove installed')
os.remove(GLOVE_FILE)
with open('requirements.txt') as f:
requirements = f.read().splitlines()
required = []
extra_required = []
for r in requirements:
if r.startswith('git'):
dep_name = r.split('/')[-1]
# extra_required.append(r.replace('.git+', '')+'#egg='+dep_name+'-dev')
required.append(dep_name + '@' + r.replace('.git+', ''))
else:
required.append(r)
# As of pip version 18.1 (at least) use PEP 508 direct reference specifications. Do not use dependency_links.
# Example: install_requires=['python-s3 @ http://github.com/robot-republic/python-s3/tarball/master.tar.gz'] – Wolfgang Kuehn Dec 27 '18 at 18:14
print(extra_required)
setup(
name=NAME,
version='1.3',
data_files=[('txt', ['requirements.txt'])],
py_modules=['tomodapi'],
install_requires=required,
dependency_links=extra_required,
# metadata to display on PyPI
author='Pasquale Lisena',
author_email='[email protected]',
description='A framework for performing topic modelling',
license='Apache 2.0',
keywords='topic-model topic nlp',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
packages=find_packages(),
include_package_data=True,
package_data={
'': ['tomodapi/lftm/LFTM.jar', '*.jar']
},
cmdclass={
'install': PostInstallCommand,
},
url='https://github.com/D2KLab/ToModAPI', # project home page, if any
project_urls={
'Bug Tracker': 'https://github.com/D2KLab/tomodapi/issues/',
'Documentation': 'https://github.com/D2KLab/tomodapi/blob/master/README.md',
'Source Code': 'https://github.com/D2KLab/tomodapi/',
},
)