1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
from __future__ import unicode_literals |
4
|
|
|
from codecs import open |
5
|
|
|
try: |
6
|
|
|
import urllib.request as urlrequest |
7
|
|
|
except ImportError: |
8
|
|
|
import urllib as urlrequest |
9
|
|
|
from setuptools.command.install import install |
10
|
|
|
from setuptools.command.develop import develop |
11
|
|
|
from setuptools import setup |
12
|
|
|
import re |
13
|
|
|
import os |
14
|
|
|
import sys |
15
|
|
|
|
16
|
|
|
# get version |
17
|
|
|
with open('processors/__init__.py', 'r', 'utf-8') as fd: |
18
|
|
|
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', |
19
|
|
|
fd.read(), re.MULTILINE).group(1) |
20
|
|
|
|
21
|
|
|
class JarManager(object): |
22
|
|
|
|
23
|
|
|
ppjar = os.path.join("processors", "processors-server.jar") |
24
|
|
|
|
25
|
|
|
@classmethod |
26
|
|
|
def download_jar(cls): |
27
|
|
|
# download processors-server.jar |
28
|
|
|
ppjar = JarManager.ppjar |
29
|
|
|
percent = 0 |
30
|
|
|
def dlProgress(count, blockSize, totalSize): |
31
|
|
|
percent = int(count*blockSize*100/totalSize) |
32
|
|
|
sys.stdout.write("\r{}% complete".format(percent)) |
33
|
|
|
sys.stdout.flush() |
34
|
|
|
jar_url = "http://py-processors.parsertongue.com/v{}/processors-server.jar".format(version) |
35
|
|
|
print("Downloading {} from {} ...".format(ppjar, jar_url)) |
36
|
|
|
urlretrieve(jar_url, ppjar, reporthook=dlProgress) |
37
|
|
|
print("\nInstalling py-processors ...") |
38
|
|
|
|
39
|
|
|
class PyProcessorsDevelop(develop): |
40
|
|
|
|
41
|
|
|
def run(self): |
42
|
|
|
# download processors-server.jar |
43
|
|
|
#JarManager.download_jar() |
44
|
|
|
develop.run(self) |
45
|
|
|
|
46
|
|
|
class PyProcessorsInstall(install): |
47
|
|
|
"""Downloads processors-server.jar for use in py-processors""" |
48
|
|
|
|
49
|
|
|
def run(self): |
50
|
|
|
# download processors-server.jar |
51
|
|
|
#JarManager.download_jar() |
52
|
|
|
# install everything else |
53
|
|
|
install.run(self) |
54
|
|
|
|
55
|
|
|
# use requirements.txt as deps list |
56
|
|
|
with open('requirements.txt', 'r', 'utf-8') as f: |
57
|
|
|
required = f.read().splitlines() |
58
|
|
|
|
59
|
|
|
# get readme |
60
|
|
|
with open('docs/index.md', 'r', 'utf-8') as f: |
61
|
|
|
readme = f.read() |
62
|
|
|
|
63
|
|
|
test_deps = ["green>=2.5.0", "coverage"] |
64
|
|
|
viz_deps = ["jupyter>=1.0.0", "ipython>=6.2.1", "traitlets>=4.3.2"] |
65
|
|
|
|
66
|
|
|
setup(name='py-processors', |
67
|
|
|
packages=["processors"], |
68
|
|
|
version=version, |
69
|
|
|
keywords=['nlp', 'processors', 'jvm'], |
70
|
|
|
description="A wrapper++ for interacting with the CLU Lab's processors library.", |
71
|
|
|
long_description=readme, |
72
|
|
|
url='http://github.com/myedibleenso/py-processors', |
73
|
|
|
download_url="https://github.com/myedibleenso/py-processors/archive/v{}.zip".format(version), |
74
|
|
|
author='myedibleenso', |
75
|
|
|
author_email='[email protected]', |
76
|
|
|
license='Apache 2.0', |
77
|
|
|
install_requires=required, |
78
|
|
|
cmdclass={ |
79
|
|
|
'install': PyProcessorsInstall, |
80
|
|
|
'develop': PyProcessorsDevelop, |
81
|
|
|
}, |
82
|
|
|
classifiers=( |
83
|
|
|
"Intended Audience :: Science/Research", |
84
|
|
|
"Natural Language :: English", |
85
|
|
|
"Topic :: Scientific/Engineering :: Artificial Intelligence", |
86
|
|
|
"Programming Language :: Python :: 2.7", |
87
|
|
|
"Programming Language :: Python :: 3" |
88
|
|
|
), |
89
|
|
|
tests_require=test_deps, |
90
|
|
|
extras_require={ |
91
|
|
|
'test': test_deps, |
92
|
|
|
'jupyter': viz_deps |
93
|
|
|
}, |
94
|
|
|
include_package_data=True, |
95
|
|
|
zip_safe=False) |
96
|
|
|
|