Skip to content

Commit c8d9641

Browse files
committed
Merge branch '3.8' into interpreter
2 parents e7bef12 + 2e559a4 commit c8d9641

File tree

491 files changed

+25365
-11977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

491 files changed

+25365
-11977
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Réservation
3+
about: Juste réserver un fichier po (je veux être le seul à travailler dessus).
4+
title: Je travaille sur DOSSIER/FICHIER.po
5+
labels: reservation
6+
assignees: ''
7+
8+
---
9+
10+
<!---
11+
Attention, une réservation n'est effective qu'un mois, renouvelez-la si nécessaire en commentant dessus.
12+
-->

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
venv/
44
.idea/
55
.DS_Store
6+
.pospell/

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ before_install:
55
- sudo apt-get update
66
- sudo apt-get install -y hunspell hunspell-fr-comprehensive
77
install:
8-
- pip install pospell "powrap>=0.3.0"
8+
- pip install poutils
99
- pospell --version
1010
- powrap --version
11+
- padpo --version
1112
script:
12-
- powrap --check --quiet **/*.po
13-
- pospell -p dict -l fr_FR **/*.po
14-
- make CPYTHON_CLONE=/tmp/cpython/ COMMIT=4d1abedce9422473af2ac78047e55cde73208208
13+
- 'printf "%s\n" "$TRAVIS_COMMIT_RANGE"'
14+
- 'CHANGED_FILES="$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep "\.po$")" ;:'
15+
- 'printf "%s files changed.\n" "$(printf "%s" "$CHANGED_FILES" | grep -c "po$")" ;:'
16+
- 'if [ -n "$CHANGED_FILES" ]; then printf -- "- %s\n" $CHANGED_FILES; fi'
17+
- 'if [ -n "$CHANGED_FILES" ]; then powrap --check --quiet $CHANGED_FILES; fi'
18+
- 'if [ -n "$CHANGED_FILES" ]; then pospell -p dict -l fr_FR $CHANGED_FILES; fi'
19+
- 'if [ -n "$CHANGED_FILES" ]; then make CPYTHON_PATH=/tmp/cpython/; fi'
20+
- 'if [ -n "$CHANGED_FILES" ]; then padpo -i $CHANGED_FILES 2>&1 | grep -v -Ff padpo.ignore || true; fi'

CONTRIBUTING.rst

Lines changed: 585 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 115 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,96 +4,145 @@
44
#
55
# - make # Automatically build an html local version
66
# - make todo # To list remaining tasks
7-
# - make verifs # To check for correctness: wrapping, spelling
8-
# - make powrap # To check for wrapping
9-
# - make pospell # To check for spelling
7+
# - make verifs # To check for correctness: wrapping, spelling
8+
# - make wrap # To check for wrapping
9+
# - make spell # To check for spelling
1010
# - make merge # To merge pot from upstream
1111
# - make fuzzy # To find fuzzy strings
1212
# - make progress # To compute current progression
13-
# - make upgrade_venv # To upgrade the venv that compiles the doc
1413
#
1514
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
1615
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
1716
# real work to the Python Doc Makefile.
1817

19-
CPYTHON_CLONE := ../cpython/
20-
SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py
21-
LANGUAGE := fr
22-
VENV := ~/.venvs/python-docs-i18n/
23-
PYTHON := $(shell which python3)
24-
MODE := html
25-
BRANCH = 3.8
26-
COMMIT =
27-
JOBS = auto
18+
# Configuration
2819

20+
# The CPYTHON_CURRENT_COMMIT is the commit, in the cpython repository,
21+
# from which we generated our po files. We use it here so when we
22+
# test build, we're building with the .rst files that generated our
23+
# .po files.
24+
CPYTHON_CURRENT_COMMIT := 83d3202b92fb4c2fc6df5b035d57f3a1cf715f20
2925

30-
.PHONY: all
31-
all: $(SPHINX_CONF) $(VENV)/bin/activate
32-
ifneq "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
33-
$(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)")
34-
endif
35-
mkdir -p $(CPYTHON_CLONE)/locales/$(LANGUAGE)/
36-
ln -nfs $(shell $(PYTHON) -c 'import os; print(os.path.realpath("."))') $(CPYTHON_CLONE)/locales/$(LANGUAGE)/LC_MESSAGES
37-
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) 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=' $(MODE)
38-
26+
CPYTHON_PATH := ../cpython/
3927

40-
$(SPHINX_CONF):
41-
git clone --depth 1 --branch $(BRANCH) https://github.com/python/cpython.git $(CPYTHON_CLONE)
42-
[ -n "$(COMMIT)" ] && (i=1; while ! $$(git -C $(CPYTHON_CLONE) checkout $(COMMIT)); do i=$$((i * 2)); git -C $(CPYTHON_CLONE) fetch --depth $$i; done) || true
28+
LANGUAGE := fr
29+
BRANCH := 3.8
4330

