* GitHub Actions: npm test is failing Windows tests on M1 Macs
`npm test` is running and failing Windows `find-visualstudio` tests on an M1 Mac!!!
These tests are not being run or not failing on Intel Macs.
* Only run "Find Visual Studio" tests on Windows
* Update test/test-find-visualstudio.js
Co-authored-by: Christian Clauss <cclauss@me.com>
---------
Co-authored-by: Stefan Stojanovic <StefanStojanovic@users.noreply.github.com>
* lib: print Python executable path using UTF-8
The Python executable path may have non-ASCII characters, which can make
the print function fail if the environment encoding is different. This fixes
this issue by using stdout.buffer, which can be used with UTF-8 encoding
for the output, regardless of the environment encoding.
Fixes: https://github.com/nodejs/node-gyp/issues/2829
* fixup! lib: print Python executable path using UTF-8
Detect visual studio installation using the VSSetup module and
Get-VSSetupInstance method. It works even in systems with the
Constrained language mode of PowerShell.
Some linux distros allow headers to be installed through
tools like rpm. If the runtime sets
process.config.variables.use_prefix_to_find_headers, look
for matching headers based on the directory set for the
prefix in process.config.variables.prefix
Signed-off-by: Michael Dawson <midawson@redhat.com>
Co-authored-by: Luke Karrys <luke@lukekarrys.com>
* chore: misc test fixes
* Sort test runs by os first
* Use cross-env for test env var
* Try sorting matrix params
* Make FAST_TEST the default and rename to FULL_TEST
* Separate helper functions to not need to export test obj in files
BREAKING CHANGE: the `Gyp` class exported is now created using
ECMAScript classes and therefore might have small differences to classes
that were previously created with `util.inherits`.
BREAKING CHANGE: All internal functions have been coverted to return
promises and no longer accept callbacks. This is not a breaking change
for users but may be breaking to consumers of `node-gyp` if you are
requiring internal functions directly.
* fix: create Python symlink only during builds, and clean it up after
Previously in b9ddcd5bbd this was created
during configuration, and the symlink persisted indefinitely. This
causes problems with many tools that do not expect a codebase to include
symlinks to external absolute paths.
This PR largely reverts that commit, and instead writes the path to
link to into the config, and then creates the symlink only temporarily
during the build process, always deleting it afterwards.
* assert install_path == self.output, f"{install_path} != {self.output}"
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Instead of downloading node.lib for all architectures, just download the
one that will be needed. Install.js changed to enable downloading just
node.lib for node versions that already have tarball downloaded and
extracted. Not fetching lib now fails the installation. Increased
installVersion because of the changes.
Refs: https://github.com/nodejs/node-gyp/issues/2847
* migrate from tap to mocha
After make-fetch-happen update GitHub Actions started failing. Migrating
from tap to mocha testing framework for GitHub Action stability.
* write custom test reporter for more verbose output
Implemented a simple custom mocha test reporter to replace the default
one. Made test report more developer friendly.
* fix: check for errors while extracting downloaded tarball
Signed-off-by: David Sanders <dsanders11@ucsbalum.com>
* test: parallel installs
Signed-off-by: David Sanders <dsanders11@ucsbalum.com>
* fix: extract tarball to temp directory on Windows
Signed-off-by: David Sanders <dsanders11@ucsbalum.com>
---------
Signed-off-by: David Sanders <dsanders11@ucsbalum.com>
Python 3.9 on IBM i now properly returns "os400" for sys.platform
instead of claiming to be AIX as it did previously. While the IBM i PASE
environment is compatible with AIX, it is a subset and has numerous
differences which makes it beneficial to distinguish, however this means
that it now needs explicit support here.
* lib: create a Python symlink and add it to PATH
Helps to ensure a version of Python validated by lib/find-python.js
is used to run various Python scripts generated by gyp.
Known to affect gyp-mac-tool, probably affects gyp-flock-tool as well.
These Python scripts (such as `gyp-mac-tool`) are invoked directly,
via the generated Makefile, so their shebang lines determine
which Python binary is used to run them.
The shebang lines of these scripts are all `#!/usr/bin/env python3`,
so the first `python3` on the user's PATH will be used.
By adding a symlink to the Python binary validated by find-python.js,
and putting this symlink first on the PATH, we can ensure we use
a compatible version of Python to run these scripts.
(Only on Unix/Unix-like OSes. Symlinks are tricky on Windows,
and Python isn't used at build-time anyhow on Windows,
so this intervention isn't useful or necessary on Windows.
A similar technique for Windows, no symlinks required,
would be to make batch scripts which execute the target binary,
much like what Node does for its bundled copy of npm on Windows.)
* test: update mocked graceful-fs for configure test
Add missing functions "unlink()" and "symlink()" to mocked module.
* lib: log any errors when creating Python symlink
Warn users about errors, but continue on in case the user does
happen to have new enough Python on their PATH.
(The symlinks are only meant to fix an issue in a corner case,
where the user told `node-gyp` where new enough Python is,
but it's not the first `python3` on their PATH.
We should not introduce a new potential failure mode to all users
when fixing this bug. So no hard errors during the symlink process.)
* lib: improve error formatting for Python symlink
Logging the entire error object shows the stack twice,
and all the other information is contained in the stack.
It also messes with the order of what is logged.
Rather than logging a bunch of redundant information in a messy way,
we can log only the stack. Logging it in a separate log.warn()
also gets rid of an extra space character at the beginning of the line.
* lib: restore err.errno to logs for symlink errors
This info (err.errno) is the only piece of information
in the error object that is not redundant to err.stack.
* lib: use log.verbose, not log.warn
These messages aren't important enough to be `log.warn`s.
Log as verbose only; they will also appear in full error output.
bundling in certs.js rather than including the raw files should avoid some
false positives that low-quality security scanners keep on complaining about.
test/test-configure-python.js downloads a fresh set of headers to the
package directory each time. By setting to the default global cache dir
we get to re-use cached headers and skip the download step.
PR-URL: https://github.com/nodejs/node-gyp/pull/1796
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Windows on Arm support is available in some versions of Node.js v12 and
Electron v6. This update allows node-gyp to fetch the appropriate
node.lib to build native modules. If an arm64 binary is not available
for the target node version, it's logged but ignored.
arm64 is not expected to work in very old node.lib distribution formats,
the test URLs in these cases are added to be consistent with x64.
PR-URL: https://github.com/nodejs/node-gyp/pull/1875
Reviewed-By: João Reis <reis@janeasystems.com>
This allows us to start testing Python 3 without breaking node-gyp
for users.
This also adds support for NODE_GYP_FORCE_PYTHON, which will be the
only Python binary acceptable when defined.
PR-URL: https://github.com/nodejs/node-gyp/pull/1815
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>