Skip to content

Commit

Permalink
feat(gyp): update gyp to v0.16.1 (#2923)
Browse files Browse the repository at this point in the history
* feat(gyp): update gyp to v0.15.1

* Add Python 3.12 to tests

* Try to fix CI

* Try specifying msvs-version

* Modify the visual-studio matrix

* Fix pythonLocation var

* Fix Python tests

* Get path

* polish

* feat(gyp): update gyp to v0.16.0

* feat(gyp): update gyp to v0.16.1

* CI: Don't install Python 'packaging' module (vendored in 'gyp-next' now)

* Apply suggestions from code review

* Upgrade to actions/checkout@v4

---------

Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
  • Loading branch information
3 people authored and lukekarrys committed Dec 2, 2024
1 parent a3a157f commit 6c92c8d
Show file tree
Hide file tree
Showing 51 changed files with 5,122 additions and 247 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
max-parallel: 15
matrix:
node: [16.x, 18.x, 20.x]
python: ["3.8", "3.11"]
python: ["3.8", "3.10", "3.12"]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -56,5 +56,11 @@ jobs:
# run: python -m pytest --doctest-modules
- name: Environment Information
run: npx envinfo
- name: Run Node tests
run: npm test
- name: Run Node tests (macOS or Linux)
if: runner.os != 'Windows'
shell: bash
run: npm test --python="${pythonLocation}/python"
- name: Run tests (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: npm run test --python="${env:pythonLocation}\\python.exe"
20 changes: 10 additions & 10 deletions .github/workflows/visual-studio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ jobs:
fail-fast: false
max-parallel: 8
matrix:
os: [windows-latest]
msvs-version: [2016, 2019, 2022] # https://github.com/actions/virtual-environments/tree/main/images/win
include:
- os: windows-2019
msvs-verison: 2019
- os: windows-2022
msvs-version: 2022
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Dependencies
run: |
npm install --no-progress
# npm audit fix --force
- name: Set Windows environment
if: startsWith(matrix.os, 'windows')
run: |
echo 'GYP_MSVS_VERSION=${{ matrix.msvs-version }}' >> $Env:GITHUB_ENV
echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV
- name: Environment Information
run: npx envinfo
- name: Run Node tests
run: npm test
shell: pwsh
run: |
$pythonLocation = (Get-Command python).Source
npm run test --python="${pythonLocation}" --msvs-version="${{ matrix.msvs-version }}"
4 changes: 0 additions & 4 deletions gyp/.flake8

This file was deleted.

13 changes: 7 additions & 6 deletions gyp/.github/workflows/Python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 8
max-parallel: 5
matrix:
os: [macos-latest, ubuntu-latest] # , windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install --editable ".[dev]"
- run: ./gyp -V && ./gyp --version && gyp -V && gyp --version
- name: Lint with flake8
run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics
- name: Test with pytest
- name: Lint with ruff # See pyproject.toml for settings
run: ruff --output-format=github .
- name: Test with pytest # See pyproject.toml for settings
run: pytest
# - name: Run doctests with pytest
# run: pytest --doctest-modules
29 changes: 22 additions & 7 deletions gyp/.github/workflows/node-gyp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,33 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python: ["3.7", "3.10"]
python: ["3.8", "3.10", "3.12"]

runs-on: ${{ matrix.os }}
steps:
- name: Clone gyp-next
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: gyp-next
- name: Clone nodejs/node-gyp
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: nodejs/node-gyp
path: node-gyp
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
allow-prereleases: true
- 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 +46,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"
6 changes: 3 additions & 3 deletions gyp/.github/workflows/nodejs-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:

jobs:
build-windows:
runs-on: windows-2019
runs-on: windows-latest
steps:
- name: Clone gyp-next
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: gyp-next
- name: Clone nodejs/node
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: nodejs/node
path: node
Expand Down
1 change: 1 addition & 0 deletions gyp/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Tom Freudenberg <th.freudenberg@gmail.com>
Julien Brianceau <jbriance@cisco.com>
Refael Ackermann <refack@gmail.com>
Ujjwal Sharma <ryzokuken@disroot.org>
Christian Clauss <cclauss@me.com>
42 changes: 42 additions & 0 deletions gyp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Changelog

## [0.16.1](https://github.com/nodejs/gyp-next/compare/v0.16.0...v0.16.1) (2023-10-25)


### Bug Fixes

* add quotes for command in msvs generator ([#217](https://github.com/nodejs/gyp-next/issues/217)) ([d3b7bcd](https://github.com/nodejs/gyp-next/commit/d3b7bcdec90d6c1b1affc15ece706e63007b7264))

## [0.16.0](https://github.com/nodejs/gyp-next/compare/v0.15.1...v0.16.0) (2023-10-23)


### Features

* add VCToolsVersion for msvs ([#209](https://github.com/nodejs/gyp-next/issues/209)) ([0e35ab8](https://github.com/nodejs/gyp-next/commit/0e35ab812d890fb75cf89a19ea72bc93dd6ba186))

## [0.15.1](https://github.com/nodejs/gyp-next/compare/v0.15.0...v0.15.1) (2023-09-08)


### Bug Fixes

* some Python lint issues ([#200](https://github.com/nodejs/gyp-next/issues/200)) ([d2dfe4e](https://github.com/nodejs/gyp-next/commit/d2dfe4e66b64c16b38bef984782db93d12674f05))
* use generator_output as output_dir ([#191](https://github.com/nodejs/gyp-next/issues/191)) ([35ffeb1](https://github.com/nodejs/gyp-next/commit/35ffeb1da8ef3fc8311e2e812cff550568f7e8a2))

## [0.15.0](https://github.com/nodejs/gyp-next/compare/v0.14.1...v0.15.0) (2023-03-30)


### Features

* **msvs:** add SpectreMitigation attribute ([#190](https://github.com/nodejs/gyp-next/issues/190)) ([853e464](https://github.com/nodejs/gyp-next/commit/853e4643b6737224a5aa0720a4108461a0230991))

## [0.14.1](https://github.com/nodejs/gyp-next/compare/v0.14.0...v0.14.1) (2023-02-19)


### Bug Fixes

* flake8 extended-ignore ([#186](https://github.com/nodejs/gyp-next/issues/186)) ([c38493c](https://github.com/nodejs/gyp-next/commit/c38493c2556aa63b6dc40ab585c18aef5ca270d3))
* No build_type in default_variables ([#183](https://github.com/nodejs/gyp-next/issues/183)) ([ac262fe](https://github.com/nodejs/gyp-next/commit/ac262fe82453c4e8dc47529338d157eb0b5ec0fb))


### Documentation

* README.md: Add pipx installation and run instructions ([#165](https://github.com/nodejs/gyp-next/issues/165)) ([4d28b15](https://github.com/nodejs/gyp-next/commit/4d28b155568dc35f11c7f86124d1dd42ba428bed))

## [0.14.0](https://github.com/nodejs/gyp-next/compare/v0.13.0...v0.14.0) (2022-10-08)


Expand Down
23 changes: 23 additions & 0 deletions gyp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,26 @@ Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check

__gyp-next__ is [released](https://github.com/nodejs/gyp-next/releases) to the [__Python Packaging Index__](https://pypi.org/project/gyp-next) (PyPI) and can be installed with the command:
* `python3 -m pip install gyp-next`

When used as a command line utility, __gyp-next__ can also be installed with [pipx](https://pypa.github.io/pipx):
* `pipx install gyp-next`
```
Installing to a new venv 'gyp-next'
installed package gyp-next 0.13.0, installed using Python 3.10.6
These apps are now globally available
- gyp
done! ✨ 🌟 ✨
```

Or to run __gyp-next__ directly without installing it:
* `pipx run gyp-next --help`
```
NOTE: running app 'gyp' from 'gyp-next'
usage: usage: gyp [options ...] [build_file ...]
options:
-h, --help show this help message and exit
--build CONFIGS configuration for build after project generation
--check check format of gyp files
[ ... ]
```
26 changes: 12 additions & 14 deletions gyp/pylib/gyp/MSVSNew.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,17 @@ def Write(self, writer=gyp.common.WriteOnDiff):
"\tEndProjectSection\r\n"
)

if isinstance(e, MSVSFolder):
if e.items:
f.write("\tProjectSection(SolutionItems) = preProject\r\n")
for i in e.items:
f.write(f"\t\t{i} = {i}\r\n")
f.write("\tEndProjectSection\r\n")

if isinstance(e, MSVSProject):
if e.dependencies:
f.write("\tProjectSection(ProjectDependencies) = postProject\r\n")
for d in e.dependencies:
f.write(f"\t\t{d.get_guid()} = {d.get_guid()}\r\n")
f.write("\tEndProjectSection\r\n")
if isinstance(e, MSVSFolder) and e.items:
f.write("\tProjectSection(SolutionItems) = preProject\r\n")
for i in e.items:
f.write(f"\t\t{i} = {i}\r\n")
f.write("\tEndProjectSection\r\n")

if isinstance(e, MSVSProject) and e.dependencies:
f.write("\tProjectSection(ProjectDependencies) = postProject\r\n")
for d in e.dependencies:
f.write(f"\t\t{d.get_guid()} = {d.get_guid()}\r\n")
f.write("\tEndProjectSection\r\n")

f.write("EndProject\r\n")

Expand Down Expand Up @@ -353,7 +351,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):

# Folder mappings
# Omit this section if there are no folders
if any([e.entries for e in all_entries if isinstance(e, MSVSFolder)]):
if any(e.entries for e in all_entries if isinstance(e, MSVSFolder)):
f.write("\tGlobalSection(NestedProjects) = preSolution\r\n")
for e in all_entries:
if not isinstance(e, MSVSFolder):
Expand Down
2 changes: 1 addition & 1 deletion gyp/pylib/gyp/MSVSProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, project_path, version, name, guid=None, platforms=None):
self.files_section = ["Files"]

# Keep a dict keyed on filename to speed up access.
self.files_dict = dict()
self.files_dict = {}

def AddToolFile(self, path):
"""Adds a tool file to the project.
Expand Down
2 changes: 1 addition & 1 deletion gyp/pylib/gyp/MSVSSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class _Boolean(_Type):
"""Boolean settings, can have the values 'false' or 'true'."""

def _Validate(self, value):
if value != "true" and value != "false":
if value not in {"true", "false"}:
raise ValueError("expected bool; got %r" % value)

def ValidateMSVS(self, value):
Expand Down
6 changes: 4 additions & 2 deletions gyp/pylib/gyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def Load(
if default_variables["GENERATOR"] == "ninja":
default_variables.setdefault(
"PRODUCT_DIR_ABS",
os.path.join(output_dir, "out", default_variables["build_type"]),
os.path.join(
output_dir, "out", default_variables.get("build_type", "default")
),
)
else:
default_variables.setdefault(
Expand Down Expand Up @@ -622,7 +624,7 @@ def gyp_main(args):
if options.generator_flags:
gen_flags += options.generator_flags
generator_flags = NameValueListToDict(gen_flags)
if DEBUG_GENERAL in gyp.debug.keys():
if DEBUG_GENERAL in gyp.debug:
DebugOutput(DEBUG_GENERAL, "generator_flags: %s", generator_flags)

# Generate all requested formats (use a set in case we got one format request
Expand Down
21 changes: 7 additions & 14 deletions gyp/pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,16 @@ def RelativePath(path, relative_to, follow_path_symlink=True):
# symlink, this option has no effect.

# Convert to normalized (and therefore absolute paths).
if follow_path_symlink:
path = os.path.realpath(path)
else:
path = os.path.abspath(path)
path = os.path.realpath(path) if follow_path_symlink else os.path.abspath(path)
relative_to = os.path.realpath(relative_to)

# On Windows, we can't create a relative path to a different drive, so just
# use the absolute path.
if sys.platform == "win32":
if (
os.path.splitdrive(path)[0].lower()
!= os.path.splitdrive(relative_to)[0].lower()
):
return path
if sys.platform == "win32" and (
os.path.splitdrive(path)[0].lower()
!= os.path.splitdrive(relative_to)[0].lower()
):
return path

# Split the paths into components.
path_split = path.split(os.path.sep)
Expand Down Expand Up @@ -277,10 +273,7 @@ def EncodePOSIXShellArgument(argument):
if not isinstance(argument, str):
argument = str(argument)

if _quote.search(argument):
quote = '"'
else:
quote = ""
quote = '"' if _quote.search(argument) else ""

encoded = quote + re.sub(_escape, r"\\\1", argument) + quote

Expand Down
6 changes: 5 additions & 1 deletion gyp/pylib/gyp/easy_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,
if win32 and os.linesep != "\r\n":
xml_string = xml_string.replace("\n", "\r\n")

default_encoding = locale.getdefaultlocale()[1]
try: # getdefaultlocale() was removed in Python 3.11
default_encoding = locale.getdefaultlocale()[1]
except AttributeError:
default_encoding = locale.getencoding()

if default_encoding and default_encoding.upper() != encoding.upper():
xml_string = xml_string.encode(encoding)

Expand Down
4 changes: 4 additions & 0 deletions gyp/pylib/gyp/easy_xml_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def test_EasyXml_complex(self):
'\'Debug|Win32\'" Label="Configuration">'
"<ConfigurationType>Application</ConfigurationType>"
"<CharacterSet>Unicode</CharacterSet>"
"<SpectreMitigation>SpectreLoadCF</SpectreMitigation>"
"<VCToolsVersion>14.36.32532</VCToolsVersion>"
"</PropertyGroup>"
"</Project>"
)
Expand All @@ -99,6 +101,8 @@ def test_EasyXml_complex(self):
},
["ConfigurationType", "Application"],
["CharacterSet", "Unicode"],
["SpectreMitigation", "SpectreLoadCF"],
["VCToolsVersion", "14.36.32532"],
],
]
)
Expand Down
Loading

0 comments on commit 6c92c8d

Please sign in to comment.