-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathsetup.py
More file actions
119 lines (99 loc) · 3.24 KB
/
setup.py
File metadata and controls
119 lines (99 loc) · 3.24 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import asyncio
import os
import subprocess
import sys
from setuptools import find_packages
from setuptools import setup
from setuptools.command.build_py import build_py
from distutils.command.install import install
# from octobot_script import PROJECT_NAME, VERSION
# todo figure out how not to import octobot_script.__init__.py here
PROJECT_NAME = "OctoBot-Script"
VERSION = "0.0.30" # major.minor.revision
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
REPORT_DIST = os.path.join(
ROOT_DIR, "octobot_script", "resources", "report", "dist", "index.html"
)
def _build_report():
npm = "npm"
print("[report] Installing JS dependencies…")
result = subprocess.run(
[npm, "install", "--prefer-offline"],
cwd=ROOT_DIR,
check=False,
)
if result.returncode != 0:
print("[report] 'npm install' failed – skipping JS build.", file=sys.stderr)
return
print("[report] Building React bundle…")
result = subprocess.run(
[npm, "run", "build"],
cwd=ROOT_DIR,
check=False,
)
if result.returncode != 0:
print("[report] 'npm run build' failed – skipping JS bundle.", file=sys.stderr)
return
if os.path.isfile(REPORT_DIST):
print(f"[report] Built successfully → {REPORT_DIST}")
else:
print("[report] Build finished but dist/index.html not found.", file=sys.stderr)
class BuildPyWithReport(build_py):
def run(self):
_build_report()
super().run()
def _post_install():
import octobot_script.cli
asyncio.run(octobot_script.cli.install_all_tentacles(True))
class InstallWithPostInstallAction(install):
def run(self):
install.run(self)
self.execute(_post_install, (), msg="Installing OctoBot-Script tentacles")
PACKAGES = find_packages(
exclude=[
"tests",
"octobot_script.imports*",
"octobot_script.user*",
]
)
# long description from README file
with open('README.md', encoding='utf-8') as f:
DESCRIPTION = f.read()
REQUIRED = open('requirements.txt').readlines()
REQUIRES_PYTHON = '>=3.8'
setup(
name=PROJECT_NAME.lower().replace("-", "_"),
version=VERSION,
url='https://github.com/Drakkar-Software/OctoBot-Script',
license='GPL-3.0',
author='Drakkar-Software',
author_email='contact@drakkar.software',
description='Backtesting framework of the OctoBot Ecosystem',
packages=PACKAGES,
cmdclass={
'install': InstallWithPostInstallAction,
'build_py': BuildPyWithReport,
},
long_description=DESCRIPTION,
long_description_content_type='text/markdown',
tests_require=["pytest"],
test_suite="tests",
zip_safe=False,
data_files=[],
include_package_data=True, # copy non python files on install
install_requires=REQUIRED,
python_requires=REQUIRES_PYTHON,
entry_points={
'console_scripts': [
'octobot_script = octobot_script.cli:main'
]
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Operating System :: OS Independent',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python :: 3.10',
],
)