-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-30687: Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat #2252
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
Conversation
….bat Also fixes bdist_wininst.vcxproj to use correct version in generated name.
@zooba, thanks for your PR! By analyzing the history of the files in this pull request, we identified @zware and @briancurtin to be potential reviewers. |
Decided this isn't really trivial, so I'll create an issue. Not a lot to discuss right now I don't think, but there could be when this all goes wrong :) |
@tjguk This should fix up the trouble you were having earlier 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea. Haven't tested it yet, and have a few questions, below.
PCbuild/fix_lineendings.py
Outdated
@@ -0,0 +1,27 @@ | |||
#! /usr/bin/env python3 | |||
# | |||
# Fixes line endings of batch files to ensure they remain LF. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't right, they should be CRLF :). Also, a del .git\index && git reset
from a clean (no changes, no untracked or ignored files) checkout should give you proper line endings according to the rules in .gitattributes
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, they weren't CRLF, because Mercurial (I'm using hggit on this machine) fixed them all and they all got changed.
I can fix them back, but then the review is going to be unreadable, so check it all out before I do it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I just checked it out and got the right line endings even on your new find_msbuild.bat
file. I think this file can just be removed and we hope .gitattributes
makes Git do the right thing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed the script to fix up the problems when hggit did the wrong thing. Maybe I just need to switch to git completely (though then I'm never going to backport anything, because it takes 10x as long)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would Tools/scripts/crlf.py
be enough for you?
@rem | ||
|
||
@rem No arguments provided means do full search | ||
@if '%1' EQU '' goto :begin_search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work, or should these be double quotes? I've been bitten by trying to use single quotes in batch files a couple of times, but I'm not convinced that I actually understand the quoting rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quoting rules are horrible here, because I want to handle where users have done:
set MSBUILD=C:\path to\MSBuild.exe
set MSBUILD="C:\path to\MSBuild.exe"
Which breaks in a whole lot of ridiculous ways. Using single quotes here at least handles the two sane cases without causing syntax errors.
PCbuild/find_msbuild.bat
Outdated
@if exist "%MSBUILD%" set MSBUILD="%MSBUILD%" & (set _SOURCE=PATH) & goto :found | ||
|
||
@rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there. | ||
@for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') DO @( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. One of those names that stuck for back-compat reasons...
@@ -115,7 +115,8 @@ if exist "%GIT%" set GITProperty=/p:GIT="%GIT%" | |||
if not exist "%GIT%" echo Cannot find Git on PATH & set GITProperty= | |||
|
|||
rem Setup the environment | |||
call "%dir%env.bat" %vs_platf% >nul |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can vs_platf
go away entirely now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sure can!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then I think the cross-compilation for PGO warning has to go away too... not sure of the full impact there yet, let me try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't; the vs_platf
stuff just gets removed from around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are some missing environment pieces, but I can add those into python.bat
on build. Looks like that's how we launch for PGO build anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you mean about keeping the warning in there. I'll bring that back
Skips UCRT check for PGO builds.
@ned-deily Can we consider this for 3.6.2? It has no impact on the resulting build, but will make the sdist (or forks) easier to use on Windows. |
I trust your judgement on the impact and importance. As you know, 3.6.2rc1 is already being "manufactured". Since this is more than a trivial change and presumably could have end-user impact, I don't think it would be appropriate to try to drop it into a 3.6.2final without exposure. There are a couple of options we can discuss off-line but, in any case, the change needs to first be merged into the normal 3.6 branch. |
I'm just waiting on @zware to approve (and merge, if there are no changes needed). The backport to the 3.6 branch should be trivial, and probably 3.5 as well. |
I'm looking at this but it's likely I won't have a chance to test
tonight (9.30pm my time now). Obviously if @zware can test it out, then
great!
|
Ok; I have tested and confirm the build now works for VS2017. I haven't
reviewed the code changes as such, and I presume that @zware is a more
appropriate reviewer in any case.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change needed, one suggestion, one request, and one question.
PCbuild/build.bat
Outdated
if "%PROCESSOR_ARCHITEW6432%" NEQ "AMD64" if "%PROCESSOR_ARCHITECTURE%" NEQ "AMD64" ( | ||
echo.ERROR: Cannot cross-compile with PGO | ||
echo. 32bit operating system detected, if this is incorrect, | ||
echo. make sure the ProgramFiles(x86^) environment variable is set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message needs to be reworded, since we're no longer checking %ProgramFiles(x86)% (and %on_64_bit% should be removed from above :CheckOpts
)
PCbuild/fix_lineendings.py
Outdated
@@ -0,0 +1,27 @@ | |||
#! /usr/bin/env python3 | |||
# | |||
# Fixes line endings of batch files to ensure they remain LF. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would Tools/scripts/crlf.py
be enough for you?
PCbuild/find_msbuild.bat
Outdated
@if exist "%MSBUILD%" set MSBUILD="%MSBUILD%" & (set _SOURCE=PATH) & goto :found | ||
|
||
@rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there. | ||
@for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') DO @( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's here that I get ERROR: The system was unable to find the specified registry key or value.
on a machine without VS 2017. Can that be suppressed without too much hardship? Probably the same below, but that key was actually found on my machine.
PCbuild/find_msbuild.bat
Outdated
|
||
:found | ||
@echo Using %MSBUILD% (found in the %_SOURCE%) | ||
@set _SOURCE= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the idea is to mutate the enclosing environment, _SOURCE
should probably be something even less likely to conflict, like _Py_MSBuild_Source
.
Made the requested changes, now just working on dealing with line endings... |
I think the line endings problem is that .hgeol converts on update/checkout but not commit, while git converts everything to LF on commits and back on checkout. So the actual files in the repo are LF and become CRLF on checkout, but hggit puts them back into git as CRLF instead of LF and we get stupid diffs. Once we get a backport bot I'll have less need to use something sensible (i.e. hg) for backporting and can use git for more development. Until then, guess I'll just keep doing these extra commits - luckily they'll squash out. |
What kind of behavior do you get if you just remove |
Then all my .bat files have LF endings. I'm on Win10 everywhere, so that's less of an issue for me - I think it's only Win7 and earlier that don't like them. |
On 19/06/2017 18:25, Steve Dower wrote:
Once we get a backport bot I'll have less need to use something sensible
(i.e. hg) for backporting and can use git for more development. Until
then, guess I'll just keep doing these extra commits - luckily they'll
squash out.
Makes it harder to review within GH though -- have to manually scan the
every-line-has-changed looking for actual changes!
|
Yep, that's why I have about 8 "Fix line endings" commits, to get around that problem :) |
:)
|
…n vcvarsall.bat (python#2252) * Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat Also fixes bdist_wininst.vcxproj to use correct version in generated name.
…n vcvarsall.bat (python#2252) * Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat Also fixes bdist_wininst.vcxproj to use correct version in generated name.
…n vcvarsall.bat (python#2252) (python#2280) * Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat Also fixes bdist_wininst.vcxproj to use correct version in generated name. (cherry picked from commit 06d6e3d)
…n vcvarsall.bat (python#2252) * Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat Also fixes bdist_wininst.vcxproj to use correct version in generated name. (cherry-picked from parts of 40a23e8)
Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat
Also fixes bdist_wininst.vcxproj to use correct version in generated name.