Commit graph

21 commits

Author SHA1 Message Date
Hüseyin Açacak
c4729129da
lib: print Python executable path using UTF-8 (#2995)
* 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
2024-03-13 09:20:35 -07:00
Luke Karrys
d52997e975 feat: convert internal classes from util.inherits to classes
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`.
2023-10-28 09:29:04 -07:00
Luke Karrys
355622f4aa feat: convert all internal functions to async/await
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.
2023-10-28 08:59:57 -07:00
Luke Karrys
192eec2aca
Sync deps and engines with npm (#2770)
* feat!: update `engines.node` to `^14.17.0 || ^16.13.0 || >=18.0.0`

* deps: nopt@^7.0.0

* feat: replace npmlog with proc-log

* deps: standard@17.0.0 and fix linting errors

* deps: which@3.0.0
- this also promiisifies the build command

* deps: glob@8.0.3

* feat: drop rimraf dependency

* fix: use fs/promises in favor of fs.promises
2023-06-20 15:44:18 +02:00
Stefan Stojanovic
5df2b72a8f
Migration from tap to mocha (#2851)
* 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.
2023-06-05 17:05:29 +02:00
DeeDeeG
1bd18f3e77
lib: drop Python 2 support in find-python.js (#2333)
Co-authored-by: Christian Clauss <cclauss@me.com>

PR-URL: https://github.com/nodejs/node-gyp/pull/2333
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2021-03-26 19:57:06 +08:00
DeeDeeG
c255ffbf6a
lib: drop "-2" flag for "py.exe" launcher
Now that node-gyp supports both Python 2 and Python 3,
We don't need to explicitly try to find only Python 2.

Fixes: https://github.com/nodejs/node-gyp/issues/2130
Refs: https://docs.python.org/3/using/windows.html#launcher
PR-URL: https://github.com/nodejs/node-gyp/pull/2131
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2020-05-18 11:08:46 +10:00
Sam Roberts
dd0e97ef0b
lib: try to find python after python3
Unadorned `python` can be either Python 2 or Python 3, but it is likely
to be Python 2 for quite a while.

To find Python3, it is recommended to use the explicit name `python3`.

See:
- https://www.python.org/dev/peps/pep-0394/#for-python-runtime-distributors
- https://github.com/nodejs/node-gyp/pull/1892#issuecomment-537637433

PR-URL: https://github.com/nodejs/node-gyp/pull/1907
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-10-04 13:25:04 +10:00
João Reis
a2a862f6ba test: accept Python 3 in test-find-python.js
Fixes: https://github.com/nodejs/node-gyp/issues/1826
PR-URL: https://github.com/nodejs/node-gyp/pull/1843
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Matt Cowley <me@mattcowley.co.uk>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-07-26 15:40:15 +01:00
João Reis
66ad305775 python: accept Python 3 conditionally
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>
2019-07-11 05:13:59 +01:00
João Reis
7e7fce3fed python: move Python detection to its own file
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>
2019-07-11 05:13:59 +01:00
Rod Vagg
e40c99e283
src: implement standard.js linting
In addition:

* moved module.exports to the bottom
* no single-line if statements
* no if statements without a {
* const for requires
* array declarations get spaces inside [ ]
* 'use strict' in all .js files

PR-URL: https://github.com/nodejs/node-gyp/pull/1794
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-07-06 14:36:37 +10:00
Rod Vagg
a52c6eb9e8
test: migrate from tape to tap
PR-URL: https://github.com/nodejs/node-gyp/pull/1795
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-06-25 11:26:08 +10:00
João Reis
43031fadcb
python: clean-up detection
Try everything until Python is found.

PR-URL: https://github.com/nodejs/node-gyp/pull/1582
Reviewed-By: Rod Vagg <rod@vagg.org>
2019-04-24 10:29:00 +10:00
Refael Ackermann
49ab79d221
python: more informative error
PR-URL: https://github.com/nodejs/node-gyp/pull/1269
Refs: https://github.com/nodejs/node-gyp/pull/1582
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-04-24 10:29:00 +10:00
Jon Moss
a5b7410497
Add ESLint no-unused-vars rule
- Uses `.eslintrc.yaml` for configuration
- `npm run lint` is part of `npm test`

PR-URL: https://github.com/nodejs/node-gyp/pull/1497
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-04-24 10:27:29 +10:00
Yang Guo
536759c7e9 configure: use sys.version_info to get python version
This is cleaner than filtering additional strings from
platform.python_version().

PR-URL: https://github.com/nodejs/node-gyp/pull/1504
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Rod Vagg <rod@vagg.org>
2018-08-09 10:45:12 +10:00
Ben Noordhuis
49801716c2
test: fix test-find-python on v0.10.x buildbot.
Work around a v0.10.x CI issue where path.resolve() on UNIX systems
prefixes Windows paths with the current working directory.

v0.12 and up are free of this issue because they use
path.win32.resolve() which does the right thing.

PR-URL: https://github.com/nodejs/node-gyp/pull/1172
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-04-25 15:52:51 +01:00
Ben Noordhuis
37ae7be114 Try python launcher when stock python is python 3.
Consult the python launcher when the python on the path is python 3.
If a python 2 exists on the system, it will tell us.

Fixes: https://github.com/nodejs/node-gyp/issues/987
PR-URL: https://github.com/nodejs/node-gyp/pull/992
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-10-08 10:45:36 +02:00
Ben Noordhuis
e3778d9907 Add lots of findPython() tests.
Break up findPython() into pieces that can be tested in isolation and
add tests that do so.

PR-URL: https://github.com/nodejs/node-gyp/pull/992
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-10-08 10:45:03 +02:00
Ben Noordhuis
817ed9bd78 Add test for python executable search logic.
Break out the search logic into a separate function and add a regression
test.

References: https://github.com/nodejs/node-gyp/pull/668
PR-URL: https://github.com/nodejs/node-gyp/pull/756
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-11-24 14:59:38 +01:00