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
Batch file to mimic 'make' on Windows #61099
Comments
I find myself frustrated with some of the hoops I have to jump through and extra things I have to remember when I want to play around with Python on Windows. To make things a little easier, I've created a 'make.bat' file that can sit in the root of the repository and do a few of the more common tasks: make [build] [-64] -- Runs Tools\buildbot\build[-amd64].bat It seems to work pretty well for me and I think it could be very useful to others, particularly new contributors. I'm sure there's plenty of room for improvement, though :) I don't know if this script might interfere or conflict with Cygwin or other tools; if so and it were decided to include this file, it could easily be renamed to 'wmake.bat' or some such. Hope this is useful enough to include, or at least useful to someone else :) |
+1 Add make external[-64] to runs Tools/buildbot/external[-amd64].bat Even after reading build.bat, I do not understand what is the different net effect of that versus just double clicking pcbuild.sln and building. So some explanation in the devguide would be needed. |
Here's an updated version in the form of a patch. Features include:
Everything seems to work ok for me, but my testing platforms are limited to a single Win7 laptop, currently. This issue is also somewhat constrained by bpo-17202; it is supposed to work without any change to .hgeol, but that can't be guaranteed. |
+1 To use Tools/builbot/*.bat doesn't the current directory have to be the main directory of the repository? Then I see no point in the "-C" argument: just set the correct directory automatically. I think make.bat should also support creation of non-debug builds. (Maybe have targets "release" and "debug"?) Tools/buildbot/build.bat already calls external.bat and clean.bat. This currently makes the "ready" target unnecessary. However, I don't think build should be calling clean.bat (or external.bat). Perhaps you should just inline the necessary parts of Tools/buildbot/build.bat. |
That is true, and it does already automatically set the correct
I agree. I've had a thought for this; what about adding a
I thought the same initially, but I realized that it is useful for
I've thought about this too, and am thinking that it would make a |
One must run external.bat if one is to subsequently build from the vs gui with *most* of the external dependencies. I think the command to run it should be 'external', not 'ready'. 'External' means get the external dependencies and anyone who has run external.bat will know what it means. 'Ready' does not mean anything in particular. Just curious: What does running 'kill-python before re-building python do? I have not seen it mentioned in the in the devguide or pcbuild/readme. |
Fair point. Thinking about it again after some sleep, I agree. Next version will revert to 'external' rather than 'ready'.
I think the idea is to make sure everything is fresh, and avoid phantom problems from things that shouldn't cause problems, but do.
I believe it's what actually performs the cleaning process. Tools/buildbot/clean.bat builds kill_python.exe and then runs it. |
It kills any currently running python(_d).exe processes. This is because Windows does not allow program or library files to be removed or overwritten while they are being used, potentially causing compilation failures. |
Thanks, clean and kill make sense for unattended build-bots. For interactive use, when 2 minutes rebuilding is a big deal, clean is a last resort. Let's just make sure we do not somehow suggest that it needs to be done routinely. Or to put it another way, do document that 'build' is intended for fail-safer unattended buildbots and not necessarily for interactive human use. And also that kill does what a human would normally do by closing windows on the task bar, or, as a last resort, with task manager. |
I was rather off about kill_python, wasn't I? Anyway, I've finally gotten another version put together that I'd like to get comments on. Major differences between this patch and the previous one, in no particular order:
Several things have gone through an iteration or two since the last patch; I'll try to go through and add some comments on Rietveld myself. Since make.bat is now stand-alone, if it is accepted (and it is deemed desirable to do so), the Windows buildbots could be converted to use make.bat instead of Tools/buildbot/*, and that directory could actually be removed. This would also make it easy to set up a buildbot that tests a Release configuration of Python. All comments welcome :) |
You seem to end your subroutines (or whatever they are called) using "goto end" rather than "exit /b". Since popd follows the "end" label, does this mean that you get a popd after calling each subroutine? Is this intended and can it cause unmatched pushd/popd-s? (I am not familiar with writing batch files.) Also, I think 32 bit builds should be the default. Many people with 64 bit Windows are using Visual Studio Express which only has 32 bit support. |
Yes.
It is intended and it can, but so far I haven't run into any trouble
Fair point. I suppose I had been assuming that the error message from Thanks for the comments. |
Here's a new version of the patch, which is a major rewrite. Among the changes:
Everything works as expected for me, but I do only have a 32bit machine available to me currently. I hope to be able to test on a 64bit machine soon, but have no guarantees. For anyone testing this, I would suggest to run the command "prompt $+%PROMPT%" before testing; this will add a "+" to the beginning of your prompt for every dir on the pushd/popd stack. Neither configure.bat nor make.bat should ever remove dirs from that stack, and should not leave any extras when they're done (unless forcibly killed in the middle of running). |
I can't say I know enough about batch files to understand much of the code, but a few notes: Windows XP does not have the command "where" which you use -- Python 3.4 will still support XP. Except perhaps for looping I would prefer to get rid of the use of goto. The fact that some goto targets end in "exit /b ..." make it very confusing as to where "exit /b" will return control. The initial pushd is matched by various popd's which are scattered over hundreds of lines (including one in :usage). I think it would be better to keep matching pushd/popd reasonably close together. For instance, I think you could do something like
It would also be helpful if the end of the subroutines were marked with a comment like
|
Can't this just be a Python script? |
That would cause bootstrap issues for people who do not already have |
Oh, that is an issue. I don't have an XP machine to test on anymore,
The only goto's that are not part of loops are now one near the
Fair enough, I can change that. I tried to keep the matches to the
Easy enough, consider it done :) |
Don't we already require an existing Python to build some of the third-party stuff, e.g., OpenSSL? I don't think the bootstrapping issue holds that much weight. Adding some huge batch script that maybe one or two people even know how to modify is a much higher cost than just having someone install Python. |
Only for building a 64-bit Python on 32-bit Windows. Otherwise,
Fair enough, but even when Python is installed, there's still the However, you've made me think; perhaps configure.bat could build a |
Is this still relevant or has it been overtaken by other work from Zach or Steve? |
Still relevant, but the current patch is overkill (Brian was right, it's just way more batch than is healthy to check in). Things are changing rapidly, though; I'll close it as "postponed" for now, with the expectation of reopening someday. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: