This repository has been archived by the owner on Nov 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
63 lines (56 loc) · 1.71 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
import setuptools
from distutils.extension import Extension
import os
import re
# pull version from package __init__
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, "fasttext_keras", "__init__.py"), "r") as rf:
initfile = rf.read()
vmatch = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", initfile, re.M)
if vmatch:
version = vmatch.group(1)
else:
raise RuntimeError("could not find version")
# rebuild from raw pyx if Cython/numpy are available,
# else use the included C++ converted source file
try:
from Cython.Build import cythonize
from Cython.Distutils import build_ext
import numpy as np
except ImportError:
USE_CYTHON = False
else:
USE_CYTHON = True
cmd_class = {}
if USE_CYTHON:
print("using Cython to rebuild from .pyx source")
ext_modules = [
Extension("fasttext_keras.dictionary.dictionary",
["fasttext_keras/dictionary/dictionary.pyx"],
include_dirs=[np.get_include()])
]
ext_modules = cythonize(ext_modules)
cmd_class.update({'build_ext': build_ext})
else:
print("building from included C++ extension files")
ext_modules = [
Extension("fasttext_keras.dictionary.dictionary",
["fasttext_keras/dictionary/dictionary.cpp"])
]
# main setup
setuptools.setup(
name='fasttext-keras',
author='John Walk',
author_email='[email protected]',
url='https://github.com/wayfair/fasttext-keras',
ext_modules=ext_modules,
packages=setuptools.find_packages(),
cmdclass=cmd_class,
long_description=open("README.md").read(),
install_requires=[
"numpy>=1.15",
"keras>=2.2.4",
"tensorflow>=1.12.1"
],
version=version
)