-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
73 lines (58 loc) · 1.78 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
import os
import sys
import re
import shutil
import pathlib
import numpy
from setuptools import setup, find_packages, Extension
import distutils.command.build
from Cython.Build import cythonize
from distutils.extension import Extension
if sys.version_info < (3, 4):
raise RuntimeError('renom_img requires Python3')
DIR = str(pathlib.Path(__file__).resolve().parent)
requires = [
"bs4", "bottle", "glob2", "lxml", "Pillow",
"PyYAML", "watchdog", "xmltodict", "tqdm"
]
entry_points = {
'console_scripts': [
'renom_img = renom_img.server.server:main',
]
}
class BuildNPM(distutils.command.build.build):
"""Custom build command."""
def run(self):
shutil.rmtree(os.path.join(DIR, 'renom_img/server/.build'), ignore_errors=True)
curdir = os.getcwd()
try:
jsdir = os.path.join(DIR, 'js')
# skip if js directory not exists.
if os.path.isdir(jsdir):
os.chdir(jsdir)
ret = os.system('npm install')
if ret:
raise RuntimeError('Failed to install npm modules')
ret = os.system('npm run build')
if ret:
raise RuntimeError('Failed to build npm modules')
finally:
os.chdir(curdir)
super().run()
setup(
name="renom_img",
version="1.0.0",
entry_points=entry_points,
packages=['renom_img'],
install_requires=requires,
include_package_data=True,
zip_safe=True,
cmdclass={
'build': BuildNPM,
},
ext_modules=cythonize([
"renom_img/api/utility/*.pyx",
"renom_img/api/utility/evaluate/*.pyx",
],
include_path=[numpy.get_include()])
)