forked from AFPy/python-docs-fr
A way to ensure everyone is testing locally with the right version of cpython. (#1050)
This commit is contained in:
parent
ff1f732b5b
commit
5d7112d2b7
|
@ -15,4 +15,4 @@ script:
|
||||||
- '[ -n "$CHANGED_FILES" ] && printf -- "- %s\n" $CHANGED_FILES ;:'
|
- '[ -n "$CHANGED_FILES" ] && printf -- "- %s\n" $CHANGED_FILES ;:'
|
||||||
- '[ -n "$CHANGED_FILES" ] && powrap --check --quiet $CHANGED_FILES || :'
|
- '[ -n "$CHANGED_FILES" ] && powrap --check --quiet $CHANGED_FILES || :'
|
||||||
- '[ -n "$CHANGED_FILES" ] && pospell -p dict -l fr_FR $CHANGED_FILES || :'
|
- '[ -n "$CHANGED_FILES" ] && pospell -p dict -l fr_FR $CHANGED_FILES || :'
|
||||||
- '[ -n "$CHANGED_FILES" ] && make CPYTHON_CLONE=/tmp/cpython/ COMMIT=e21aa61e96f8343200e765d119ebe778873a6bf1 || :'
|
- '[ -n "$CHANGED_FILES" ] && make CPYTHON_CLONE=/tmp/cpython/ || :'
|
||||||
|
|
162
Makefile
162
Makefile
|
@ -4,59 +4,94 @@
|
||||||
#
|
#
|
||||||
# - make # Automatically build an html local version
|
# - make # Automatically build an html local version
|
||||||
# - make todo # To list remaining tasks
|
# - make todo # To list remaining tasks
|
||||||
# - make verifs # To check for correctness: wrapping, spelling
|
# - make verifs # To check for correctness: wrapping, spelling
|
||||||
# - make wrap # To check for wrapping
|
# - make wrap # To check for wrapping
|
||||||
# - make spell # To check for spelling
|
# - make spell # To check for spelling
|
||||||
# - make merge # To merge pot from upstream
|
# - make merge # To merge pot from upstream
|
||||||
# - make fuzzy # To find fuzzy strings
|
# - make fuzzy # To find fuzzy strings
|
||||||
# - make progress # To compute current progression
|
# - make progress # To compute current progression
|
||||||
# - make upgrade_venv # To upgrade the venv that compiles the doc
|
|
||||||
#
|
#
|
||||||
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
|
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
|
||||||
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
|
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
|
||||||
# real work to the Python Doc Makefile.
|
# real work to the Python Doc Makefile.
|
||||||
|
|
||||||
CPYTHON_CLONE := $(realpath ../cpython/)
|
# Configuration
|
||||||
SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py
|
|
||||||
|
# The CPYTHON_CURRENT_COMMIT is the commit, in the cpython repository,
|
||||||
|
# from which we generated our po files. We use it here so when we
|
||||||
|
# test build, we're building with the .rst files that generated our
|
||||||
|
# .po files.
|
||||||
|
CPYTHON_CURRENT_COMMIT := e21aa61e96f8343200e765d119ebe778873a6bf1
|
||||||
|
|
||||||
|
CPYTHON_PATH := $(realpath ../cpython/)
|
||||||
|
|
||||||
LANGUAGE := fr
|
LANGUAGE := fr
|
||||||
|
BRANCH := 3.8
|
||||||
|
|
||||||
|
|
||||||
|
# Internal variables
|
||||||
|
|
||||||
|
UPSTREAM := https://github.com/python/cpython
|
||||||
VENV := $(shell pwd)/venv/
|
VENV := $(shell pwd)/venv/
|
||||||
PYTHON := $(shell which python3)
|
PYTHON := $(shell which python3)
|
||||||
MODE := html
|
MODE := html
|
||||||
BRANCH = 3.8
|
WORKTREES := $(VENV)/worktrees/
|
||||||
COMMIT =
|
WORKTREE := $(WORKTREES)/$(CPYTHON_CURRENT_COMMIT)/
|
||||||
JOBS = auto
|
JOBS := auto
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(SPHINX_CONF) $(VENV)/bin/activate
|
all: setup
|
||||||
ifneq "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
|
mkdir -p $(WORKTREE)/locales/$(LANGUAGE)/LC_MESSAGES/
|
||||||
$(warning "Your ../cpython checkout may be on the wrong branch, got $(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD) expected $(BRANCH)")
|
cp --parents *.po */*.po $(WORKTREE)/locales/$(LANGUAGE)/LC_MESSAGES/
|
||||||
endif
|
$(MAKE) -C $(WORKTREE)/Doc/ VENVDIR=$(WORKTREE)/Doc/venv/ PYTHON=$(PYTHON) \
|
||||||
mkdir -p $(CPYTHON_CLONE)/locales/$(LANGUAGE)/
|
SPHINXOPTS='-qW -j$(JOBS) \
|
||||||
ln -nfs $(shell $(PYTHON) -c 'import os; print(os.path.realpath("."))') $(CPYTHON_CLONE)/locales/$(LANGUAGE)/LC_MESSAGES
|
-D locale_dirs=../locales \
|
||||||
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) \
|
-D language=$(LANGUAGE) \
|
||||||
SPHINXOPTS='-qW -j$(JOBS) -D locale_dirs=../locales -D language=$(LANGUAGE) -D gettext_compact=0 -D latex_engine=xelatex -D latex_elements.inputenc= -D latex_elements.fontenc=' \
|
-D gettext_compact=0 \
|
||||||
$(MODE) && echo "Build success, open file://$(CPYTHON_CLONE)/Doc/build/html/index.html or run 'make serve' to see them."
|
-D latex_engine=xelatex \
|
||||||
|
-D latex_elements.inputenc= \
|
||||||
|
-D latex_elements.fontenc=' \
|
||||||
|
$(MODE) && echo "Build success, open file://$(WORKTREE)/Doc/build/html/index.html or run 'make serve' to see them."
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: setup
|
||||||
|
setup: venv
|
||||||
|
# Setup the main clone
|
||||||
|
if ! [ -d $(CPYTHON_PATH) ]; then \
|
||||||
|
git clone --depth 16 --branch $(BRANCH) $(UPSTREAM) $(CPYTHON_PATH); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup the current worktree
|
||||||
|
if ! [ -d $(WORKTREE) ]; then \
|
||||||
|
rm -fr $(WORKTREES); \
|
||||||
|
git -C $(CPYTHON_PATH) worktree prune; \
|
||||||
|
mkdir -p $(WORKTREES); \
|
||||||
|
if [ -n "$(CPYTHON_CURRENT_COMMIT)" ]; \
|
||||||
|
then \
|
||||||
|
depth=32; \
|
||||||
|
while ! git -C $(CPYTHON_PATH) rev-parse $(CPYTHON_CURRENT_COMMIT); \
|
||||||
|
do \
|
||||||
|
depth=$$((depth * 2)); \
|
||||||
|
git -C $(CPYTHON_PATH) fetch --depth $$depth $(UPSTREAM); \
|
||||||
|
done \
|
||||||
|
else \
|
||||||
|
git -C $(CPYTHON_PATH) fetch --depth 1 $(UPSTREAM); \
|
||||||
|
fi; \
|
||||||
|
git -C $(CPYTHON_PATH) worktree add $(WORKTREE)/ $(CPYTHON_CURRENT_COMMIT); \
|
||||||
|
$(MAKE) -C $(WORKTREE)/Doc/ VENVDIR=$(WORKTREE)/Doc/venv/ PYTHON=$(PYTHON) venv; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: venv
|
||||||
|
venv:
|
||||||
|
if [ ! -d $(VENV) ]; then $(PYTHON) -m venv --prompt python-docs-fr $(VENV); fi
|
||||||
|
$(VENV)/bin/pip install -q -U -r requirements.txt
|
||||||
|
|
||||||
|
|
||||||
.PHONY: serve
|
.PHONY: serve
|
||||||
serve:
|
serve:
|
||||||
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ serve
|
$(MAKE) -C $(WORKTREE)/Doc/ serve
|
||||||
|
|
||||||
|
|
||||||
$(SPHINX_CONF):
|
|
||||||
git clone --depth 1 --branch $(BRANCH) https://github.com/python/cpython.git $(CPYTHON_CLONE)
|
|
||||||
[ -n "$(COMMIT)" ] && (i=1; while ! $$(git -C $(CPYTHON_CLONE) checkout $(COMMIT)); do i=$$((i * 2)); git -C $(CPYTHON_CLONE) fetch --depth $$i; done) || true
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: upgrade_venv
|
|
||||||
upgrade_venv:
|
|
||||||
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) venv
|
|
||||||
$(VENV)/bin/pip install -U pip potodo powrap pospell
|
|
||||||
|
|
||||||
|
|
||||||
$(VENV)/bin/activate: $(SPHINX_CONF)
|
|
||||||
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) venv
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: progress
|
.PHONY: progress
|
||||||
|
@ -66,41 +101,37 @@ progress:
|
||||||
$(shell msgcat *.po */*.po | grep -c '^msgid')
|
$(shell msgcat *.po */*.po | grep -c '^msgid')
|
||||||
|
|
||||||
|
|
||||||
$(VENV)/bin/potodo: $(VENV)/bin/activate
|
|
||||||
$(VENV)/bin/pip install potodo
|
|
||||||
|
|
||||||
$(VENV)/bin/powrap: $(VENV)/bin/activate
|
|
||||||
$(VENV)/bin/pip install powrap
|
|
||||||
|
|
||||||
$(VENV)/bin/pospell: $(VENV)/bin/activate
|
|
||||||
$(VENV)/bin/pip install pospell
|
|
||||||
|
|
||||||
.PHONY: todo
|
.PHONY: todo
|
||||||
todo: $(VENV)/bin/potodo
|
todo: venv
|
||||||
$(VENV)/bin/potodo
|
$(VENV)/bin/potodo
|
||||||
|
|
||||||
|
.PHONY: wrap
|
||||||
|
wrap: venv
|
||||||
|
$(VENV)/bin/powrap --check --quiet *.po **/*.po
|
||||||
|
|
||||||
|
.PHONY: spell
|
||||||
|
spell: venv
|
||||||
|
$(VENV)/bin/pospell -p dict -l fr_FR *.po **/*.po
|
||||||
|
|
||||||
|
.PHONY: fuzzy
|
||||||
|
fuzzy: venv
|
||||||
|
$(VENV)/bin/potodo -f
|
||||||
|
|
||||||
.PHONY: verifs
|
.PHONY: verifs
|
||||||
verifs: wrap spell
|
verifs: wrap spell
|
||||||
|
|
||||||
.PHONY: wrap
|
|
||||||
wrap: $(VENV)/bin/powrap
|
|
||||||
$(VENV)/bin/powrap --check --quiet *.po **/*.po
|
|
||||||
|
|
||||||
.PHONY: spell
|
|
||||||
spell: $(VENV)/bin/pospell
|
|
||||||
$(VENV)/bin/pospell -p dict -l fr_FR *.po **/*.po
|
|
||||||
|
|
||||||
.PHONY: merge
|
.PHONY: merge
|
||||||
merge: upgrade_venv
|
merge: setup
|
||||||
ifneq "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
|
git -C $(CPYTHON_PATH) fetch $(UPSTREAM)
|
||||||
$(error "You're merging from a different branch:" "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" vs "$(BRANCH)")
|
rm -fr $(WORKTREES)/$(BRANCH)
|
||||||
endif
|
git -C $(CPYTHON_PATH) worktree prune
|
||||||
(cd $(CPYTHON_CLONE)/Doc; rm -f build/NEWS)
|
git -C $(CPYTHON_PATH) worktree add $(WORKTREES)/$(BRANCH) $(word 1,$(shell git -C $(CPYTHON_PATH) remote -v | grep python/cpython))/$(BRANCH)
|
||||||
(cd $(CPYTHON_CLONE); $(VENV)/bin/sphinx-build -Q -b gettext -D gettext_compact=0 Doc pot/)
|
$(MAKE) -C $(WORKTREES)/$(BRANCH)/Doc/ VENVDIR=$(WORKTREES)/$(BRANCH)/Doc/venv/ PYTHON=$(PYTHON) venv;
|
||||||
find $(CPYTHON_CLONE)/pot/ -name '*.pot' |\
|
(cd $(WORKTREES)/$(BRANCH); $(WORKTREES)/$(BRANCH)/Doc/venv/bin/sphinx-build -Q -b gettext -D gettext_compact=0 Doc pot/)
|
||||||
|
find $(WORKTREES)/$(BRANCH) -name '*.pot' |\
|
||||||
while read -r POT;\
|
while read -r POT;\
|
||||||
do\
|
do\
|
||||||
PO="./$$(echo "$$POT" | sed "s#$(CPYTHON_CLONE)/pot/##; s#\.pot\$$#.po#")";\
|
PO="./$$(echo "$$POT" | sed "s#$(WORKTREES)/$(BRANCH)/pot/##; s#\.pot\$$#.po#")";\
|
||||||
mkdir -p "$$(dirname "$$PO")";\
|
mkdir -p "$$(dirname "$$PO")";\
|
||||||
if [ -f "$$PO" ];\
|
if [ -f "$$PO" ];\
|
||||||
then\
|
then\
|
||||||
|
@ -112,8 +143,11 @@ endif
|
||||||
msgcat -o "$$PO" "$$POT";\
|
msgcat -o "$$PO" "$$POT";\
|
||||||
fi\
|
fi\
|
||||||
done
|
done
|
||||||
|
sed -i 's/^CPYTHON_CURRENT_COMMIT :=.*/CPYTHON_CURRENT_COMMIT := $(shell git -C $(WORKTREES)/$(BRANCH) rev-parse HEAD)/' Makefile
|
||||||
|
rm -fr $(WORKTREES)/$(BRANCH)
|
||||||
|
git -C $(CPYTHON_PATH) worktree prune
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
.PHONY: fuzzy
|
clean:
|
||||||
fuzzy: $(VENV)/bin/potodo
|
rm -fr venv
|
||||||
$(VENV)/bin/potodo -f
|
find -name '*.mo' -delete
|
||||||
|
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
poutils==0.1.2
|
Loading…
Reference in New Issue
Block a user