Skip to content

Commit 3392eba

Browse files
authored
Use our own cpython clone. (#1675)
1 parent 5fa4893 commit 3392eba

File tree

2 files changed

+31
-70
lines changed

2 files changed

+31
-70
lines changed

CONTRIBUTING-CORE.rst

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,26 @@
11
Maintenance
22
-----------
33

4-
Les commandes suivantes doivent être exécutées à partir de la racine d'un clone
5-
de ``python-docs-fr`` et certaines s'attendent à trouver un clone de CPython
6-
à jour à proximité :
7-
8-
.. code-block:: bash
9-
10-
~/
11-
├── python-docs-fr/
12-
└── cpython/
13-
14-
15-
Pour cloner CPython, vous pouvez utiliser :
16-
17-
.. code-block:: bash
18-
19-
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git
20-
21-
22-
Ceci évite de télécharger tout l'historique (inutile pour générer la
23-
documentation) mais récupère néanmoins toutes les branches.
24-
25-
.. code-block:: bash
26-
27-
make merge
28-
294
Dans certains cas on a besoin de propager des traductions d'une branche
305
à l'autre :
31-
6+
327
- d'une ancienne branche vers une nouvelle branche : lors du passage
338
d'une version à l'autre de CPython, lorsque quelqu'un a une PR sur une
349
ancienne version (*forward porting*) ;
3510
- d'une nouvelle branche vers des anciennes branches : pour propager
3611
de temps en temps le travail sur d'anciennes versions (rétroportage
3712
ou *backporting*).
38-
13+
3914
Pour forward-porter un ou plusieurs commits, il vaut mieux utiliser ``git
4015
cherry-pick -x LE_SHA``, ça garde l'auteur, le sha1 d'origine, et
4116
toutes les modifications.
4217

4318
Pour rétroporter « en gros » on utilise ``pomerge``\ : on le fait lire
4419
sur une branche, puis écrire sur une autre, par exemple pour copier de
4520
la 3.8 à la 3.7 :
46-
21+
4722
.. code-block:: bash
48-
23+
4924
git fetch
5025
git checkout 3.8
5126
git reset --hard upstream/3.8
@@ -56,10 +31,10 @@ la 3.8 à la 3.7 :
5631
git add --patch
5732
git commit --message="Backporting from 3.8"
5833
git push --set-upstream origin HEAD
59-
60-
34+
35+
6136
Notes :
62-
37+
6338
- j'utilise ``git fetch`` au début pour avoir *upstream/3.7* et
6439
*upstream/3.8* à jour localement, ainsi je peux travailler sans
6540
toucher au réseau jusqu'au ``git push``, mais chacun fait comme il
@@ -84,4 +59,3 @@ Notes :
8459
en général, je n'ajoute pas les différences d'ordre dans les entêtes,
8560
mais un ``git add --update`` irait très bien ;
8661
- attention au fichier *dict* auquel il peut manquer des lignes.
87-

Makefile

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
# .po files.
2323
CPYTHON_CURRENT_COMMIT := d5feb2b1f12a15c1a9bac094a8f6f77d0cfcbdc2
2424

25-
CPYTHON_PATH := ../cpython/
26-
2725
LANGUAGE := fr
2826
BRANCH := 3.10
2927

@@ -57,52 +55,41 @@ endif
5755

