1
0
Fork 0

Use our own cpython clone. (#1675)

This commit is contained in:
Julien Palard 2021-09-25 16:09:15 +02:00 committed by GitHub
parent 5fa489367e
commit 3392ebaa93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 70 deletions

View File

@ -1,41 +1,16 @@
Maintenance Maintenance
----------- -----------
Les commandes suivantes doivent être exécutées à partir de la racine d'un clone
de ``python-docs-fr`` et certaines s'attendent à trouver un clone de CPython
à jour à proximité :
.. code-block:: bash
~/
├── python-docs-fr/
└── cpython/
Pour cloner CPython, vous pouvez utiliser :
.. code-block:: bash
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git
Ceci évite de télécharger tout l'historique (inutile pour générer la
documentation) mais récupère néanmoins toutes les branches.
.. code-block:: bash
make merge
Dans certains cas on a besoin de propager des traductions d'une branche Dans certains cas on a besoin de propager des traductions d'une branche
à l'autre : à l'autre :
- d'une ancienne branche vers une nouvelle branche : lors du passage - d'une ancienne branche vers une nouvelle branche : lors du passage
d'une version à l'autre de CPython, lorsque quelqu'un a une PR sur une d'une version à l'autre de CPython, lorsque quelqu'un a une PR sur une
ancienne version (*forward porting*) ; ancienne version (*forward porting*) ;
- d'une nouvelle branche vers des anciennes branches : pour propager - d'une nouvelle branche vers des anciennes branches : pour propager
de temps en temps le travail sur d'anciennes versions (rétroportage de temps en temps le travail sur d'anciennes versions (rétroportage
ou *backporting*). ou *backporting*).
Pour forward-porter un ou plusieurs commits, il vaut mieux utiliser ``git Pour forward-porter un ou plusieurs commits, il vaut mieux utiliser ``git
cherry-pick -x LE_SHA``, ça garde l'auteur, le sha1 d'origine, et cherry-pick -x LE_SHA``, ça garde l'auteur, le sha1 d'origine, et
toutes les modifications. toutes les modifications.
@ -43,9 +18,9 @@ toutes les modifications.
Pour rétroporter « en gros » on utilise ``pomerge``\ : on le fait lire Pour rétroporter « en gros » on utilise ``pomerge``\ : on le fait lire
sur une branche, puis écrire sur une autre, par exemple pour copier de sur une branche, puis écrire sur une autre, par exemple pour copier de
la 3.8 à la 3.7 : la 3.8 à la 3.7 :
.. code-block:: bash .. code-block:: bash
git fetch git fetch
git checkout 3.8 git checkout 3.8
git reset --hard upstream/3.8 git reset --hard upstream/3.8
@ -56,10 +31,10 @@ la 3.8 à la 3.7 :
git add --patch git add --patch
git commit --message="Backporting from 3.8" git commit --message="Backporting from 3.8"
git push --set-upstream origin HEAD git push --set-upstream origin HEAD
Notes : Notes :
- j'utilise ``git fetch`` au début pour avoir *upstream/3.7* et - j'utilise ``git fetch`` au début pour avoir *upstream/3.7* et
*upstream/3.8* à jour localement, ainsi je peux travailler sans *upstream/3.8* à jour localement, ainsi je peux travailler sans
toucher au réseau jusqu'au ``git push``, mais chacun fait comme il toucher au réseau jusqu'au ``git push``, mais chacun fait comme il
@ -84,4 +59,3 @@ Notes :
en général, je n'ajoute pas les différences d'ordre dans les entêtes, en général, je n'ajoute pas les différences d'ordre dans les entêtes,
mais un ``git add --update`` irait très bien ; mais un ``git add --update`` irait très bien ;
- attention au fichier *dict* auquel il peut manquer des lignes. - attention au fichier *dict* auquel il peut manquer des lignes.

View File

