Skip to content

Commit 3d92a7e

Browse files
jeff5ezio-melotti
authored andcommitted
Build in a virtual environment on Windows (python#267) (python#268)
* Build in a virtual environment on Windows (pythonGH-267) 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. * Simplify wording and add comment following review. * Always build relative to the directory containing make.bat 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. * Properly escape parentheses in the help text. Previously this disabled subsequent build targets by making "goto end" accidentally unconditional. We also describe the "check" target.
1 parent 2b84294 commit 3d92a7e

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

docquality.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,18 @@ To build the devguide, some additional dependencies are required (most
8686
importantly, `Sphinx`_), and the standard way to install dependencies in
8787
Python projects is to create a virtualenv, and then install dependencies from
8888
a ``requirements.txt`` file. For your convenience, this is all *automated for
89-
you* and all you have to do to build the devguide is run::
89+
you*. To build the devguide on a Unix-like system use::
9090

9191
$ make html
9292

93-
in the checkout directory, which will write the files to the ``_build/html``
94-
directory. Note that ``make check`` is automatically run when
93+
in the checkout directory. On Windows use:
94+
95+
.. code-block:: doscon
96+
97+
> .\make html
98+
99+
You will find the generated files in ``_build/html``.
100+
Note that ``make check`` is automatically run when
95101
you submit a :doc:`pull request <pullrequest>`, so you should make
96102
sure that it runs without errors.
97103

make.bat

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22

33
REM Command file for Sphinx documentation
44

5+
setlocal
6+
7+
pushd %~dp0
8+
59
if "%PYTHON%" == "" (
610
set PYTHON=py -3
711
)
8-
if "%SPHINXBUILD%" == "" (
9-
set SPHINXBUILD=sphinx-build
10-
)
12+
1113
set BUILDDIR=_build
1214
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
1315
if NOT "%PAPER%" == "" (
1416
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
1517
)
1618

17-
if "%1" == "" goto help
1819
if "%1" == "check" goto check
1920
if "%1" == "serve" goto serve
2021

22+
if "%1" == "" goto help
2123
if "%1" == "help" (
2224
:help
2325
echo.Please use `make ^<target^>` where ^<target^> is one of
@@ -36,8 +38,8 @@ if "%1" == "help" (
3638
echo. changes to make an overview over all changed/added/deprecated items
3739
echo. linkcheck to check all external links for integrity
3840
echo. doctest to run all doctests embedded in the documentation if enabled
39-
echo. check
40-
echo. serve to serve devguide on the localhost (8000)
41+
echo. check to check for stylistic and formal issues using rstlint
42+
echo. serve to serve devguide on the localhost ^(8000^)
4143
goto end
4244
)
4345

@@ -47,6 +49,21 @@ if "%1" == "clean" (
4749
goto end
4850
)
4951

52+
rem Targets other than "clean", "check", "serve", "help", or "" need the
53+
rem Sphinx build command, which the user may define via SPHINXBUILD.
54+
55+
if not defined SPHINXBUILD (
56+
rem If it is not defined, we build in a virtual environment
57+
if not exist venv (
58+
echo. Setting up the virtual environment
59+
%PYTHON% -m venv venv
60+
echo. Installing requirements
61+
venv\Scripts\python -m pip install -r requirements.txt
62+
)
63+
set PYTHON=venv\Scripts\python
64+
set SPHINXBUILD=venv\Scripts\sphinx-build
65+
)
66+
5067
if "%1" == "html" (
5168
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
5269
if errorlevel 1 exit /b 1
@@ -183,3 +200,5 @@ cmd /C %PYTHON% tools\serve.py %BUILDDIR%\html
183200
goto end
184201

185202
:end
203+
popd
204+
endlocal

0 commit comments

Comments
 (0)