Skip to content

Commit

Permalink
docs: README.md Do not hardcode the supported versions of Python (#2880)
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Aug 25, 2023
1 parent 0f1f667 commit bb93b94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 123 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Expand Up @@ -13,8 +13,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: pip install --user ruff
- run: ruff --format=github --select="E,F,PLC,PLE,UP,W,YTT" --ignore="PLC1901,S101,UP031" --target-version=py37 .
- run: ruff --format=github --select="E,F,PLC,PLE,UP,W,YTT" --ignore="E721,PLC1901,S101,UP031" --target-version=py38 .
Tests:
needs: Lint_Python # Lint_Python takes ~5 seconds, so wait for it to pass before running the full matrix of tests.
strategy:
fail-fast: false
max-parallel: 15
Expand Down
40 changes: 22 additions & 18 deletions README.md
Expand Up @@ -6,7 +6,8 @@
`node-gyp` is a cross-platform command-line tool written in Node.js for
compiling native addon modules for Node.js. It contains a vendored copy of the
[gyp-next](https://github.com/nodejs/gyp-next) project that was previously used
by the Chromium team, extended to support the development of Node.js native addons.
by the Chromium team and extended to support the development of Node.js native
addons.

Note that `node-gyp` is _not_ used to build Node.js itself.

Expand All @@ -31,23 +32,22 @@ Depending on your operating system, you will need to install:

### On Unix

* Python v3.7, v3.8, v3.9, or v3.10
* [A supported version of Python](https://devguide.python.org/versions/)
* `make`
* A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org)

### On macOS

**ATTENTION**: If your Mac has been _upgraded_ to macOS Catalina (10.15) or higher, please read [macOS_Catalina.md](macOS_Catalina.md).

* Python v3.7, v3.8, v3.9, or v3.10
* [A supported version of Python](https://devguide.python.org/versions/)
* `XCode Command Line Tools` which will install `clang`, `clang++`, and `make`.
* Install the `XCode Command Line Tools` standalone by running `xcode-select --install`. -- OR --
* Alternatively, if you already have the [full Xcode installed](https://developer.apple.com/xcode/download/), you can install the Command Line Tools under the menu `Xcode -> Open Developer Tool -> More Developer Tools...`.


### On Windows

Install the current version of Python from the [Microsoft Store package](https://www.microsoft.com/en-us/p/python-310/9pjpw5ldxlz5).
Install the current [version of Python](https://devguide.python.org/versions/) from the
[Microsoft Store](https://apps.microsoft.com/store/search?publisher=Python+Software+Foundation).

Install tools and configuration manually:
* Install Visual C++ Build Environment: [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools)
Expand All @@ -62,9 +62,9 @@ Install tools and configuration manually:

### Configuring Python Dependency

`node-gyp` requires that you have installed a compatible version of Python, one of: v3.7, v3.8,
v3.9, or v3.10. If you have multiple Python versions installed, you can identify which Python
version `node-gyp` should use in one of the following ways:
`node-gyp` requires that you have installed a [supported version of Python](https://devguide.python.org/versions/).
If you have multiple versions of Python installed, you can identify which version
`node-gyp` should use in one of the following ways:

1. by setting the `--python` command-line option, e.g.:

Expand All @@ -73,24 +73,28 @@ node-gyp <command> --python /path/to/executable/python
```

2. If `node-gyp` is called by way of `npm`, *and* you have multiple versions of
Python installed, then you can set `npm`'s 'python' config key to the appropriate
value:

Python installed, then you can set the `npm_config_python` environment variable
to the appropriate path:
``` bash
npm config set python /path/to/executable/python
export npm_config_python=/path/to/executable/python
```
&nbsp;&nbsp;&nbsp;&nbsp;Or on Windows:
```console
py --list-paths # To see the installed Python versions
set npm_config_python=C:\path\to\python.exe
```

3. If the `PYTHON` environment variable is set to the path of a Python executable,
then that version will be used, if it is a compatible version.
then that version will be used if it is a supported version.

4. If the `NODE_GYP_FORCE_PYTHON` environment variable is set to the path of a
Python executable, it will be used instead of any of the other configured or
builtin Python search paths. If it's not a compatible version, no further
built-in Python search paths. If it's not a compatible version, no further
searching will be done.

### Build for Third Party Node.js Runtimes

When building modules for third party Node.js runtimes like Electron, which have
When building modules for third-party Node.js runtimes like Electron, which have
different build configurations from the official Node.js distribution, you
should use `--dist-url` or `--nodedir` flags to specify the headers of the
runtime to build for.
Expand All @@ -106,7 +110,7 @@ to work around configuration errors.

## How to Use

To compile your native addon, first go to its root directory:
To compile your native addon first go to its root directory:

``` bash
cd my_node_addon
Expand Down Expand Up @@ -240,7 +244,7 @@ Or this on Windows:
set npm_config_devdir=c:\temp\.gyp
```

### `npm` configuration
### `npm` configuration for npm versions before v9

Use the form `OPTION_NAME` for any of the command options listed above.

Expand Down
104 changes: 0 additions & 104 deletions macOS_Catalina.md

This file was deleted.

0 comments on commit bb93b94

Please sign in to comment.