From 960321a69e520a49427932474eb5ace767bcf15d Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 30 May 2023 16:08:05 +0200 Subject: [PATCH 01/16] Add Python 3.12 beta 1 to testing --- .github/workflows/node-gyp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 855ecbd7..4bf71f5d 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,7 +26,7 @@ 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 }} From 05ba71d4270779f9ff2ceca4341725a58d845040 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:16:42 -0700 Subject: [PATCH 02/16] Use packaging instead of distutils --- pylib/gyp/input.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 39e4a373b7f0d6b2b1daef4e47e20b00a02d9a81 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:26:34 -0700 Subject: [PATCH 03/16] Ignore PLR1714 for now --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 3c4020b2..b4f55ba8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,7 @@ select = [ ignore = [ "PLC1901", "PLR0402", + "PLR1714", "PLR2004", "PLR5501", "PLW0603", From 5dfef14ce80c7c7e91e5abc36a777fac63332d99 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:58:55 -0700 Subject: [PATCH 04/16] Add packaging as a dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index b4f55ba8..2d3875ce 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", From 2410e5b835e3f50b8005775be41702b4f93d130f Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:08:42 -0700 Subject: [PATCH 05/16] Install Python dependencies in CI --- .github/workflows/node-gyp.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 4bf71f5d..cf8cbe69 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -30,7 +30,11 @@ jobs: - 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 + - name: Install Node.js dependencies run: | cd node-gyp npm install --no-progress From 4b523f5eb6de6d8216c7f56c3dbf84b2e53d0ddc Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:23:35 -0700 Subject: [PATCH 06/16] Add another install command --- .github/workflows/node-gyp.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index cf8cbe69..a75a5ef7 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -34,6 +34,7 @@ jobs: run: | cd gyp-next python -m pip install --upgrade pip setuptools + pip install --editable . - name: Install Node.js dependencies run: | cd node-gyp From 51e87b6f7c368e150de9b1e0af6926e13ba2537a Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Sun, 30 Jul 2023 17:15:27 -0700 Subject: [PATCH 07/16] Try setting env var --- .github/workflows/node-gyp.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index a75a5ef7..7c4a99b1 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -44,7 +44,19 @@ jobs: run: | rm -rf node-gyp/gyp cp -r gyp-next node-gyp/gyp - - name: Run tests + - name: Run tests (POSIX) + if: runner.os != 'Windows' + shell: bash + run: | + export NODE_GYP_FORCE_PYTHON="${pythonLocation}" + echo "Python is at ${pythonLocation}" + cd node-gyp + npm test + - name: Run tests (Windows) + if: runner.os == 'Windows' + shell: pwsh run: | + $env:NODE_GYP_FORCE_PYTHON = "$env:pythonLocation" + echo "Python is at ${env:NODE_GYP_FORCE_PYTHON}" cd node-gyp npm test From 621abaf8f03863a6b17477995f643cf051bd9995 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Sun, 30 Jul 2023 17:31:07 -0700 Subject: [PATCH 08/16] Rework pwsh script --- .github/workflows/node-gyp.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 7c4a99b1..1d7dc433 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -44,11 +44,11 @@ jobs: run: | rm -rf node-gyp/gyp cp -r gyp-next node-gyp/gyp - - name: Run tests (POSIX) + - name: Run tests (macOS or Linux) if: runner.os != 'Windows' shell: bash run: | - export NODE_GYP_FORCE_PYTHON="${pythonLocation}" + NODE_GYP_FORCE_PYTHON="${pythonLocation}" echo "Python is at ${pythonLocation}" cd node-gyp npm test @@ -56,7 +56,7 @@ jobs: if: runner.os == 'Windows' shell: pwsh run: | - $env:NODE_GYP_FORCE_PYTHON = "$env:pythonLocation" - echo "Python is at ${env:NODE_GYP_FORCE_PYTHON}" + $env:NODE_GYP_FORCE_PYTHON = "${env:pythonLocation}" + Write-Output "Python is at ${env:NODE_GYP_FORCE_PYTHON}" cd node-gyp npm test From 5f376a56208e155acb9961db8e663665f6be922f Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Sun, 30 Jul 2023 17:57:20 -0700 Subject: [PATCH 09/16] Try using batch --- .github/workflows/node-gyp.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 1d7dc433..762e5e34 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -54,9 +54,9 @@ jobs: npm test - name: Run tests (Windows) if: runner.os == 'Windows' - shell: pwsh + shell: cmd run: | - $env:NODE_GYP_FORCE_PYTHON = "${env:pythonLocation}" - Write-Output "Python is at ${env:NODE_GYP_FORCE_PYTHON}" + set NODE_GYP_FORCE_PYTHON=%pythonLocation% + echo Python is at %NODE_GYP_FORCE_PYTHON% cd node-gyp - npm test + npm run test From 161cd487b3de8fdb8e43edd1a6a7c12242d1c8e6 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Sun, 30 Jul 2023 18:50:40 -0700 Subject: [PATCH 10/16] use npm config set --- .github/workflows/node-gyp.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 762e5e34..a7ee64b8 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -48,15 +48,13 @@ jobs: if: runner.os != 'Windows' shell: bash run: | - NODE_GYP_FORCE_PYTHON="${pythonLocation}" - echo "Python is at ${pythonLocation}" cd node-gyp + npm config set python "${pythonLocation}" npm test - name: Run tests (Windows) if: runner.os == 'Windows' - shell: cmd + shell: pwsh run: | - set NODE_GYP_FORCE_PYTHON=%pythonLocation% - echo Python is at %NODE_GYP_FORCE_PYTHON% cd node-gyp + npm config set python "${env:pythonLocation}" npm run test From d42fab11c36e41e1d22e91e3a481ea34e611108c Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Sun, 30 Jul 2023 19:07:29 -0700 Subject: [PATCH 11/16] Work around https://github.com/npm/cli/issues/6126 --- .github/workflows/node-gyp.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index a7ee64b8..a39a5ede 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -49,12 +49,10 @@ jobs: shell: bash run: | cd node-gyp - npm config set python "${pythonLocation}" - npm test + npm test --python="${pythonLocation}" - name: Run tests (Windows) if: runner.os == 'Windows' shell: pwsh run: | cd node-gyp - npm config set python "${env:pythonLocation}" - npm run test + npm run test --python="${env:pythonLocation}" From b0e15bbebd1cb7a0a233edd04da3b9863c56ff4d Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Sun, 30 Jul 2023 19:33:21 -0700 Subject: [PATCH 12/16] Pass file rather than directory --- .github/workflows/node-gyp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index a39a5ede..9172e359 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -49,10 +49,10 @@ jobs: shell: bash run: | cd node-gyp - npm test --python="${pythonLocation}" + npm test --python="${pythonLocation}/python" - name: Run tests (Windows) if: runner.os == 'Windows' shell: pwsh run: | cd node-gyp - npm run test --python="${env:pythonLocation}" + npm run test --python="${env:pythonLocation}\\python.exe" From ed04368178d5252fa597847866cebeba8c52142d Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:52:26 -0700 Subject: [PATCH 13/16] Remove gyp-next self-install --- .github/workflows/node-gyp.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 9172e359..446e4b82 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -35,6 +35,7 @@ jobs: cd gyp-next python -m pip install --upgrade pip setuptools pip install --editable . + pip remove gyp-next - name: Install Node.js dependencies run: | cd node-gyp From 82034b1fca64a42e0ec3bc094fc92101de5b54e0 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:53:51 -0700 Subject: [PATCH 14/16] uninstall, not remove --- .github/workflows/node-gyp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 446e4b82..6c313b0f 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -35,7 +35,7 @@ jobs: cd gyp-next python -m pip install --upgrade pip setuptools pip install --editable . - pip remove gyp-next + pip uninstall gyp-next - name: Install Node.js dependencies run: | cd node-gyp From 113fddde42621861e5270dca90f67d4ad976d02c Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:55:12 -0700 Subject: [PATCH 15/16] Add -y --- .github/workflows/node-gyp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node-gyp.yml b/.github/workflows/node-gyp.yml index 6c313b0f..13bd52bd 100644 --- a/.github/workflows/node-gyp.yml +++ b/.github/workflows/node-gyp.yml @@ -35,7 +35,7 @@ jobs: cd gyp-next python -m pip install --upgrade pip setuptools pip install --editable . - pip uninstall gyp-next + pip uninstall -y gyp-next - name: Install Node.js dependencies run: | cd node-gyp From 91eb0e928b68d908cf3212ba14a5904670a79c46 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:57:50 -0700 Subject: [PATCH 16/16] Ignore the latest lint rules --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2d3875ce..89cf8958 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,6 +87,7 @@ select = [ # "TRY", # tryceratops ] ignore = [ + "E721", "PLC1901", "PLR0402", "PLR1714", @@ -94,6 +95,7 @@ ignore = [ "PLR5501", "PLW0603", "PLW2901", + "PYI024", "RUF005", "RUF012", "UP031",