Comparing version 3.1.0 to 3.2.0
@@ -22,5 +22,11 @@ | ||
function build (gyp, argv, callback) { | ||
var platformMake = 'make' | ||
if (process.platform === 'aix') { | ||
platformMake = 'gmake' | ||
} else if (process.platform.indexOf('bsd') !== -1) { | ||
platformMake = 'gmake' | ||
} | ||
var release = processRelease(argv, gyp, process.version, process.release) | ||
, makeCommand = gyp.opts.make || process.env.MAKE | ||
|| (process.platform.indexOf('bsd') != -1 ? 'gmake' : 'make') | ||
, makeCommand = gyp.opts.make || process.env.MAKE || platformMake | ||
, command = win ? 'msbuild' : makeCommand | ||
@@ -27,0 +33,0 @@ , buildDir = path.resolve('build') |
module.exports = exports = configure | ||
module.exports.test = { findPython: findPython } | ||
@@ -22,2 +23,3 @@ /** | ||
, win = process.platform == 'win32' | ||
, findNodeDirectory = require('./find-node-directory') | ||
@@ -35,94 +37,11 @@ exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module' | ||
checkPython() | ||
// Check if Python is in the $PATH | ||
function checkPython () { | ||
log.verbose('check python', 'checking for Python executable "%s" in the PATH', python) | ||
which(python, function (err, execPath) { | ||
if (err) { | ||
log.verbose('`which` failed', python, err) | ||
if (python === 'python2') { | ||
python = 'python' | ||
return checkPython() | ||
} | ||
if (win) { | ||
guessPython() | ||
} else { | ||
failNoPython() | ||
} | ||
} else { | ||
log.verbose('`which` succeeded', python, execPath) | ||
checkPythonVersion() | ||
} | ||
}) | ||
} | ||
// Called on Windows when "python" isn't available in the current $PATH. | ||
// We're gonna check if "%SystemDrive%\python27\python.exe" exists. | ||
function guessPython () { | ||
log.verbose('could not find "' + python + '". guessing location') | ||
var rootDir = process.env.SystemDrive || 'C:\\' | ||
if (rootDir[rootDir.length - 1] !== '\\') { | ||
rootDir += '\\' | ||
findPython(python, function (err, found) { | ||
if (err) { | ||
callback(err) | ||
} else { | ||
python = found | ||
getNodeDir() | ||
} | ||
var pythonPath = path.resolve(rootDir, 'Python27', 'python.exe') | ||
log.verbose('ensuring that file exists:', pythonPath) | ||
fs.stat(pythonPath, function (err, stat) { | ||
if (err) { | ||
if (err.code == 'ENOENT') { | ||
failNoPython() | ||
} else { | ||
callback(err) | ||
} | ||
return | ||
} | ||
python = pythonPath | ||
checkPythonVersion() | ||
}) | ||
} | ||
}) | ||
function checkPythonVersion () { | ||
var env = extend({}, process.env) | ||
env.TERM = 'dumb' | ||
execFile(python, ['-c', 'import platform; print(platform.python_version());'], { env: env }, function (err, stdout) { | ||
if (err) { | ||
return callback(err) | ||
} | ||
log.verbose('check python version', '`%s -c "import platform; print(platform.python_version());"` returned: %j', python, stdout) | ||
var version = stdout.trim() | ||
if (~version.indexOf('+')) { | ||
log.silly('stripping "+" sign(s) from version') | ||
version = version.replace(/\+/g, '') | ||
} | ||
if (~version.indexOf('rc')) { | ||
log.silly('stripping "rc" identifier from version') | ||
version = version.replace(/rc(.*)$/ig, '') | ||
} | ||
var range = semver.Range('>=2.5.0 <3.0.0') | ||
var valid = false | ||
try { | ||
valid = range.test(version) | ||
} catch (e) { | ||
log.silly('range.test() error', e) | ||
} | ||
if (valid) { | ||
getNodeDir() | ||
} else { | ||
failPythonVersion(version) | ||
} | ||
}) | ||
} | ||
function failNoPython () { | ||
callback(new Error('Can\'t find Python executable "' + python + | ||
'", you can set the PYTHON env variable.')) | ||
} | ||
function failPythonVersion (badVersion) { | ||
callback(new Error('Python executable "' + python + | ||
'" is v' + badVersion + ', which is not supported by gyp.\n' + | ||
'You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.')) | ||
} | ||
function getNodeDir () { | ||
@@ -304,2 +223,30 @@ | ||
// for AIX we need to set up the path to the exp file | ||
// which contains the symbols needed for linking. | ||
// The file will either be in one of the following | ||
// depending on whether it is an installed or | ||
// development environment: | ||
// - the include/node directory | ||
// - the out/Release directory | ||
// - the out/Debug directory | ||
// - the root directory | ||
var node_exp_file = '' | ||
if (process.platform === 'aix') { | ||
var node_root_dir = findNodeDirectory() | ||
var candidates = ['include/node/node.exp', | ||
'out/Release/node.exp', | ||
'out/Debug/node.exp', | ||
'node.exp'] | ||
for (var next = 0; next < candidates.length; next++) { | ||
node_exp_file = path.resolve(node_root_dir, candidates[next]) | ||
try { | ||
fs.accessSync(node_exp_file, fs.R_OK) | ||
// exp file found, stop looking | ||
break | ||
} catch (exception) { | ||
// this candidate was not found or not readable, do nothing | ||
} | ||
} | ||
} | ||
// this logic ported from the old `gyp_addon` python file | ||
@@ -325,2 +272,5 @@ var gyp_script = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py') | ||
argv.push('-Dnode_root_dir=' + nodeDir) | ||
if (process.platform === 'aix') { | ||
argv.push('-Dnode_exp_file=' + node_exp_file) | ||
} | ||
argv.push('-Dnode_gyp_dir=' + nodeGypDir) | ||
@@ -367,1 +317,99 @@ argv.push('-Dnode_lib_file=' + release.name + '.lib') | ||
} | ||
function findPython (python, callback) { | ||
checkPython() | ||
// Check if Python is in the $PATH | ||
function checkPython () { | ||
log.verbose('check python', 'checking for Python executable "%s" in the PATH', python) | ||
which(python, function (err, execPath) { | ||
if (err) { | ||
log.verbose('`which` failed', python, err) | ||
if (python === 'python2') { | ||
python = 'python' | ||
return checkPython() | ||
} | ||
if (win) { | ||
guessPython() | ||
} else { | ||
failNoPython() | ||
} | ||
} else { | ||
log.verbose('`which` succeeded', python, execPath) | ||
// Found the `python` exceutable, and from now on we use it explicitly. | ||
// This solves #667 and #750 (`execFile` won't run batch files | ||
// (*.cmd, and *.bat)) | ||
python = execPath | ||
checkPythonVersion() | ||
} | ||
}) | ||
} | ||
// Called on Windows when "python" isn't available in the current $PATH. | ||
// We're gonna check if "%SystemDrive%\python27\python.exe" exists. | ||
function guessPython () { | ||
log.verbose('could not find "' + python + '". guessing location') | ||
var rootDir = process.env.SystemDrive || 'C:\\' | ||
if (rootDir[rootDir.length - 1] !== '\\') { | ||
rootDir += '\\' | ||
} | ||
var pythonPath = path.resolve(rootDir, 'Python27', 'python.exe') | ||
log.verbose('ensuring that file exists:', pythonPath) | ||
fs.stat(pythonPath, function (err, stat) { | ||
if (err) { | ||
if (err.code == 'ENOENT') { | ||
failNoPython() | ||
} else { | ||
callback(err) | ||
} | ||
return | ||
} | ||
python = pythonPath | ||
checkPythonVersion() | ||
}) | ||
} | ||
function checkPythonVersion () { | ||
var env = extend({}, process.env) | ||
env.TERM = 'dumb' | ||
execFile(python, ['-c', 'import platform; print(platform.python_version());'], { env: env }, function (err, stdout) { | ||
if (err) { | ||
return callback(err) | ||
} | ||
log.verbose('check python version', '`%s -c "import platform; print(platform.python_version());"` returned: %j', python, stdout) | ||
var version = stdout.trim() | ||
if (~version.indexOf('+')) { | ||
log.silly('stripping "+" sign(s) from version') | ||
version = version.replace(/\+/g, '') | ||
} | ||
if (~version.indexOf('rc')) { | ||
log.silly('stripping "rc" identifier from version') | ||
version = version.replace(/rc(.*)$/ig, '') | ||
} | ||
var range = semver.Range('>=2.5.0 <3.0.0') | ||
var valid = false | ||
try { | ||
valid = range.test(version) | ||
} catch (e) { | ||
log.silly('range.test() error', e) | ||
} | ||
if (valid) { | ||
callback(null, python) | ||
} else { | ||
failPythonVersion(version) | ||
} | ||
}) | ||
} | ||
function failNoPython () { | ||
callback(new Error('Can\'t find Python executable "' + python + | ||
'", you can set the PYTHON env variable.')) | ||
} | ||
function failPythonVersion (badVersion) { | ||
callback(new Error('Python executable "' + python + | ||
'" is v' + badVersion + ', which is not supported by gyp.\n' + | ||
'You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.')) | ||
} | ||
} |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"installVersion": 9, | ||
@@ -17,0 +17,0 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)", |
@@ -41,7 +41,7 @@ node-gyp | ||
* `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) (already installed on Mac OS X) | ||
* [Xcode](https://developer.apple.com/xcode/downloads/) | ||
* [Xcode](https://developer.apple.com/xcode/download/) | ||
* You also need to install the `Command Line Tools` via Xcode. You can find this under the menu `Xcode -> Preferences -> Downloads` | ||
* This step will install `gcc` and the related toolchain containing `make` | ||
* On Windows: | ||
* [Python][windows-python] ([`v2.7.3`][windows-python-v2.7.3] recommended, `v3.x.x` is __*not*__ supported) | ||
* Python ([`v2.7.10`][python-v2.7.10] recommended, `v3.x.x` is __*not*__ supported) | ||
* Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder | ||
@@ -54,2 +54,10 @@ * Windows XP/Vista/7: | ||
* Microsoft Visual Studio C++ 2013 for Windows Desktop ([Express][msvc2013] version works well) | ||
* Windows 10: | ||
* Install the latest version of npm (3.3.6 at the time of writing) | ||
* Install Python 2.7 from https://www.python.org/download/releases/2.7/ and make sure its on the System Path | ||
* Install Visual Studio Community 2015 Edition. (Custom Install, Select Visual C++ during the installation) | ||
* Set the environment variable GYP_MSVS_VERSION=2015 | ||
* Run the command prompt as Administrator | ||
* $ npm install (--msvs_version=2015) <-- Shouldn't be needed if you have set GYP_MSVS_VERSION env | ||
* If the above steps have not worked or you are unsure please visit http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64 for a full walkthrough | ||
* All Windows Versions | ||
@@ -141,5 +149,5 @@ * For 64-bit builds of node and native modules you will _**also**_ need the [Windows 7 64-bit SDK][win7sdk] | ||
* ["Going Native" a nodeschool.io tutorial](http://nodeschool.io/#goingnative) | ||
* ["Hello World" node addon example](https://github.com/joyent/node/tree/master/test/addons/hello-world) | ||
* [gyp user documentation](https://chromium.googlesource.com/external/gyp/+/master/docs/UserDocumentation.md) | ||
* [gyp input format reference](https://chromium.googlesource.com/external/gyp/+/master/docs/InputFormatReference.md) | ||
* ["Hello World" node addon example](https://github.com/nodejs/node/tree/master/test/addons/hello-world) | ||
* [gyp user documentation](https://gyp.gsrc.io/docs/UserDocumentation.md) | ||
* [gyp input format reference](https://gyp.gsrc.io/docs/InputFormatReference.md) | ||
* [*"binding.gyp" files out in the wild* wiki page](https://github.com/nodejs/node-gyp/wiki/%22binding.gyp%22-files-out-in-the-wild) | ||
@@ -191,6 +199,5 @@ | ||
[windows-python]: http://www.python.org/getit/windows | ||
[windows-python-v2.7.3]: http://www.python.org/download/releases/2.7.3#download | ||
[msvc2013]: http://www.microsoft.com/en-gb/download/details.aspx?id=44914 | ||
[win7sdk]: http://www.microsoft.com/en-us/download/details.aspx?id=8279 | ||
[compiler update for the Windows SDK 7.1]: http://www.microsoft.com/en-us/download/details.aspx?id=4422 | ||
[python-v2.7.10]: https://www.python.org/downloads/release/python-2710/ | ||
[msvc2013]: https://www.microsoft.com/en-gb/download/details.aspx?id=44914 | ||
[win7sdk]: https://www.microsoft.com/en-us/download/details.aspx?id=8279 | ||
[compiler update for the Windows SDK 7.1]: https://www.microsoft.com/en-us/download/details.aspx?id=4422 |
@@ -9,2 +9,7 @@ 'use strict'; | ||
// `npm test` dumps a ton of npm_config_* variables in the environment. | ||
Object.keys(process.env) | ||
.filter(function(key) { return /^npm_config_/.test(key) }) | ||
.forEach(function(key) { delete process.env[key] }) | ||
// Zero-length keys should get filtered out. | ||
@@ -11,0 +16,0 @@ process.env.npm_config_ = '42' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1595881
104
2106
200
28
7