Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build, win: vcbuild improvements #17015

Closed
wants to merge 3 commits into from

Conversation

bzoz
Copy link
Contributor

@bzoz bzoz commented Nov 14, 2017

Adds extra a check for proper Python version. If it is not found, vcbuild will exit early.

If no VS2017 installation is found, vswhere_usability_wrapper.cmd would print could not find "vswhere". This removes that message, making output look nicer for VS2015 compilation.

Finally, this adds support for DEBUG_HELPER to vcbuild.bat. Similar to vswhere_usability_wrapper.cmd and find_python.cmd, if DEBUG_HELPER environment variable is set, echo off will not be called, making debugging easier.

Fixes: #16864

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

build

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. install Issues and PRs related to the installers. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform. labels Nov 14, 2017
@bzoz
Copy link
Contributor Author

bzoz commented Nov 14, 2017

@bzoz
Copy link
Contributor Author

bzoz commented Nov 16, 2017

/cc @nodejs/build @nodejs/platform-windows

@seishun
Copy link
Contributor

seishun commented Nov 16, 2017

This removes that message, making output look nicer for VS2015 compilation.

Will it still be relevant once #16969 is merged?

@bzoz
Copy link
Contributor Author

bzoz commented Nov 16, 2017

Yes

@@ -28,5 +28,4 @@ for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (

:no-vswhere
endlocal
echo could not find "vswhere"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this. Or upstream to https://github.com/node4good/msvs-com-helper

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes that message, making output look nicer for VS2015 compilation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we just dropped "official" VS2015 support 🤷‍♂️

If you still want to keep output clean, I'd rather you change the call in vcbuild

call tools\msvs\vswhere_usability_wrapper.cmd
to:

if defined DEBUG_HELPER (call tools\msvs\vswhere_usability_wrapper.cmd)
else (call tools\msvs\vswhere_usability_wrapper.cmd > nul)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you still want to keep output clean, I'd rather you change the call in vcbuild

I'd prefer to keep vcbuild clean too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without 2015, if no VS2017 is found, it will look like this:

Looking for Visual Studio 2017
could not find "vswhere"
Failed to find a suitable Visual Studio installation.
Try to run in a "Developer Command Prompt" or consult
https://github.com/nodejs/node/blob/master/BUILDING.md#windows-1

I don't think it looks good, and the could not find "vswhere" is only helpful if you know vcbuild internals. We can use DEBUG_HELPER to debug vcbuild if needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll move it upstream.

@@ -1,4 +1,4 @@
@echo off
@if not defined DEBUG_HELPER @ECHO OFF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAASS! (I have this floating in all my workspaces, and I keep forgetting to upstream it)

vcbuild.bat Outdated
echo Looking for Python 2.x
call :run-python --version > nul 2> nul
if errorlevel 1 echo Could not find Python 2.x installation && exit /b 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. :run-python will echo Could not find python2 so IMHO no need to echo again. (L561)
  2. should end subroutine with either exit /b or goto :EOF

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, let's not duplicate the validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:run-python is very verbose, especially if no Python is found (see #16864). Stdout and stderr is redirected to nul, to keep it clean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe :run-python should be fixed. I was planning to do it myself, I think it's a simple error in the code.

@bzoz
Copy link
Contributor Author

bzoz commented Nov 22, 2017

Updated, PTAL

vcbuild.bat Outdated
@@ -577,6 +577,7 @@ set TAG=
set FULLVERSION=
:: Call as subroutine for validation of python
call :run-python tools\getnodeversion.py > nul
if errorlevel 1 exit /b 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly. Basically, we run tools\getnodeversion.py, ignore the output, exit if it failed, then run it again, this time directly using a variable that's supposed to be internal to find_python.cmd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could change the fake call to call :run-python --version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would still be a hacky workaround for the limitation of run-python.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No argument here. This file has a lot of cmdism hacks, mainly because you can't redirect stdout into a variable.
I'll check if there's a way to use call as the for command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked before, there isn't. So a subroutine doesn't work as a replacement for the python command.

An alternative would be to replace run-python with find-python that would just populate a variable to be used instead of python. But then one would have to make sure that find-python is run before the first usage of Python and that it's not run if Python isn't needed, whenever a significant change is introduced into vcbuild.bat.

Honestly, I'd prefer to just revert 614dbbd since it introduces a lot of complexity in order to support an edge case that has never affected anyone to my knowledge. IMO it was landed prematurely (only one approval and not thoroughly tested).

@bzoz
Copy link
Contributor Author

bzoz commented Nov 29, 2017

Updated, PTAL.

@bzoz
Copy link
Contributor Author

bzoz commented Dec 4, 2017

ping?

@seishun
Copy link
Contributor

seishun commented Dec 4, 2017

Unfortunately, my comment in #17298 (comment) applies here as well, so I cannot approve this.

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the resident domain expert but LGTM, FWIW.

@bzoz
Copy link
Contributor Author

bzoz commented Dec 7, 2017

@seishun it does not fix all issues, but at least makes vcbuild slightly more user friendly without breaking anything. IMO it will be better to wait for proper python fix with this version, rather that the one from master.

@bzoz
Copy link
Contributor Author

bzoz commented Dec 21, 2017

If nobody oposes, I will land this tomorrow

Copy link
Contributor

@seishun seishun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking until either #17293 or #17804 lands due to the aforementioned reasons.

Removes extra erroor messages when Python is not installed. Removes
"vswhere not found" message when no VS2017 installation is found.
Adds support for DEBUG_HELPER to vcbuild.bat.

Fixes: nodejs#16864
@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 17, 2018
@BridgeAR
Copy link
Member

vcbuild.bat Outdated
call tools\msvs\find_python.cmd
if errorlevel 1 echo Could not find python2 & goto :exit
echo Looking for Python 2.x
call tools\msvs\find_python.cmd > NUL 2> NUL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the noise not be fixed inside find_python.cmd itself?

vcbuild.bat Outdated
if errorlevel 1 echo Could not find python2 & goto :exit
echo Looking for Python 2.x
call tools\msvs\find_python.cmd > NUL 2> NUL
if errorlevel 1 echo Could not find Python installation & goto :exit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop "installation".

@BridgeAR BridgeAR removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 17, 2018
@bzoz
Copy link
Contributor Author

bzoz commented Feb 19, 2018

@bzoz
Copy link
Contributor Author

bzoz commented Feb 19, 2018

I've moved error messages to find_python.cmd. This way we can have special error message when we find Python, but the version is incorrect.

@bzoz
Copy link
Contributor Author

bzoz commented Feb 21, 2018

CI after update: https://ci.nodejs.org/job/node-test-pull-request/13300/

Can I get +1?

@seishun
Copy link
Contributor

seishun commented Feb 21, 2018

I don't really see the point in separating error messages for "No Python found at all" and "Python 2.x specifically not found". Isn't the action to be taken by the user the same in both cases?

@bzoz
Copy link
Contributor Author

bzoz commented Feb 21, 2018

Its mostly for the new people, like in Code + Learn, etc. If they have Python 3 installed, vcbuild complaining about "no python" will be confusing for some people. Telling them "I've found python but the version is wrong" makes it clear whats the problem.

Copy link
Member

@gibfahn gibfahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, but would be good to get another review from @nodejs/platform-windows

@seishun
Copy link
Contributor

seishun commented Feb 21, 2018

If they have Python 3 installed, vcbuild complaining about "no python" will be confusing for some people.

I'd say "No Python 2.x" is sufficient for both cases. Mentioning a Python 3.x installation seems excessive, it's just a different product (i.e. you can have both installed).

@bzoz
Copy link
Contributor Author

bzoz commented Feb 21, 2018

Sure, saying "you don't have python2.x" is sufficient. But saying "you have wrong python version" is more helpful.

@seishun
Copy link
Contributor

seishun commented Feb 21, 2018

It's also misleading because it suggests it should be replaced with python 2.x.

@gibfahn
Copy link
Member

gibfahn commented Feb 21, 2018

It's also misleading because it suggests it should be replaced with python 2.x.

In that case wouldn't the answer be to be more specific rather than less, i.e. something like:

Found Python 3 but not Python 2. Please install Python 2.6 or 2.7.

?

@bzoz
Copy link
Contributor Author

bzoz commented Feb 22, 2018

It will say Python found in [...], but it is not v2.x..

Again, this is to help out new people on the project, like in Code + Learn. The more info we provide the better. And easier for people running such workshops to get everyone started with developing Node.

I would like to land this, @seishun are you -1 on this?

@seishun
Copy link
Contributor

seishun commented Feb 22, 2018

I can't imagine a situation where this extra info would help new people. If anything, it's confusing because they might think they should uninstall Python 3.x.

I'm -0 on this.

@bzoz
Copy link
Contributor Author

bzoz commented Feb 22, 2018

I'm gonna land this then.

@bzoz
Copy link
Contributor Author

bzoz commented Feb 22, 2018

Landed in 887a2ba

@bzoz bzoz closed this Feb 22, 2018
bzoz added a commit that referenced this pull request Feb 22, 2018
Removes extra erroor messages when Python is not installed. Removes
"vswhere not found" message when no VS2017 installation is found.
Adds support for DEBUG_HELPER to vcbuild.bat.

Fixes: #16864

PR-URL: #17015
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
addaleax pushed a commit to addaleax/node that referenced this pull request Feb 26, 2018
Removes extra erroor messages when Python is not installed. Removes
"vswhere not found" message when no VS2017 installation is found.
Adds support for DEBUG_HELPER to vcbuild.bat.

Fixes: nodejs#16864

PR-URL: nodejs#17015
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
addaleax pushed a commit that referenced this pull request Feb 26, 2018
Removes extra erroor messages when Python is not installed. Removes
"vswhere not found" message when no VS2017 installation is found.
Adds support for DEBUG_HELPER to vcbuild.bat.

Fixes: #16864

PR-URL: #17015
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
@addaleax addaleax mentioned this pull request Feb 27, 2018
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Removes extra erroor messages when Python is not installed. Removes
"vswhere not found" message when no VS2017 installation is found.
Adds support for DEBUG_HELPER to vcbuild.bat.

Fixes: nodejs#16864

PR-URL: nodejs#17015
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
@MylesBorins
Copy link
Contributor

Should this be backported to v8.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. install Issues and PRs related to the installers. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vcbuild explodes is Python is not installed
8 participants