1- # Makefile fortr Python Documentation
1+ # Makefile forTurkish Python Documentation
22#
33# Here is what you can do:
44#
55# - make # Automatically build an HTML local version
6- # - make todo # To list remaining tasks
6+ # - make todo # To list remaining tasks and show current progression
77# - make verifs # To check for correctness: wrapping, spelling
8- # - make wrap # Tocheck for wrapping
8+ # - make wrap # Torewrap modified files
99# - make spell # To check for spelling
10- # - makemerge # Tomerge pot from upstream
10+ # - makeclean # Toremove build artifacts
1111# - make fuzzy # To find fuzzy strings
12- # - make progress # To compute current progression
1312#
1413# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
1514# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
2120# from which we generated our po files. We use it here so when we
2221# test build, we're building with the .rst files that generated our
2322# .po files.
24- CPYTHON_CURRENT_COMMIT := b027dd78bbdb66f2995bb898af304e66e5508bf6
25-
26- CPYTHON_PATH := ../cpython/
27-
23+ CPYTHON_CURRENT_COMMIT := e699e5c20fc495952905597edfa82de0c1848f8c
2824LANGUAGE := tr
2925BRANCH := 3.10
3026
31- EXCLUDED := whatsnew/ c-api/
27+ EXCLUDED :=\
28+ whatsnew/2.?.po\
29+ whatsnew/3.[0-8].po\
30+ c-api/\
31+ distutils/\
32+ install/\
33+ library/2to3.po\
34+ library/distutils.po\
35+ library/imp.po\
36+ library/tkinter.tix.po\
37+ library/test.po\
38+ library/aifc.po\
39+ library/asynchat.po\
40+ library/asyncore.po\
41+ library/audioop.po\
42+ library/cgi.po\
43+ library/cgitb.po\
44+ library/chunk.po\
45+ library/crypt.po\
46+ library/imghdr.po\
47+ library/msilib.po\
48+ library/nntplib.po\
49+ library/nis.po\
50+ library/ossaudiodev.po\
51+ library/pipes.po\
52+ library/smtpd.po\
53+ library/sndhdr.po\
54+ library/spwd.po\
55+ library/sunau.po\
56+ library/telnetlib.po\
57+ library/uu.po\
58+ library/xdrlib.po
3259
3360# Internal variables
3461
@@ -38,6 +65,7 @@ PYTHON := $(shell which python3)
3865MODE := html
3966POSPELL_TMP_DIR := .pospell/
4067JOBS := auto
68+ SERVE_PORT :=
4169
4270# Detect OS
4371
@@ -58,89 +86,54 @@ endif
5886
5987.PHONY : all
6088all : ensure_prerequisites
61- git -C$( CPYTHON_PATH ) checkout$(CPYTHON_CURRENT_COMMIT )
89+ git -Cvenv/cpython checkout $( CPYTHON_CURRENT_COMMIT ) || (git -C venv/cpython fetch && git -C venv/cpython checkout$( CPYTHON_CURRENT_COMMIT) )
6290mkdir -p locales/$(LANGUAGE ) /LC_MESSAGES/
6391$(CP_CMD ) -u --parents* .po* /* .po locales/$(LANGUAGE ) /LC_MESSAGES/
64- $(MAKE ) -C$( CPYTHON_PATH ) / Doc/\
65- SPHINXOPTS=' -qW - j$(JOBS) \
92+ $(MAKE ) -Cvenv/cpython/ Doc/\
93+ SPHINXOPTS=' -j$(JOBS) \
6694 -D locale_dirs=$(abspath locales) \
6795 -D language=$(LANGUAGE ) \
68- -D gettext_compact=0\
96+ -D gettext_compact=0\
6997 -D latex_engine=xelatex\
7098 -D latex_elements.inputenc=\
7199 -D latex_elements.fontenc=' \
72100$(MODE )
73- git -C$(CPYTHON_PATH ) checkout -
74- @echo" Build success, open file://$( abspath$( CPYTHON_PATH) ) /Doc/build/html/index.html or run 'make serve' to see them."
101+ @echo" Build success, open file://$( abspath venv/cpython/) /Doc/build/html/index.html or run 'make serve' to see them."
102+
103+
104+ # We clone cpython/ inside venv/ because venv/ is the only directory
105+ # excluded by cpython' Sphinx configuration.
106+ venv/cpython/.git/HEAD :
107+ git clone https://github.com/python/cpython venv/cpython
75108
76109
77110.PHONY : ensure_prerequisites
78- ensure_prerequisites :
79- @if [-z $( CPYTHON_PATH) ]; then \
80- echo " Your CPYTHON_PATH is empty, please provide one." ; \
81- exit 1; \
82- fi
83- @if! [-d $( CPYTHON_PATH) ]; then \
84- echo " Building the translation requires a cpython clone." ; \
85- echo " Please provide the path to a clone using the CPYTHON_PATH variable." ; \
86- echo " (Currently CPYTHON_PATH is$( CPYTHON_PATH) ." ; \
87- echo " So you may want to run:" ; \
88- echo " " ; \
89- echo " git clone$( UPSTREAM) $( CPYTHON_PATH) " ; \
90- exit 1; \
91- fi
92- @if [-n " $$ (git -C$( CPYTHON_PATH) status --porcelain)" ]; then \
93- echo " Your cpython clone at$( CPYTHON_PATH) is not clean." ; \
94- echo " In order to avoid breaking things, please clean it first." ; \
95- exit 1; \
96- fi
111+ ensure_prerequisites : venv/cpython/.git/HEAD
97112@if! (blurbhelp > /dev/null2>&1 && sphinx-build --version> /dev/null2>&1 ); then \
98- git -C$( CPYTHON_PATH ) checkout$(BRANCH ) ; \
99- echo " You're missing dependencies, please enable a venv and install:" ; \
113+ git -Cvenv/cpython/ checkout$(BRANCH ) ; \
114+ echo " You're missing dependencies please install:" ; \
100115echo " " ; \
101- echo " python -m pip install -r requirements.txt -r$( CPYTHON_PATH ) /Doc/requirements.txt" ; \
116+ echo " python -m pip install -r requirements.txt -rvenv/cpython /Doc/requirements.txt" ; \
102117exit 1; \
103118fi
104119
120+
105121.PHONY : serve
106122serve :
107- $(MAKE ) -C$(CPYTHON_PATH ) /Doc/ serve
108-
109-
110- .PHONY : progress
111- progress :
112- ifeq ($(file ) ,)
113- @echo "No file specified, showing total progress"; \
114- $(PYTHON) -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
115- $(shell msgcat *.po */*.po | msgattrib --translated | grep -c '^msgid') \
116- $(shell msgcat *.po */*.po | grep -c '^msgid')
117-
123+ ifdef SERVE_PORT
124+ $(MAKE) -C venv/cpython/Doc/ serve SERVE_PORT=$(SERVE_PORT)
118125else
119- @$(PYTHON) -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
120- $(shell msgcat $(file) | msgattrib --translated | grep -c '^msgid') \
121- $(shell msgcat $(file) | grep -c '^msgid')
126+ $(MAKE) -C venv/cpython/Doc/ serve
122127endif
123128
124-
125129.PHONY : todo
126130todo : ensure_prerequisites
127131potodo --exclude venv .venv$(EXCLUDED )
128132
129133.PHONY : wrap
130134wrap : ensure_prerequisites
131- ifeq ($(fix ) ,)
132- @echo "Verify wrapping"
133- powrap --check --quiet *.po **/*.po
134-
135- else
136- ifeq ($(file ) ,)
137- @echo "Checking and fixing wrapping"
138- powrap *.po **/*.po
139- else
140- @echo "Fixing wrapping in $(file)"
141- powrap $(file)
142- endif
143- endif
135+ @echo" Re wrapping modified files"
136+ powrap -m
144137
145138SRCS =$(shell git diff --name-only$(BRANCH ) | grep '.po$$')
146139# foo/bar.po => $(POSPELL_TMP_DIR)/foo/bar.po.out
@@ -152,41 +145,19 @@ spell: ensure_prerequisites $(DESTS)
152145$(POSPELL_TMP_DIR ) /% .po.out :% .po dict
153146@echo" Pospell checking $<..."
154147mkdir -p$(@D )
155- pospell -p dict -lfr_FR $< && touch$@
148+ pospell -p dict -ltr_TR $< && touch$@
156149
157150.PHONY : fuzzy
158151fuzzy : ensure_prerequisites
159152potodo -f --exclude venv .venv$(EXCLUDED )
160153
161154.PHONY : verifs
162- verifs : wrap spell
163-
164- .PHONY : merge
165- merge : ensure_prerequisites
166- @echo" Merge from$( UPSTREAM) "
167- git -C$(CPYTHON_PATH ) checkout$(BRANCH )
168- git -C$(CPYTHON_PATH ) pull --ff-only
169- (cd$( CPYTHON_PATH) /Doc; sphinx-build -Q -b gettext -D gettext_compact=0. ../pot)
170- find$(CPYTHON_PATH ) /pot/ -name' *.pot' | \
171- while read -r POT; \
172- do \
173- PO=" ./$$ (echo" $$ POT" | sed" s#$(CPYTHON_PATH ) /pot/# #; s#\.pot\$$#.po#")"; \
174- mkdir -p" $$ (dirname" $$ PO" )" ; \
175- if [-f " $$ PO" ]; \
176- then \
177- msgmerge --backup=off --force-po -U" $$ PO" " $$ POT" ; \
178- else \
179- msgcat -o" $$ PO" " $$ POT" ; \
180- fi \
181- done
182- rm -fr$(CPYTHON_PATH ) /pot/
183- sed -i' s|^#: .*Doc/|#: |' * .po* /* .po
184- powrap -m
185- @printf" \n%s %s\n" " Replace CPYTHON_CURRENT_COMMIT in Makefile by:" $(shell git -C$(CPYTHON_PATH ) rev-parse HEAD)
186- @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'
155+ verifs : spell
187156
188157.PHONY : clean
189158clean :
190159@echo" Cleaning *.mo and$( POSPELL_TMP_DIR) "
191- rm -fr $(POSPELL_TMP_DIR )
160+ rm -rf $(POSPELL_TMP_DIR )
192161find -name' *.mo' -delete
162+ @echo" Cleaning build directory"
163+ $(MAKE ) -C venv/cpython/Doc/ clean