GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Docs: Create venv if missing by hugovk · Pull Request #98266 · python/cpython

Conversation

@hugovk

@hugovk hugovk commented Oct 14, 2022

Copy link
Copy Markdown
Member

Problem

I started getting this error:

$ make -C Doc clean
rm -rf ./venv
rm -rf build/*
$ make -C Doc html
mkdir -p build
Building NEWS from Misc/NEWS.d with blurb
PATH=./venv/bin:$PATH sphinx-build -b html -d build/doctrees  -j auto  -W . build/html
Running Sphinx v5.1.1
making output directory... done

Theme error:
no theme named 'python_docs_theme' found (missing theme.conf?)
make: *** [build] Error 2

That's because I have no venv so it can't find the theme.

The problem is we have this, which looks for Sphinx in the venv or $PATH:

SPHINXBUILD  = PATH=$(VENVDIR)/bin:$$PATH sphinx-build

And in my case it's finding it in my $PATH, so this guard passes:

cpython/Doc/Makefile

Line 55 in b863b9c

elif $(BLURB) help >/dev/null 2>&1 && $(SPHINXBUILD) --version >/dev/null 2>&1; then \

But I don't get this warning:

cpython/Doc/Makefile

Lines 65 to 66 in b863b9c

echo "Missing the required blurb or sphinx-build tools."; \
echo "Please run 'make venv' to install local copies."; \

Fix

Two things (aka let's do it like the devguide)

  1. let's just use the tools in the venv, not $PATH (to make the guard fail, and show the warning):

https://github.com/python/devguide/blob/05f6d0c8d09bd757440e0346190dbd62e06c7251/Makefile#L9-L10

  1. and add ensure-venv target that will install the venv if the venv dir is missing (to avoid the warning in the first place):

https://github.com/python/devguide/blob/05f6d0c8d09bd757440e0346190dbd62e06c7251/Makefile#L58-L64

Bonus

Whilst we're changing Docs/Makefile, PR #98189 recently fixed some missing .PHONY targets. 👍

I expect missing .PHONY targets will happen again, because it's normal to copy/paste a target, and forget (or not know) to update the long .PHONY line right at the top.

Let's do as @zware suggested and define them right next to each target: #98189 (comment)

We do this at Pillow and at work, it helps a lot. (I'll add it to the devguide and PEPs too.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
hugovk added 3 commits October 14, 2022 13:57
@hugovk
Docs: Add ensure-venv target to create venv if dir missing
325db7f
@hugovk
Docs: Use tools from venv
48a6bfd
@hugovk
Docs: Move .PHONY to each section to avoid copy/paste omissions
aeb85ad
@bedevere-bot bedevere-bot added the awaiting review label Oct 14, 2022
@hugovk hugovk mentioned this pull request Oct 14, 2022
Mark all targets in Doc/Makefile as PHONY #98189
Merged
@hugovk hugovk added skip issue skip news labels Oct 14, 2022
@zware

zware commented Oct 14, 2022

Copy link
Copy Markdown
Member

We've been down this road before and it was either not accepted or shortly reverted, though I don't remember why. There is some history to dig up and review here, though past rejection doesn't necessarily mean we must still stick to the status quo.

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk
Docs: Add ensure-venv target to create venv if dir missing
f40416a
@JelleZijlstra

JelleZijlstra commented Oct 15, 2022

Copy link
Copy Markdown
Member

See #27635 and issues #88919 and #88986. Because of a similar change we ended up with Pablo's venv in the distributed 3.10 tarballs.

zware reacted with thumbs up emoji hugovk reacted with eyes emoji
All reactions
  • 👍 1 reaction
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

hugovk commented Oct 21, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Right, so we need to be able to build using pre-downloaded tools not in the venv, so fix 1 and 2 are not needed.


We could add a check for other missing tools in this guard:

cpython/Doc/Makefile

Lines 55 to 59 in b863b9c

elif $(BLURB) help >/dev/null 2>&1 && $(SPHINXBUILD) --version >/dev/null 2>&1; then \
if [ -d ../Misc/NEWS.d ]; then \
echo "Building NEWS from Misc/NEWS.d with blurb"; \
$(BLURB) merge -f build/NEWS; \
else \

In this case, python_docs_theme was missing, and isn't easy to check for. So I guess "if in doubt, make clean venv applies :)

(I think I've seen a similar problem for another tool that could be checked easily, but I can't remember what it was so I'll address it if it comes up again.)


What's left? I think the bonus .PHONY change is still useful. Shall I refactor this PR or make a new, cleaner one?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 21, 2022
Move .PHONY to each section to avoid copy/paste omissions python/devguide#972
Merged
Infra: Declare Makefile targets as phony python/peps#2841
Merged
@hugovk hugovk mentioned this pull request Nov 11, 2022
Docs: Move .PHONY to each section to avoid copy/paste omissions #99396
Merged
@hugovk

hugovk commented Nov 11, 2022

Copy link
Copy Markdown
Member Author

What's left? I think the bonus .PHONY change is still useful. Shall I refactor this PR or make a new, cleaner one?

I went for a new, clean PR, please see #99396.

And let's close this one, thanks for the background!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk hugovk closed this Nov 11, 2022
@hugovk
hugovk deleted the update-docs-makefile branch November 11, 2022 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@hugovk @zware @JelleZijlstra @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.