@ -22,8 +22,6 @@
# .po files. # .po files.
CPYTHON_CURRENT_COMMIT := d5feb2b1f12a15c1a9bac094a8f6f77d0cfcbdc2 CPYTHON_CURRENT_COMMIT := d5feb2b1f12a15c1a9bac094a8f6f77d0cfcbdc2
CPYTHON_PATH := ../cpython/
LANGUAGE := fr LANGUAGE := fr
BRANCH := 3.10 BRANCH := 3.10
@ -57,52 +55,41 @@ endif
.PHONY: all .PHONY: all
all: ensure_prerequisites all: ensure_prerequisites
git -C $(CPYTHON_PATH) checkout $(CPYTHON_CURRENT_COMMIT) git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT) || (git -C venv/cpython fetch && git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT))
mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/ mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/
$(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/ $(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/
$(MAKE) -C $(CPYTHON_PATH)/Doc/ \ $(MAKE) -C venv/cpython/Doc/ \
SPHINXOPTS='-j$(JOBS) \ SPHINXOPTS='-j$(JOBS) \
-D locale_dirs=$(abspath locales) \ -D locale_dirs=$(abspath locales) \
-D language=$(LANGUAGE) \ -D language=$(LANGUAGE) \
-D gettext_compact=0 \ -D gettext_compact=0 \
-D latex_engine=xelatex \ -D latex_engine=xelatex \
-D latex_elements.inputenc= \ -D latex_elements.inputenc= \
-D latex_elements.fontenc=' \ -D latex_elements.fontenc=' \
$(MODE) $(MODE)
@echo "Build success, open file://$(abspath $(CPYTHON_PATH))/Doc/build/html/index.html or run 'make serve' to see them." @echo "Build success, open file://$(abspath venv/cpython/)/Doc/build/html/index.html or run 'make serve' to see them."
# We clone cpython/ inside venv/ because venv/ is the only directory
# excluded by cpython' Sphinx configuration.
venv/cpython/.git/HEAD:
git clone https://github.com/python/cpython venv/cpython
.PHONY: ensure_prerequisites .PHONY: ensure_prerequisites
ensure_prerequisites: ensure_prerequisites: venv/cpython/.git/HEAD
@if [ -z $(CPYTHON_PATH) ]; then \
echo "Your CPYTHON_PATH is empty, please provide one."; \
exit 1; \
fi
@if ! [ -d $(CPYTHON_PATH) ]; then \
echo "Building the translation requires a cpython clone."; \
echo "Please provide the path to a clone using the CPYTHON_PATH variable."; \
echo "(Currently CPYTHON_PATH is $(CPYTHON_PATH)."; \
echo "So you may want to run:"; \
echo ""; \
echo " git clone $(UPSTREAM) $(CPYTHON_PATH)"; \
exit 1; \
fi
@if [ -n "$$(git -C $(CPYTHON_PATH) status --porcelain)" ]; then \
echo "Your cpython clone at $(CPYTHON_PATH) is not clean."; \
echo "In order to avoid breaking things, please clean it first."; \
exit 1; \
fi
@if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \ @if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \
git -C $(CPYTHON_PATH) checkout $(BRANCH); \ git -C venv/cpython/ checkout $(BRANCH); \
echo "You're missing dependencies, please enable a venv and install:"; \ echo "You're missing dependencies please install:"; \
echo ""; \ echo ""; \
echo " python -m pip install -r requirements.txt -r $(CPYTHON_PATH)/Doc/requirements.txt"; \ echo " python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt"; \
exit 1; \ exit 1; \
fi fi
.PHONY: serve .PHONY: serve
serve: serve:
$(MAKE) -C $(CPYTHON_PATH)/Doc/ serve $(MAKE) -C venv/cpython/Doc/ serve
.PHONY: todo .PHONY: todo
todo: ensure_prerequisites todo: ensure_prerequisites
@ -135,13 +122,13 @@ verifs: wrap spell
.PHONY: merge .PHONY: merge
merge: ensure_prerequisites merge: ensure_prerequisites
@echo "Merge from $(UPSTREAM)" @echo "Merge from $(UPSTREAM)"
git -C $(CPYTHON_PATH) checkout $(BRANCH) git -C venv/cpython/ checkout $(BRANCH)
git -C $(CPYTHON_PATH) pull --ff-only git -C venv/cpython/ pull --ff-only
(cd $(CPYTHON_PATH)/Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot) (cd venv/cpython/Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot)
find $(CPYTHON_PATH)/pot/ -name '*.pot' |\ find venv/cpython/pot/ -name '*.pot' |\
while read -r POT; \ while read -r POT; \
do \ do \
PO="./$$(echo "$$POT" | sed "s#$(CPYTHON_PATH)/pot/##; s#\.pot\$$#.po#")"; \ PO="./$$(echo "$$POT" | sed "s#venv/cpython/pot/##; s#\.pot\$$#.po#")"; \
mkdir -p "$$(dirname "$$PO")"; \ mkdir -p "$$(dirname "$$PO")"; \
if [ -f "$$PO" ]; \ if [ -f "$$PO" ]; \
then \ then \
@ -150,10 +137,10 @@ merge: ensure_prerequisites
msgcat -o "$$PO" "$$POT"; \ msgcat -o "$$PO" "$$POT"; \
fi \ fi \
done done
rm -fr $(CPYTHON_PATH)/pot/ rm -fr venv/cpython/pot/
sed -i 's|^#: .*Doc/|#: |' *.po */*.po sed -i 's|^#: .*Doc/|#: |' *.po */*.po
powrap -m powrap -m
@printf "\n%s %s\n" "Replace CPYTHON_CURRENT_COMMIT in Makefile by: " $(shell git -C $(CPYTHON_PATH) rev-parse HEAD) @printf "\n%s %s\n" "Replace CPYTHON_CURRENT_COMMIT in Makefile by: " $(shell git -C venv/cpython/ rev-parse HEAD)
@printf 'To add, you can use:\n 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\n' @printf 'To add, you can use:\n 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\n'
.PHONY: clean .PHONY: clean