-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
105 lines (90 loc) · 2.74 KB
/
Copy pathsetup.py
File metadata and controls
105 lines (90 loc) · 2.74 KB
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
from pathlib import Path
from setuptools import setup, find_packages
package_dir = 'topic_analysis'
root = Path(__file__).parent.resolve()
# Read in package meta from about.py
about_path = root / package_dir / 'about.py'
with about_path.open('r', encoding='utf8') as f:
about = {}
exec(f.read(), about)
# Get readme
readme_path = root / 'README.md'
with readme_path.open('r', encoding='utf8') as f:
readme = f.read()
install_requires = [
'adjustText',
'joblib',
'matplotlib',
'numpy>=1.16',
'pandas',
'progressbar2',
'psutil',
'pystemmer',
'scipy',
'scikit-learn',
'spacy',
'spacy-lookups-data',
'symspellpy',
'unidecode'
]
test_requires = ['pytest']
def have_compiler():
"""
checks for the existence of a compiler by compiling a small C source file
source: https://charlesleifer.com/blog/misadventures-in-python-packaging-optional-c-extensions/
"""
from distutils.ccompiler import new_compiler
from distutils.errors import CompileError
from distutils.errors import DistutilsExecError
import os
import tempfile
import warnings
fd, fname = tempfile.mkstemp('.c', text=True)
f = os.fdopen(fd, 'w')
f.write('int main(int argc, char** argv) { return 0; }')
f.close()
compiler = new_compiler()
try:
compiler.compile([fname])
except (CompileError, DistutilsExecError):
warnings.warn('compiler not installed')
return False
except Exception as exc:
warnings.warn('unexpected error encountered while testing if compiler '
'available: %s' % exc)
return False
else:
return True
if not have_compiler():
install_requires.remove('pystemmer')
install_requires += ['nltk']
setup(
name=about['__title__'],
description=about['__summary__'],
long_description=readme,
long_description_content_type='text/markdown',
author=about['__author__'],
author_email=about['__email__'],
url=about['__uri__'],
version=about['__version__'],
license=about['__license__'],
packages=find_packages(exclude=('tests*',)),
install_requires=install_requires,
test_requires=test_requires,
zip_safe=True,
include_package_data=True,
classifiers=[
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.7',
'Topic :: Text Processing :: General'
]
)
# install spacy languages
import os
import sys
os.system(f'{sys.executable} -m spacy download nl_core_news_sm --user')
os.system(f'{sys.executable} -m spacy download en_core_web_sm --user')