Skip to content

Commit a68d184

Browse files
committed
gyp: record absolute Python path in Makefile
Ensures the Python validated by `lib/find-python.js` is used when running `gyp-mac-tool` during package builds. (Unless that Python binary has been moved/deleted since `node-gyp configure` was run, but we an't do much about that.)
1 parent 0da2e01 commit a68d184

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

gyp/pylib/gyp/generator/make.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import os
2626
import re
2727
import subprocess
28+
import sys
2829
import gyp
2930
import gyp.common
3031
import gyp.xcode_emulation
@@ -177,9 +178,9 @@ def CalculateGeneratorInputInfo(params):
177178
cmd_solink_module = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
178179
""" # noqa: E501
179180

180-
LINK_COMMANDS_MAC = """\
181+
LINK_COMMANDS_MAC = f"""\
181182
quiet_cmd_alink = LIBTOOL-STATIC $@
182-
cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^)
183+
cmd_alink = rm -f $@ && $(shell command -v {sys.executable}) ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^)
183184
184185
quiet_cmd_link = LINK($(TOOLSET)) $@
185186
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
@@ -503,7 +504,7 @@ def CalculateGeneratorInputInfo(params):
503504
""" # noqa: E501
504505
)
505506

506-
SHARED_HEADER_MAC_COMMANDS = """
507+
SHARED_HEADER_MAC_COMMANDS = f"""
507508
quiet_cmd_objc = CXX($(TOOLSET)) $@
508509
cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
509510
@@ -524,10 +525,10 @@ def CalculateGeneratorInputInfo(params):
524525
# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
525526
# already.
526527
quiet_cmd_mac_tool = MACTOOL $(4) $<
527-
cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@"
528+
cmd_mac_tool = $(shell command -v {sys.executable}) ./gyp-mac-tool $(4) $< "$@"
528529
529530
quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@
530-
cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)
531+
cmd_mac_package_framework = $(shell command -v {sys.executable}) ./gyp-mac-tool package-framework "$@" $(4)
531532
532533
quiet_cmd_infoplist = INFOPLIST $@
533534
cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
@@ -2301,7 +2302,7 @@ def CalculateMakefilePath(build_file, base_name):
23012302
"LINK.host": GetEnvironFallback(("LINK_host", "LINK"), "$(CXX.host)"),
23022303
}
23032304
if flavor == "mac":
2304-
flock_command = "./gyp-mac-tool flock"
2305+
flock_command = f"$(shell command -v {sys.executable}) ./gyp-mac-tool flock"
23052306
header_params.update(
23062307
{
23072308
"flock": flock_command,
@@ -2331,7 +2332,7 @@ def CalculateMakefilePath(build_file, base_name):
23312332
header_params.update(
23322333
{
23332334
"copy_archive_args": copy_archive_arguments,
2334-
"flock": "./gyp-flock-tool flock",
2335+
"flock": f"$(shell command -v {sys.executable}) ./gyp-flock-tool flock",
23352336
"flock_index": 2,
23362337
}
23372338
)
@@ -2347,7 +2348,7 @@ def CalculateMakefilePath(build_file, base_name):
23472348
{
23482349
"copy_archive_args": copy_archive_arguments,
23492350
"link_commands": LINK_COMMANDS_AIX,
2350-
"flock": "./gyp-flock-tool flock",
2351+
"flock": f"$(shell command -v {sys.executable}) ./gyp-flock-tool flock",
23512352
"flock_index": 2,
23522353
}
23532354
)

0 commit comments

Comments
 (0)