-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
93 lines (79 loc) · 3.04 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
#!/usr/bin/env python
from __future__ import print_function
from setuptools import setup, find_packages
from setuptools.command.install import install
import os
import platform
import sys
import atexit
import tarfile
__version__ = '0.1.58'
# Installing Cython indepdently bc of numpy version. Pinning packages bc of python3.6
install_requires = ['PyLD', 'future', 'prov', 'unicodecsv', 'progressbar2==3.55.0', 'pandas==1.1.5','requests', 'argparse==1.1', 'Cython','tqdm==4.46.0']
# TODO: migrate to docs confix:, 'sphinx-argparse', 'sphinxcontrib-fulltoc']
if sys.version_info.major == 2:
install_requires.append('configparser')
install_requires.append('mock')
def _download_config():
print("Downloading .htrc file...")
_config_file_url = 'https://analytics.hathitrust.org/files/.htrc'
_path = os.path.expanduser('~/.htrc')
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
urlretrieve(_config_file_url, _path)
print("\n")
def _install_mallet():
mallet_path = os.path.expanduser('~/mallet')
if not os.path.exists(mallet_path):
print('Installing Mallet ...')
os.makedirs(mallet_path)
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
mallet_zip, _ = urlretrieve('http://mallet.cs.umass.edu/dist/mallet-2.0.8RC3.tar.gz')
mallet_dir = tarfile.open(mallet_zip, "r:gz")
mallet_dir.extractall(path=mallet_path)
mallet_dir.close()
print('\n')
class PostInstallCommand(install, object):
def __init__(self, *args, **kwargs):
super(PostInstallCommand, self).__init__(*args, **kwargs)
atexit.register(_download_config)
atexit.register(_install_mallet)
setup(
name='htrc',
version=__version__,
description='HathiTrust Research Center API Access',
author="HathiTrust Research Center",
author_email="[email protected]",
url='http://analytics.hathitrust.org',
download_url='http://github.com/htrc/HTRC-PythonSDK',
keywords=[],
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: Unix",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Linguistic",
],
packages=find_packages(),
install_requires=install_requires,
include_package_data=True,
data_files=[('htrc/mock/volumes', ['htrc/mock/volumes/example.zip']),
('htrc', ['htrc/.htrc.default'])],
zip_safe=False,
entry_points={
'console_scripts': ['htrc = htrc.__main__:main']
},
test_suite="unittest2.collector",
tests_require=['unittest2'],
cmdclass={'install': PostInstallCommand}
)