forked from Superalgos/Superalgos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
105 lines (93 loc) · 4.93 KB
/
setup.js
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
const path = require("path");
const process = require("process");
const { exec } = require("child_process");
const systemCheck = require('./Launch-Scripts/system-check')
const platform = require('os').platform(); // Possible values are: 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32'.
// Check system is set up correctly
systemCheck();
// Handle adding shortcuts
if (process.argv.includes("noShortcuts")) {
// Cancel running script if flag provided
console.log('');
console.log('noShortcuts ................................................... Setting up without shortcuts.')
} else {
// Run create-shortcuts script
try {
const { fork } = require('child_process')
fork('./Launch-Scripts/create-shortcut.js')
} catch (err) {
console.log('')
console.log(err)
console.log('')
}
}
// Create Operating System compatable paths to each node_modules directory.
let nodeModulesDirs = [
path.join( process.cwd(), "Platform"),
path.join( process.cwd(), "Projects", "Foundations", "TS", "Bot-Modules", "Sensor-Bot", "Exchange-Raw-Data"),
path.join( process.cwd(), "Projects", "Foundations", "TS", "Bot-Modules", "API-Data-Fetcher-Bot"),
path.join( process.cwd(), "Projects", "Foundations", "TS", "Bot-Modules", "Trading-Bot", "Announcements"),
path.join( process.cwd(), "Projects", "Foundations", "TS", "Bot-Modules", "Trading-Bot", "Low-Frequency-Trading", "APIs"),
path.join( process.cwd(), "Projects", "Foundations", "TS", "Task-Modules")
];
if (
process.argv.includes("TensorFlow") ||
process.argv.includes("tensorflow") ||
process.argv.includes("--TensorFlow") ||
process.argv.includes("-TensorFlow") ||
process.argv.includes("--tensorflow") ||
process.argv.includes("--tensorflow")
) {
nodeModulesDirs = [
path.join( process.cwd(), "Projects", "TensorFlow", "TS", "Bot-Modules", "Learning-Bot", "Low-Frequency-Learning")
]
}
// Check if WinOS because extra dependencies may be required for tfjs:
var tfjsWinInstallFlag = false;
if (platform === 'win32') { // *Note: win32 == win32 || win64
tfjsWinInstallFlag = true;
}
console.log('');
console.log("Installing node dependencies at the following directories:");
console.log('');
console.log(nodeModulesDirs);
console.log('');
for (let dir of nodeModulesDirs) {
// Loop through directories and run npm ci in a child process shell.
let command = "echo Results of install at "+ dir + " & npm ci";
exec( command,
{
cwd: dir
},
function ( error, stdout ){
if (error) {
console.log('');
console.log("There was an error installing some dependencies error: ");
console.log('');
console.log( error );
if (tfjsWinInstallFlag == true && dir == path.join(process.cwd(), "Projects", "TensorFlow", "TS", "Bot-Modules", "Learning-Bot", "Low-Frequency-Learning")) {
tfjsWinInstall();
}
return;
}
console.log('');
console.log( stdout );
});
};
/* If WinOS && error with tfjs installation:
* This is a well known and documented issue with @Tensorflow/tfjs-node installation on WinOS.
* npm's windows-build-tools via: `npm install --global --production windows-build-tools` &&
* `npm install -g node-gyp` can sometimes correct the issue but not always depending on the
* version and options the user defined when installing npm/nodejs.
* The best reliable way to correct that I (Pluvtech) have found to work on many versions of WinOS
* is to reinstall nodejs and select to install chocolatey during the installation configuration.
*/
function tfjsWinInstall() {
console.log("\n*** Note to Windows Users Regarding the Superalgos TensorFlow Project ***");
console.log("If you have no other errors with this setup script and do not wish to use the TensorFlow Project:\nThen all is successful with your Superalgos setup and you may proceed to use the software.");
console.log("\nIf you do wish to install the @Tensorflow/tfjs-node modules required for use with the Superalgos TensorFlow Project:");
console.log("In this case it is likely your system is missing some dependencies required to build the TensorFlow (tfjs-node) bindings and you will need to follow the below steps:");
console.log("\n1.) Reinstall node.js from https://nodejs.org/en/download/ @Version 14.17.5 or higher.\nDuring installation, when you arrive at the 'Tools for Native Modules' screen you need to select the box to:\n\t'Automatically install the necessary tools...Chocolatey...'");
console.log("Doing this will cause a pop-up script in a new window which will install many npm/node tools and dependencies for use within the WinOS ecosystem.");
console.log("2.) When the installations finally complete you need to navigate back to your Superalgos directory and run `node setup` again.\n");
}