4431

45-
.PHONY: upgrade_venv
46-
upgrade_venv:
47-
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) venv
48-
$(VENV)/bin/pip install -U pip potodo powrap pospell
32+
# Internal variables
4933

34+
UPSTREAM := https://github.com/python/cpython
35+
VENV := $(shell pwd)/venv/
36+
PYTHON := $(shell which python3)
37+
MODE := html
38+
POSPELL_TMP_DIR := .pospell/
39+
WORKTREES := $(VENV)/worktrees/
40+
WORKTREE := $(WORKTREES)/$(CPYTHON_CURRENT_COMMIT)/
41+
JOBS := auto
5042

51-
$(VENV)/bin/activate: $(SPHINX_CONF)
52-
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) venv
43+
.PHONY: all
44+
all: setup
45+
mkdir -p $(WORKTREE)/locales/$(LANGUAGE)/LC_MESSAGES/
46+
cp --parents *.po */*.po $(WORKTREE)/locales/$(LANGUAGE)/LC_MESSAGES/
47+
$(MAKE) -C $(WORKTREE)/Doc/ VENVDIR=$(WORKTREE)/Doc/venv/ PYTHON=$(PYTHON) \
48+
SPHINXOPTS='-qW -j$(JOBS) \
49+
-D locale_dirs=../locales \
50+
-D language=$(LANGUAGE) \
51+
-D gettext_compact=0 \
52+
-D latex_engine=xelatex \
53+
-D latex_elements.inputenc= \
54+
-D latex_elements.fontenc=' \
55+
$(MODE) && echo "Build success, open file://$(WORKTREE)/Doc/build/html/index.html or run 'make serve' to see them."
56+
57+
58+
.PHONY: setup
59+
setup: venv
60+
# Setup the main clone
61+
if ! [ -d $(CPYTHON_PATH) ]; then \
62+
git clone --depth 16 --branch $(BRANCH) $(UPSTREAM) $(CPYTHON_PATH); \
63+
fi
64+
65+
# Setup the current worktree
66+
if ! [ -d $(WORKTREE) ]; then \
67+
rm -fr $(WORKTREES); \
68+
git -C $(CPYTHON_PATH) worktree prune; \
69+
mkdir -p $(WORKTREES); \
70+
if [ -n "$(CPYTHON_CURRENT_COMMIT)" ]; \
71+
then \
72+
depth=32; \
73+
while ! git -C $(CPYTHON_PATH) cat-file -e $(CPYTHON_CURRENT_COMMIT); \
74+
do \
75+
depth=$$((depth * 2)); \
76+
git -C $(CPYTHON_PATH) fetch --depth $$depth $(UPSTREAM) $(BRANCH); \
77+
done \
78+
else \
79+
git -C $(CPYTHON_PATH) fetch --depth 1 $(UPSTREAM); \
80+
fi; \
81+
git -C $(CPYTHON_PATH) worktree add $(WORKTREE)/ $(CPYTHON_CURRENT_COMMIT); \
82+
$(MAKE) -C $(WORKTREE)/Doc/ VENVDIR=$(WORKTREE)/Doc/venv/ PYTHON=$(PYTHON) venv; \
83+
fi
84+
85+
86+
.PHONY: venv
87+
venv:
88+
@if [ ! -d $(VENV) ]; then $(PYTHON) -m venv --prompt python-docs-fr $(VENV); fi
89+
@$(VENV)/bin/python -m pip install -q -r requirements.txt 2> $(VENV)/pip-install.log
90+
@if grep -q 'pip install --upgrade pip' $(VENV)/pip-install.log; then \
91+
$(VENV)/bin/pip install -q --upgrade pip; \
92+
fi
93+
94+
95+
.PHONY: serve
96+
serve:
97+
$(MAKE) -C $(WORKTREE)/Doc/ serve
5398

5499

55100
.PHONY: progress
56101
progress:
57-
@python3 -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
102+
@$(PYTHON) -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
58103
$(shell msgcat *.po */*.po | msgattrib --translated | grep -c '^msgid') \
59104
$(shell msgcat *.po */*.po | grep -c '^msgid')
60105

61106

62-
$(VENV)/bin/potodo: $(VENV)/bin/activate
63-
$(VENV)/bin/pip install potodo
107+
.PHONY: todo
108+
todo: venv
109+
$(VENV)/bin/potodo
64110

65-
$(VENV)/bin/powrap: $(VENV)/bin/activate
66-
$(VENV)/bin/pip install powrap
111+
.PHONY: wrap
112+
wrap: venv
113+
$(VENV)/bin/powrap --check --quiet *.po **/*.po
67114

68-
$(VENV)/bin/pospell: $(VENV)/bin/activate
69-
$(VENV)/bin/pip install pospell
115+
SRCS = $(shell git diff --name-only $(BRANCH) | grep '.po$$')
116+
# foo/bar.po => $(POSPELL_TMP_DIR)/foo/bar.po.out
117+
DESTS = $(addprefix $(POSPELL_TMP_DIR)/,$(addsuffix .out,$(SRCS)))
70118

71-
.PHONY: todo
72-
todo: $(VENV)/bin/potodo
73-
$(VENV)/bin/potodo
119+
.PHONY: spell
120+
spell: venv $(DESTS)
74121

75-
.PHONY: verifs
76-
verifs: powrap pospell
122+
$(POSPELL_TMP_DIR)/%.po.out: %.po dict
123+
@echo "Checking $<..."
124+
@mkdir -p $(@D)
125+
@$(VENV)/bin/pospell -p dict -l fr_FR $< && touch $@
77126

78-
.PHONY: powrap
79-
powrap: $(VENV)/bin/powrap
80-
$(VENV)/bin/powrap --check --quiet *.po */*.po
127+
.PHONY: fuzzy
128+
fuzzy: venv
129+
$(VENV)/bin/potodo -f
81130

82-
.PHONY: pospell
83-
pospell: $(VENV)/bin/pospell
84-
$(VENV)/bin/pospell -p dict -l fr_FR *.po */*.po
131+
.PHONY: verifs
132+
verifs: wrap spell
85133

86134
.PHONY: merge
87-
merge: upgrade_venv
88-
ifneq "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
89-
$(error "You're merging from a different branch:" "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" vs "$(BRANCH)")
90-
endif
91-
(cd $(CPYTHON_CLONE)/Doc; rm -f build/NEWS)
92-
(cd $(CPYTHON_CLONE); $(VENV)/bin/sphinx-build -Q -b gettext -D gettext_compact=0 Doc pot/)
93-
find $(CPYTHON_CLONE)/pot/ -name '*.pot' |\
135+
merge: setup
136+
git -C $(CPYTHON_PATH) fetch $(UPSTREAM)
137+
rm -fr $(WORKTREES)/$(BRANCH)
138+
git -C $(CPYTHON_PATH) worktree prune
139+
git -C $(CPYTHON_PATH) worktree add $(WORKTREES)/$(BRANCH) $(word 1,$(shell git -C $(CPYTHON_PATH) remote -v | grep python/cpython))/$(BRANCH)
140+
$(MAKE) -C $(WORKTREES)/$(BRANCH)/Doc/ VENVDIR=$(WORKTREES)/$(BRANCH)/Doc/venv/ PYTHON=$(PYTHON) venv;
141+
(cd $(WORKTREES)/$(BRANCH); $(WORKTREES)/$(BRANCH)/Doc/venv/bin/sphinx-build -Q -b gettext -D gettext_compact=0 Doc pot/)
142+
find $(WORKTREES)/$(BRANCH) -name '*.pot' |\
94143
while read -r POT;\
95144
do\
96-
PO="./$$(echo "$$POT" | sed "s#$(CPYTHON_CLONE)/pot/##; s#\.pot\$$#.po#")";\
145+
PO="./$$(echo "$$POT" | sed "s#$(WORKTREES)/$(BRANCH)/pot/##; s#\.pot\$$#.po#")";\
97146
mkdir -p "$$(dirname "$$PO")";\
98147
if [ -f "$$PO" ];\
99148
then\
@@ -105,8 +154,12 @@ endif
105154
msgcat -o "$$PO" "$$POT";\
106155
fi\
107156
done
108-
109-
110-
.PHONY: fuzzy
111-
fuzzy: $(VENV)/bin/potodo
112-
$(VENV)/bin/potodo -f
157+
sed -i 's/^CPYTHON_CURRENT_COMMIT :=.*/CPYTHON_CURRENT_COMMIT := $(shell git -C $(WORKTREES)/$(BRANCH) rev-parse HEAD)/' Makefile
158+
rm -fr $(WORKTREES)/$(BRANCH)
159+
git -C $(CPYTHON_PATH) worktree prune
160+
echo 'To add, you can use git status -s | grep "^ M .*\.po" | cut -d" " -f3 | while read -r file; do if [ $$(git diff "$$file" | wc -l) -gt 13 ]; then git add "$$file"; fi ; done'
161+
162+
.PHONY: clean
163+
clean:
164+
rm -fr venv $(POSPELL_TMP_DIR)
165+
find -name '*.mo' -delete

0 commit comments

Comments
 (0)