From 874233e19748f584f73461d636d4ae9f86a88c7b Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:06:44 -0700 Subject: [PATCH] Get node-gyp to run with Python 3.12-dev and Node 18 (#201) * 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 https://github.com/npm/cli/issues/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 --- .github/workflows/node-gyp.yml | 24 +++++++++++++++++++----- pylib/gyp/input.py | 4 ++-- pyproject.toml | 4 ++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 855ecbd7..13bd52bd 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -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: @@ -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 @@ -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" diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py index b6464e98..644bc505 100644 --- a/pylib/gyp/input.py +++ b/pylib/gyp/input.py @@ -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 = [ @@ -1180,7 +1180,7 @@ def EvalSingleCondition(cond_expr, true_dict, false_dict, phase, variables, buil else: ast_code = compile(cond_expr_expanded, "", "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 diff --git a/pyproject.toml b/pyproject.toml index 3c4020b2..89cf8958 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -86,12 +87,15 @@ select = [ # "TRY", # tryceratops ] ignore = [ + "E721", "PLC1901", "PLR0402", + "PLR1714", "PLR2004", "PLR5501", "PLW0603", "PLW2901", + "PYI024", "RUF005", "RUF012", "UP031",