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
-----------
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
à l'autre :
- 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
ancienne version (*forward porting*) ;
- d'une nouvelle branche vers des anciennes branches : pour propager
de temps en temps le travail sur d'anciennes versions (rétroportage
ou *backporting*).
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
toutes les modifications.
@ -43,9 +18,9 @@ toutes les modifications.
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
la 3.8 à la 3.7 :
.. code-block:: bash
git fetch
git checkout 3.8
git reset --hard upstream/3.8
@ -56,10 +31,10 @@ la 3.8 à la 3.7 :
git add --patch
git commit --message="Backporting from 3.8"
git push --set-upstream origin HEAD
Notes :
- j'utilise ``git fetch`` au début pour avoir *upstream/3.7* et
*upstream/3.8* à jour localement, ainsi je peux travailler sans
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,
mais un ``git add --update`` irait très bien ;
- attention au fichier *dict* auquel il peut manquer des lignes.

View File

@ -22,8 +22,6 @@
# .po files.
CPYTHON_CURRENT_COMMIT := d5feb2b1f12a15c1a9bac094a8f6f77d0cfcbdc2
CPYTHON_PATH := ../cpython/
LANGUAGE := fr
BRANCH := 3.10
@ -57,52 +55,41 @@ endif
.PHONY: all
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/
$(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/
$(MAKE) -C $(CPYTHON_PATH)/Doc/ \
SPHINXOPTS='-j$(JOBS) \
$(MAKE) -C venv/cpython/Doc/ \
SPHINXOPTS='-j$(JOBS) \
-D locale_dirs=$(abspath locales) \
-D language=$(LANGUAGE) \
-D gettext_compact=0 \
-D gettext_compact=0 \
-D latex_engine=xelatex \
-D latex_elements.inputenc= \
-D latex_elements.fontenc=' \
$(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
ensure_prerequisites:
@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
ensure_prerequisites: venv/cpython/.git/HEAD
@if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \
git -C $(CPYTHON_PATH) checkout $(BRANCH); \
echo "You're missing dependencies, please enable a venv and install:"; \
git -C venv/cpython/ checkout $(BRANCH); \
echo "You're missing dependencies please install:"; \
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; \
fi
.PHONY: serve
serve:
$(MAKE) -C $(CPYTHON_PATH)/Doc/ serve
$(MAKE) -C venv/cpython/Doc/ serve
.PHONY: todo
todo: ensure_prerequisites
@ -135,13 +122,13 @@ verifs: wrap spell
.PHONY: merge
merge: ensure_prerequisites
@echo "Merge from $(UPSTREAM)"
git -C $(CPYTHON_PATH) checkout $(BRANCH)
git -C $(CPYTHON_PATH) pull --ff-only
(cd $(CPYTHON_PATH)/Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot)
find $(CPYTHON_PATH)/pot/ -name '*.pot' |\
git -C venv/cpython/ checkout $(BRANCH)
git -C venv/cpython/ pull --ff-only
(cd venv/cpython/Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot)
find venv/cpython/pot/ -name '*.pot' |\
while read -r POT; \
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")"; \
if [ -f "$$PO" ]; \
then \
@ -150,10 +137,10 @@ merge: ensure_prerequisites
msgcat -o "$$PO" "$$POT"; \
fi \
done
rm -fr $(CPYTHON_PATH)/pot/
rm -fr venv/cpython/pot/
sed -i 's|^#: .*Doc/|#: |' *.po */*.po
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'
.PHONY: clean