-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
106 lines (79 loc) · 3.25 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
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
106
from __future__ import print_function
import os
import subprocess
import sys
from setuptools import setup, find_packages
from distutils.command.build import build # type: ignore
from distutils.command.sdist import sdist # type: ignore
from setuptools.command.develop import develop
# the name of the project
name = "idom_plotly"
# basic paths used to gather files
here = os.path.abspath(os.path.dirname(__file__))
package_dir = os.path.join(here, name)
# -----------------------------------------------------------------------------
# General Package Info
# -----------------------------------------------------------------------------
package = {
"name": name,
"python_requires": ">=3.8",
"install_requires": ["idom>=0.33.1", "plotly"],
"packages": find_packages(exclude=["tests*"]),
"description": "Plotly figures as a custom component for IDOM",
"author": "Ryan Morshead",
"author_email": "[email protected]",
"url": "https://github.com/idom-team/idom-plotly",
"platforms": "Linux, Mac OS X, Windows",
"keywords": ["idom", "components"],
"include_package_data": True,
"zip_safe": False,
"classifiers": [
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: User Interfaces",
"Topic :: Software Development :: Widget Sets",
"Typing :: Typed",
],
}
# -----------------------------------------------------------------------------
# Library Version
# -----------------------------------------------------------------------------
with open(os.path.join(package_dir, "__init__.py")) as init_file:
for line in init_file:
if line.split("=", 1)[0].strip() == "__version__":
package["version"] = eval(line.split("=", 1)[1])
break
else:
print("No version found in %s/__init__.py" % package_dir)
sys.exit(1)
# -----------------------------------------------------------------------------
# Library Description
# -----------------------------------------------------------------------------
with open(os.path.join(here, "README.md")) as f:
long_description = f.read()
package["long_description"] = long_description
package["long_description_content_type"] = "text/markdown"
# ----------------------------------------------------------------------------
# Build Javascript
# ----------------------------------------------------------------------------
def build_javascript_first(cls):
class Command(cls):
def run(self):
for cmd_str in ["npm install", "npm run build"]:
subprocess.check_call(cmd_str.split(), cwd=os.path.join(here, "js"))
super().run()
return Command
package["cmdclass"] = {
"sdist": build_javascript_first(sdist),
"build": build_javascript_first(build),
"develop": build_javascript_first(develop),
}
# -----------------------------------------------------------------------------
# Install It
# -----------------------------------------------------------------------------
if __name__ == "__main__":
setup(**package)