-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathsetup.py
68 lines (57 loc) · 2.16 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
#!/usr/bin/env python
# -*- coding: utf8 -*-
import setuptools
from setuptools.command.develop import develop
from setuptools.command.install import install
from os import getenv, path
# Note: This is duplicate with zeeguu/config/__init__.py but we can't avoid it
# because at the time we're running the setup.py we don't have the packages installed yet
# and also we can't import it from there with a relative import
# I guess everything would be easier if by default, we would work with in /zeeguu-resources
# that would make the container preparation easier, because we would not have to define
# zeeguu_resources ... come on, that's not that hard
ZEEGUU_RESOURCES_FOLDER = getenv("ZEEGUU_RESOURCES_FOLDER") or path.expanduser("~")
class DevelopScript(develop):
def run(self):
develop.run(self)
ntlk_install_packages()
class InstallScript(install):
def run(self):
install.run(self)
ntlk_install_packages()
def ntlk_install_packages():
import nltk
import os
# install in /var/www if available
# when API is run with mod_wsgi from container
# in the docker container
if os.path.exists(ZEEGUU_RESOURCES_FOLDER) and os.access(
ZEEGUU_RESOURCES_FOLDER, os.W_OK
):
nltk_data_dir = os.path.join(ZEEGUU_RESOURCES_FOLDER, "nltk_data")
nltk.download("punkt", download_dir=nltk_data_dir)
nltk.download("punkt_tab", download_dir=nltk_data_dir)
nltk.download("averaged_perceptron_tagger", download_dir=nltk_data_dir)
else:
print("Downloading nltk packages...")
nltk.download("punkt")
nltk.download("punkt_tab")
nltk.download("averaged_perceptron_tagger")
setuptools.setup(
name="zeeguu_api",
version="0.31",
packages=setuptools.find_packages(),
include_package_data=True,
zip_safe=False,
author="The Zeeguu Team",
author_email="[email protected]",
description=(
"API for Zeeguu, a project that aims to accelerate vocabulary"
" acquisition in a second language"
),
keywords=" API, second language acquisition",
cmdclass={
"develop": DevelopScript,
"install": InstallScript,
},
)