This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.js
65 lines (51 loc) · 2.22 KB
/
install.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
'use strict'
const spawn = require('child_process').spawn
const os = require('os')
const EventEmitter = require('events')
const ee = new EventEmitter()
const path = require('path')
const pathTo27 = 'deps/python/2.7'
let v27 = '2.7'
/*
* This is the install script which runs on 'npm pre-install'.
* Not much magic. It just `./configure`s, `make && make install`s inside cpython directory.
* Most of the code here presents the users output and errors into the console and pretty-prints stuff.
*
*/
let configureOpts = [
`--prefix=${process.cwd()}/deps/python/${v27}/build`,
`--exec-prefix=${process.cwd()}/deps/python/${v27}/build`,
// "--with-PACKAGE=no",
'--without-doc-strings',
'-q'
]
// TODO: do both in a child process.
let time = process.hrtime()
let configure27 = spawn('./configure', configureOpts, {cwd: pathTo27, stdio: 'inherit'})
configure27.on('close', function (code) {
let diff = process.hrtime(time)
let prettyTime = '[' + ('0' + ~~(diff[0] / 60)).slice(-2) + ':' + ( '0'+ diff[0] % 60).slice(-2) + '] mm:ss'
console.log('\n' + 'Configure: child process exited with code ' + code + '\n' + 'after ' + prettyTime + '\n')
ee.emit('done:configure')
})
ee.on('done:configure', function() {
let time = process.hrtime()
let makeOpts = ['-j' + os.cpus().length, '--silent'] // run make in parrallel with max. cpus
let make27 = spawn('make', makeOpts, {cwd: pathTo27, stdio: 'inherit'})
make27.on('close', function (code) {
let diff = process.hrtime(time)
let prettyTime = '[' + ('0' + ~~(diff[0] / 60)).slice(-2) + ':' + ( '0'+ diff[0] % 60).slice(-2) + '] mm:ss'
console.log('\n' + 'make: child process exited with code ' + code + '\n' + 'after ' + prettyTime + '\n')
ee.emit('done:make')
})
})
ee.on('done:make', function() {
let time = process.hrtime()
let installOpts = ['install','--silent']
let makeInstall27 = spawn('make', installOpts, {cwd: pathTo27, stdio: 'inherit'})
makeInstall27.on('close', function (code) {
let diff = process.hrtime(time)
let prettyTime = '[' + ('0' + ~~(diff[0] / 60)).slice(-2) + ':' + ( '0'+ diff[0] % 60).slice(-2) + '] mm:ss'
console.log('\n' + 'make install: child process exited with code ' + code + '\n' + 'after ' + prettyTime + '\n')
})
})