5856
.PHONY: all
5957
all: ensure_prerequisites
60-
git -C $(CPYTHON_PATH) checkout $(CPYTHON_CURRENT_COMMIT)
58+
git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT) || (git -C venv/cpython fetch && git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT))
6159
mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/
6260
$(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/
63-
$(MAKE) -C $(CPYTHON_PATH)/Doc/ \
64-
SPHINXOPTS='-j$(JOBS) \
61+
$(MAKE) -C venv/cpython/Doc/ \
62+
SPHINXOPTS='-j$(JOBS) \
6563
-D locale_dirs=$(abspath locales) \
6664
-D language=$(LANGUAGE) \
67-
-D gettext_compact=0 \
65+
-D gettext_compact=0 \
6866
-D latex_engine=xelatex \
6967
-D latex_elements.inputenc= \
7068
-D latex_elements.fontenc=' \
7169
$(MODE)
72-
@echo "Build success, open file://$(abspath $(CPYTHON_PATH))/Doc/build/html/index.html or run 'make serve' to see them."
70+
@echo "Build success, open file://$(abspath venv/cpython/)/Doc/build/html/index.html or run 'make serve' to see them."
71+
72+
73+
# We clone cpython/ inside venv/ because venv/ is the only directory
74+
# excluded by cpython' Sphinx configuration.
75+
venv/cpython/.git/HEAD:
76+
git clone https://github.com/python/cpython venv/cpython
7377

7478

7579
.PHONY: ensure_prerequisites
76-
ensure_prerequisites:
77-
@if [ -z $(CPYTHON_PATH) ]; then \
78-
echo "Your CPYTHON_PATH is empty, please provide one."; \
79-
exit 1; \
80-
fi
81-
@if ! [ -d $(CPYTHON_PATH) ]; then \
82-
echo "Building the translation requires a cpython clone."; \
83-
echo "Please provide the path to a clone using the CPYTHON_PATH variable."; \
84-
echo "(Currently CPYTHON_PATH is $(CPYTHON_PATH)."; \
85-
echo "So you may want to run:"; \
86-
echo ""; \
87-
echo " git clone $(UPSTREAM) $(CPYTHON_PATH)"; \
88-
exit 1; \
89-
fi
90-
@if [ -n "$$(git -C $(CPYTHON_PATH) status --porcelain)" ]; then \
91-
echo "Your cpython clone at $(CPYTHON_PATH) is not clean."; \
92-
echo "In order to avoid breaking things, please clean it first."; \
93-
exit 1; \
94-
fi
80+
ensure_prerequisites: venv/cpython/.git/HEAD
9581
@if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \
96-
git -C $(CPYTHON_PATH) checkout $(BRANCH); \
97-
echo "You're missing dependencies, please enable a venv and install:"; \
82+
git -C venv/cpython/ checkout $(BRANCH); \
83+
echo "You're missing dependencies please install:"; \
9884
echo ""; \
99-
echo " python -m pip install -r requirements.txt -r $(CPYTHON_PATH)/Doc/requirements.txt"; \
85+
echo " python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt"; \
10086
exit 1; \
10187
fi
10288

89+
10390
.PHONY: serve
10491
serve:
105-
$(MAKE) -C $(CPYTHON_PATH)/Doc/ serve
92+
$(MAKE) -C venv/cpython/Doc/ serve
10693

10794
.PHONY: todo
10895
todo: ensure_prerequisites
@@ -135,13 +122,13 @@ verifs: wrap spell
135122
.PHONY: merge
136123
merge: ensure_prerequisites
137124
@echo "Merge from $(UPSTREAM)"
138-
git -C $(CPYTHON_PATH) checkout $(BRANCH)
139-
git -C $(CPYTHON_PATH) pull --ff-only
140-
(cd $(CPYTHON_PATH)/Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot)
141-
find $(CPYTHON_PATH)/pot/ -name '*.pot' |\
125+
git -C venv/cpython/ checkout $(BRANCH)
126+
git -C venv/cpython/ pull --ff-only
127+
(cd venv/cpython/Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot)
128+
find venv/cpython/pot/ -name '*.pot' |\
142129
while read -r POT; \
143130
do \
144-
PO="./$$(echo "$$POT" | sed "s#$(CPYTHON_PATH)/pot/##; s#\.pot\$$#.po#")"; \
131+
PO="./$$(echo "$$POT" | sed "s#venv/cpython/pot/##; s#\.pot\$$#.po#")"; \
145132
mkdir -p "$$(dirname "$$PO")"; \
146133
if [ -f "$$PO" ]; \
147134
then \
@@ -150,10 +137,10 @@ merge: ensure_prerequisites
150137
msgcat -o "$$PO" "$$POT"; \
151138
fi \
152139
done
153-
rm -fr $(CPYTHON_PATH)/pot/
140+
rm -fr venv/cpython/pot/
154141
sed -i 's|^#: .*Doc/|#: |' *.po */*.po
155142
powrap -m
156-
@printf "\n%s %s\n" "Replace CPYTHON_CURRENT_COMMIT in Makefile by: " $(shell git -C $(CPYTHON_PATH) rev-parse HEAD)
143+
@printf "\n%s %s\n" "Replace CPYTHON_CURRENT_COMMIT in Makefile by: " $(shell git -C venv/cpython/ rev-parse HEAD)
157144
@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'
158145

159146
.PHONY: clean

0 commit comments

Comments
 (0)