Skip to content

Commit

Permalink
Get node-gyp to run with Python 3.12-dev and Node 18 (#201)
Browse files Browse the repository at this point in the history
* Add Python 3.12 beta 1 to testing

* Use packaging instead of distutils

* Ignore PLR1714 for now

* Add packaging as a dependency

* Install Python dependencies in CI

* Add another install command

* Try setting env var

* Rework pwsh script

* Try using batch

* use npm config set

* Work around npm/cli#6126

* Pass file rather than directory

* Remove gyp-next self-install

* uninstall, not remove

* Add -y

* Ignore the latest lint rules

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
  • Loading branch information
rzhao271 and cclauss authored Aug 26, 2023
1 parent d2dfe4e commit 874233e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/node-gyp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python: ["3.8", "3.x"]
python: ["3.8", "3.x", "3.12-dev"]

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -26,11 +26,17 @@ jobs:
path: node-gyp
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18.x
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
- name: Install Python dependencies
run: |
cd gyp-next
python -m pip install --upgrade pip setuptools
pip install --editable .
pip uninstall -y gyp-next
- name: Install Node.js dependencies
run: |
cd node-gyp
npm install --no-progress
Expand All @@ -39,7 +45,15 @@ jobs:
run: |
rm -rf node-gyp/gyp
cp -r gyp-next node-gyp/gyp
- name: Run tests
- name: Run tests (macOS or Linux)
if: runner.os != 'Windows'
shell: bash
run: |
cd node-gyp
npm test --python="${pythonLocation}/python"
- name: Run tests (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd node-gyp
npm test
npm run test --python="${env:pythonLocation}\\python.exe"
4 changes: 2 additions & 2 deletions pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import sys
import threading
import traceback
from distutils.version import StrictVersion
from gyp.common import GypError
from gyp.common import OrderedSet
from packaging.version import Version

# A list of types that are treated as linkable.
linkable_types = [
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def EvalSingleCondition(cond_expr, true_dict, false_dict, phase, variables, buil
else:
ast_code = compile(cond_expr_expanded, "<string>", "eval")
cached_conditions_asts[cond_expr_expanded] = ast_code
env = {"__builtins__": {}, "v": StrictVersion}
env = {"__builtins__": {}, "v": Version}
if eval(ast_code, env, variables):
return true_dict
return false_dict
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description = "A fork of the GYP build system for use in the Node.js projects"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.8"
dependencies = ["packaging>=23.1"]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
Expand Down Expand Up @@ -86,12 +87,15 @@ select = [
# "TRY", # tryceratops
]
ignore = [
"E721",
"PLC1901",
"PLR0402",
"PLR1714",
"PLR2004",
"PLR5501",
"PLW0603",
"PLW2901",
"PYI024",
"RUF005",
"RUF012",
"UP031",
Expand Down

0 comments on commit 874233e

Please sign in to comment.