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 in a virtual environment on Windows (#267) #268

Merged
merged 4 commits into from Oct 1, 2017

Conversation

@jeff5
Copy link
Contributor

@jeff5 jeff5 commented Sep 28, 2017

Add to the Windows build script a clause to create and use a virtual
environment and install Sphinx there, comparable with the Unix Makefile.
The user may suppress this behaviour by defining a her preferred command
in the environment variable SPHINXBUILD, as before.

Add to the Windows build script a clause to create and use a virtual
environment and install Sphinx there, comparable with the Unix Makefile.
The user may suppress this behaviour by defining a her preferred command
in the environment variable SPHINXBUILD, as before.
> .\make html
in the checkout directory, and again this will write the files to the
``_build\html`` directory.

This comment has been minimized.

@ezio-melotti

ezio-melotti Sep 28, 2017
Member

In order to avoid repetitions and keep the instructions concise, I think it would be better to say:

To build the devguide on an Unix-like system use:
  $ make html
On Windows, use:
  > .\make html
You will find the generate files in _build/html.

This comment has been minimized.

@zware

zware Sep 28, 2017
Member

The .\ shouldn't even be necessary unless that's a PowerShell-ism; the same command should work on both platforms.

.. code-block:: ps1con
PS> Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

This comment has been minimized.

@ezio-melotti

ezio-melotti Sep 28, 2017
Member

I'm not on Windows so I'm not sure how prevalent the use of PowerShell is but this seems a bit specific for the devguide.
Do you think PowerShell users can easily figure out the problem and the solution if they try to run that command from PS and get an error? If so, this should probably be removed; if instead this is not particularly obvious then it can stay.

This comment has been minimized.

@jeff5

jeff5 Sep 28, 2017
Author Contributor

Ok.

In the "Creator's Update" to Windows 10, a few months back, Microsoft took away convenient access to cmd from the File explorer (which is how I'd normally start my day), leaving only PS. I took the hint and rewrote my scripts. It is better IMO and should be considered the new default. I can't speak for uptake either, but yes, people have probably figured out the permissions thing.

This comment has been minimized.

@zware

zware Sep 28, 2017
Member

I agree that this probably doesn't need to be here.

By the way, right click the start button for an easy shortcut to Command Prompt (in regular and admin flavors), unless they also removed that in which case I'm never updating my VM again :)

make.bat Outdated

if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)

rem If we get this far, we're going to use the SPHINXBUILD command

This comment has been minimized.

@ezio-melotti

ezio-melotti Sep 28, 2017
Member

Unless we got a "clean" "check", "serve", "help", or "" we should get here, right?

This comment has been minimized.

@jeff5

jeff5 Sep 28, 2017
Author Contributor

Yes. The venv bit is here rather than up top for that reason. Perhaps it was someone's logic to order the targets so in anticipation. Happy to assume so.

make.bat Outdated
@@ -183,3 +196,4 @@ cmd /C %PYTHON% tools\serve.py %BUILDDIR%\html
goto end

:end
endlocal

This comment has been minimized.

@ezio-melotti

ezio-melotti Sep 28, 2017
Member

I think you are missing a newline at the end here.

make.bat Outdated
rem If we get this far, we're going to use the SPHINXBUILD command
if not defined SPHINXBUILD (
rem If it is not defined, we build in a virtual environment
if not exist venv (

This comment has been minimized.

@zware

zware Sep 28, 2017
Member

This needs some protection against running the script from somewhere other than the dir holding the script. I think if not exist %~dp0venv should do it, but make sure I remembered the correct flags.

This comment has been minimized.

@jeff5

jeff5 Sep 28, 2017
Author Contributor

Sorry, missed this comment the first look. I'll think about this. First thought is that it didn't have it before.

Second is that it might be useful and another thing I could take from the CPython docs build. I guess it would pushd to the right place ... https://github.com/python/cpython/blob/8d59aca4a953b097a9b02b0ecafef840e4ac5855/Doc/make.bat#L4

This comment has been minimized.

@jeff5

jeff5 Sep 28, 2017
Author Contributor

To clarify, I think the idiom in that example would make it run correctly whatever the current directory, but I'll check that (and figure out whether popd is needed).

> .\make html
in the checkout directory, and again this will write the files to the
``_build\html`` directory.

This comment has been minimized.

@zware

zware Sep 28, 2017
Member

The .\ shouldn't even be necessary unless that's a PowerShell-ism; the same command should work on both platforms.

.. code-block:: ps1con
PS> Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

This comment has been minimized.

@zware

zware Sep 28, 2017
Member

I agree that this probably doesn't need to be here.

By the way, right click the start button for an easy shortcut to Command Prompt (in regular and admin flavors), unless they also removed that in which case I'm never updating my VM again :)

@jeff5
Copy link
Contributor Author

@jeff5 jeff5 commented Sep 28, 2017

@zware So it does. The file explorer version was nice because it opened in the folder you had highlighted, so I'd generally do that 2 or 3 times to get started.

Nearly there with a change set satisfying @ezio-melotti .

In this section of the devguide you also claim make check will be run on check-ins, but evidently it is not, as it did not run cleanly for me even before I started. I'll give you separate PR for that. (Unrelated files.)

@jeff5
Copy link
Contributor Author

@jeff5 jeff5 commented Sep 28, 2017

@zware The .\make is indeed a concession to PShell, which requires it. It works with CMD too. I think CMD users will know it is unnecessary for them to type. Without this I'd be reverting docquality.rst to where I started (except for Ezio's side-improvements)!

Whatever the current directory when invoked, the build takes place into
_build/... in the directory that contains make.bat, and returns to the
invocation directory.
@jeff5
Copy link
Contributor Author

@jeff5 jeff5 commented Sep 29, 2017

Although still showing "changes requested" I believe the review comments are now answered, mostly by change. (Not sure if I've subverted the workflow somehow.) Anyhow, is this good enough to land this now?

make.bat Outdated
@@ -39,14 +41,29 @@ if "%1" == "help" (
echo. check
echo. serve to serve devguide on the localhost (8000)
goto end
)
:help0

This comment has been minimized.

@ezio-melotti

ezio-melotti Sep 29, 2017
Member

I'm not particularly familiar with bat files, and I'm not sure I understand this change.
ISTM that you just avoid printing the help if the arg is not "help", so the end result should be the same as before.
FWIW all the other commands follow the structure:

if "%1" == "something" (
    ...
    goto end
)

except "check" and "serve".
If possible, to maintain symmetry and improve readability, I would keep/adopt the same structure for all the different targets, and combine with an OR the two targets that result in an help ("help" and ""). This could be done in a separate PR, but unless there's a reason to break this structure, I would either revert or refactor this change.

(I made this comment on the first review, but apparently forgot to save/add it, so I'm adding it back now.)

This comment has been minimized.

@jeff5

jeff5 Sep 30, 2017
Author Contributor

I'm not great with .bat files either, but as briefly stated in the related issue #267, the .\make html currently builds nothing because goto end is executed unconditionally. I attributed this to known issues with parenthetical if bodies and goto, anr the legacy-style work-around made it go away.

On closer inspection, the problem is the un-escaped (8000). I can fix that.

There is no OR operator, but I can make it a bit clearer (closer to what sphinx-quickstart generated).

This comment has been minimized.

@ezio-melotti

ezio-melotti Sep 30, 2017
Member

If there's a valid reason to do it that way, then go ahead, but perhaps add a comment to document it :)

This comment has been minimized.

@jeff5

jeff5 Sep 30, 2017
Author Contributor

Thanks to your challenge I have found the real problem and the right answer.

Previously this disabled subsequent build targets by making "goto end"
accidentally unconditional. We also describe the "check" target.
@zware
zware approved these changes Sep 30, 2017
@ezio-melotti ezio-melotti merged commit 3d92a7e into python:master Oct 1, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ezio-melotti
Copy link
Member

@ezio-melotti ezio-melotti commented Oct 1, 2017

Merged, thanks for the PR!

@jeff5
Copy link
Contributor Author

@jeff5 jeff5 commented Oct 1, 2017

Thanks for the helpful reviews.

You may have spotted that my contributions are a side-effect of trying to re-use your work, or follow its model, in a devguide for Jython. I'll offer further things as I spot them.

@jeff5 jeff5 deleted the jeff5:iss267cp-win-venv branch Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.