Skip to content

Commit a650064

Browse files
committed
Add missing build scripts, tests, and data directory
1 parent ec9da71 commit a650064

9 files changed

Lines changed: 1181 additions & 0 deletions

File tree

build_installers.py

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Build script for creating ForexSmartBot installers
4+
Supports Windows (.exe), Linux (.deb, .rpm, .tar.gz), and macOS (.dmg)
5+
"""
6+
7+
import os
8+
import sys
9+
import subprocess
10+
import shutil
11+
from pathlib import Path
12+
import platform
13+
14+
def run_command(cmd, cwd=None):
15+
"""Run a command and return the result."""
16+
try:
17+
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True)
18+
if result.returncode != 0:
19+
print(f"Error running command: {cmd}")
20+
print(f"Error: {result.stderr}")
21+
return False
22+
return True
23+
except Exception as e:
24+
print(f"Exception running command {cmd}: {e}")
25+
return False
26+
27+
def build_windows_installer():
28+
"""Build Windows .exe installer using PyInstaller."""
29+
print("Building Windows installer...")
30+
31+
# Install PyInstaller if not already installed
32+
if not run_command("pip install pyinstaller"):
33+
return False
34+
35+
# Create the PyInstaller spec file
36+
spec_content = """
37+
# -*- mode: python ; coding: utf-8 -*-
38+
39+
block_cipher = None
40+
41+
a = Analysis(
42+
['app.py'],
43+
pathex=[],
44+
binaries=[],
45+
datas=[
46+
('forexsmartbot/languages', 'forexsmartbot/languages'),
47+
('assets', 'assets'),
48+
],
49+
hiddenimports=[
50+
'PyQt6.QtCore',
51+
'PyQt6.QtGui',
52+
'PyQt6.QtWidgets',
53+
'matplotlib',
54+
'numpy',
55+
'pandas',
56+
'yfinance',
57+
'requests',
58+
'win10toast',
59+
],
60+
hookspath=[],
61+
hooksconfig={},
62+
runtime_hooks=[],
63+
excludes=[],
64+
win_no_prefer_redirects=False,
65+
win_private_assemblies=False,
66+
cipher=block_cipher,
67+
noarchive=False,
68+
)
69+
70+
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
71+
72+
exe = EXE(
73+
pyz,
74+
a.scripts,
75+
a.binaries,
76+
a.zipfiles,
77+
a.datas,
78+
[],
79+
name='ForexSmartBot',
80+
debug=False,
81+
bootloader_ignore_signals=False,
82+
strip=False,
83+
upx=True,
84+
upx_exclude=[],
85+
runtime_tmpdir=None,
86+
console=False,
87+
disable_windowed_traceback=False,
88+
argv_emulation=False,
89+
target_arch=None,
90+
codesign_identity=None,
91+
entitlements_file=None,
92+
icon='assets/icons/forexsmartbot_256.ico'
93+
)
94+
"""
95+
96+
with open('ForexSmartBot.spec', 'w') as f:
97+
f.write(spec_content)
98+
99+
# Build the executable
100+
if run_command("pyinstaller ForexSmartBot.spec"):
101+
print("Windows installer built successfully!")
102+
return True
103+
return False
104+
105+
def build_linux_packages():
106+
"""Build Linux packages (.deb, .rpm, .tar.gz)."""
107+
print("Building Linux packages...")
108+
109+
# Create setup.py for Linux packages
110+
setup_content = """
111+
from setuptools import setup, find_packages
112+
import os
113+
114+
# Read the README file
115+
with open("README.md", "r", encoding="utf-8") as fh:
116+
long_description = fh.read()
117+
118+
# Read requirements
119+
with open("requirements.txt", "r", encoding="utf-8") as fh:
120+
requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")]
121+
122+
setup(
123+
name="forexsmartbot",
124+
version="3.0.0",
125+
author="VoxHash",
126+
author_email="support@voxhash.com",
127+
description="Advanced Forex Trading Bot with Machine Learning Strategies",
128+
long_description=long_description,
129+
long_description_content_type="text/markdown",
130+
url="https://github.com/voxhash/forexsmartbot",
131+
packages=find_packages(),
132+
classifiers=[
133+
"Development Status :: 5 - Production/Stable",
134+
"Intended Audience :: Financial and Insurance Industry",
135+
"License :: OSI Approved :: MIT License",
136+
"Operating System :: OS Independent",
137+
"Programming Language :: Python :: 3",
138+
"Programming Language :: Python :: 3.10",
139+
"Programming Language :: Python :: 3.11",
140+
"Programming Language :: Python :: 3.12",
141+
"Programming Language :: Python :: 3.13",
142+
"Topic :: Office/Business :: Financial :: Investment",
143+
],
144+
python_requires=">=3.10",
145+
install_requires=requirements,
146+
entry_points={
147+
"console_scripts": [
148+
"forexsmartbot=app:main",
149+
],
150+
},
151+
include_package_data=True,
152+
package_data={
153+
"forexsmartbot": [
154+
"languages/*.json",
155+
"assets/icons/*.png",
156+
"assets/icons/*.ico",
157+
],
158+
},
159+
data_files=[
160+
("share/applications", ["forexsmartbot.desktop"]),
161+
("share/pixmaps", ["assets/icons/forexsmartbot_256.png"]),
162+
],
163+
)
164+
"""
165+
166+
with open('setup.py', 'w') as f:
167+
f.write(setup_content)
168+
169+
# Create desktop file
170+
desktop_content = """
171+
[Desktop Entry]
172+
Version=1.0
173+
Type=Application
174+
Name=ForexSmartBot
175+
Comment=Advanced Forex Trading Bot
176+
Exec=forexsmartbot
177+
Icon=forexsmartbot_256
178+
Terminal=false
179+
Categories=Office;Finance;
180+
"""
181+
182+
with open('forexsmartbot.desktop', 'w') as f:
183+
f.write(desktop_content)
184+
185+
# Build packages
186+
packages_built = []
187+
188+
# Build .deb package
189+
if run_command("pip install stdeb"):
190+
if run_command("python setup.py --command-packages=stdeb.command bdist_deb"):
191+
packages_built.append("deb")
192+
193+
# Build .rpm package
194+
if run_command("pip install rpm"):
195+
if run_command("python setup.py bdist_rpm"):
196+
packages_built.append("rpm")
197+
198+
# Build .tar.gz package
199+
if run_command("python setup.py sdist"):
200+
packages_built.append("tar.gz")
201+
202+
if packages_built:
203+
print(f"Linux packages built: {', '.join(packages_built)}")
204+
return True
205+
return False
206+
207+
def build_macos_package():
208+
"""Build macOS .dmg package."""
209+
print("Building macOS package...")
210+
211+
# Install required packages
212+
if not run_command("pip install py2app"):
213+
return False
214+
215+
# Create setup.py for macOS
216+
setup_macos_content = """
217+
from setuptools import setup
218+
import os
219+
220+
APP = ['app.py']
221+
DATA_FILES = [
222+
('forexsmartbot/languages', ['forexsmartbot/languages/' + f for f in os.listdir('forexsmartbot/languages') if f.endswith('.json')]),
223+
('assets', ['assets/' + f for f in os.listdir('assets') if os.path.isfile(os.path.join('assets', f))]),
224+
]
225+
226+
OPTIONS = {
227+
'argv_emulation': True,
228+
'iconfile': 'assets/icons/forexsmartbot_256.icns',
229+
'plist': {
230+
'CFBundleName': 'ForexSmartBot',
231+
'CFBundleDisplayName': 'ForexSmartBot',
232+
'CFBundleIdentifier': 'com.voxhash.forexsmartbot',
233+
'CFBundleVersion': '3.0.0',
234+
'CFBundleShortVersionString': '3.0.0',
235+
},
236+
'packages': ['PyQt6', 'matplotlib', 'numpy', 'pandas', 'yfinance', 'requests'],
237+
}
238+
239+
setup(
240+
app=APP,
241+
data_files=DATA_FILES,
242+
options={'py2app': OPTIONS},
243+
setup_requires=['py2app'],
244+
)
245+
"""
246+
247+
with open('setup_macos.py', 'w') as f:
248+
f.write(setup_macos_content)
249+
250+
# Build the macOS app
251+
if run_command("python setup_macos.py py2app"):
252+
print("macOS package built successfully!")
253+
return True
254+
return False
255+
256+
def main():
257+
"""Main build function."""
258+
print("ForexSmartBot v3.0.0 - Installer Builder")
259+
print("=" * 50)
260+
261+
current_os = platform.system().lower()
262+
263+
if current_os == "windows":
264+
print("Building Windows installer...")
265+
if build_windows_installer():
266+
print("✅ Windows installer built successfully!")
267+
else:
268+
print("❌ Failed to build Windows installer")
269+
270+
elif current_os == "linux":
271+
print("Building Linux packages...")
272+
if build_linux_packages():
273+
print("✅ Linux packages built successfully!")
274+
else:
275+
print("❌ Failed to build Linux packages")
276+
277+
elif current_os == "darwin":
278+
print("Building macOS package...")
279+
if build_macos_package():
280+
print("✅ macOS package built successfully!")
281+
else:
282+
print("❌ Failed to build macOS package")
283+
284+
else:
285+
print(f"Unsupported operating system: {current_os}")
286+
return False
287+
288+
print("\nBuild process completed!")
289+
return True
290+
291+
if __name__ == "__main__":
292+
main()

0 commit comments

Comments
 (0)