Skip to content

build: use the same python executable to run configure and gyp - #39498

Closed
joyeecheung wants to merge 1 commit into
nodejs:masterfrom
joyeecheung:python_exec
Closed

build: use the same python executable to run configure and gyp#39498
joyeecheung wants to merge 1 commit into
nodejs:masterfrom
joyeecheung:python_exec

Conversation

@joyeecheung

Copy link
Copy Markdown
Member

Otherwise we would end up using python 2 to run actions in the gyp
config if that's the system default.

@nodejs-github-botnodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. labels Jul 23, 2021
Otherwise we would end up using python 2 to run actions in the gyp
config if that's the system default.
@richardlau

Copy link
Copy Markdown
Member

Similar to #39465.

Otherwise we would end up using python 2 to run actions in the gyp
config if that's the system default.

This should not be the case if using make due to the symlinking that goes on in

node/configure.py

Lines 1857 to 1888 in 56a7e0a

defmake_bin_override():
ifsys.platform=='win32':
raiseException('make_bin_override should not be called on win32.')
# If the system python is not the python we are running (which should be
# python 3), then create a directory with a symlink called `python` to our
# sys.executable. This directory will be prefixed to the PATH, so that
# other tools that shell out to `python` will use the appropriate python
which_python=which('python')
if (which_pythonand
os.path.realpath(which_python) ==os.path.realpath(sys.executable)):
return
bin_override=os.path.abspath('out/tools/bin')
try:
os.makedirs(bin_override)
exceptOSErrorase:
ife.errno!=errno.EEXIST: raisee
python_link=os.path.join(bin_override, 'python')
try:
os.unlink(python_link)
exceptOSErrorase:
ife.errno!=errno.ENOENT: raisee
os.symlink(sys.executable, python_link)
# We need to set the environment right now so that when gyp (in run_gyp)
# shells out, it finds the right python (specifically at
# https://github.com/nodejs/node/blob/d82e107/deps/v8/gypfiles/toolchain.gypi#L43)
os.environ['PATH'] =bin_override+':'+os.environ['PATH']
returnbin_override
and path manipulation done in

node/configure.py

Lines 1992 to 1997 in 56a7e0a

# On Windows there's no reason to search for a different python binary.
bin_override=Noneifsys.platform=='win32'elsemake_bin_override()
ifbin_override:
config_str='export PATH:='+bin_override+':$(PATH)\n'+config_str
write('config.mk', do_not_edit+config_str)
.

@legendecas

Copy link
Copy Markdown
Member

hi, @joyeecheung, can you take a look at #39465?

@joyeecheung

Copy link
Copy Markdown
MemberAuthor

closing in favor of #39465

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildIssues and PRs related to build files or the CI.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@joyeecheung@richardlau@legendecas@jasnell@nodejs-github-bot