Ported build of Anki apkg to Python 3.
--- a/Makefile Wed Jan 31 00:27:20 2018 +0200
+++ b/Makefile Fri Feb 09 15:05:35 2018 +0200
@@ -538,6 +538,17 @@
@echo ===== TSL =====
python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/tsl.var
+.PHONY: missing-speakout
+missing-speakout: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS)
+ @echo ===== so1 =====
+ python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so1.list | tee so1.miss
+ @echo ===== so2 =====
+ python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so2.list | tee so2.miss
+ @echo ===== so3 =====
+ python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so3.list | tee so3.miss
+ @echo ===== so4 =====
+ python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so4.list | tee so4.miss
+
define stat-cmd
{ \
stat() { \
@@ -646,17 +657,17 @@
# Specific rules (due to renames or other customization).
dist/anki/gadict.apkg: gadict.gadict $(GADICT_DEL_FILE) py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
- PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python -B py/gadict_srs_anki.py -name="gadict_en-ru+uk" -rich $(GADICT_DEL_OPT) $(FREQLIST_OPT) $< $@
+ PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name="gadict_en-ru+uk" -rich $(GADICT_DEL_OPT) $(FREQLIST_OPT) $< $@
dist/anki/gadict_voa.apkg: gadict_voa.gadict py/gadict.py py/gadict_srs_anki.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
- PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python -B py/gadict_srs_anki.py -name="gadict_voa" $(VOA_FREQLIST_OPT) $< $@
+ PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name="gadict_voa" $(VOA_FREQLIST_OPT) $< $@
# General rules.
dist/anki/%.apkg: %.gadict %.del py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
- PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python -B py/gadict_srs_anki.py -name=$* -rich -delfile=$*.del $(FREQLIST_OPT) $< $@
+ PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name=$* -rich -delfile=$*.del $(FREQLIST_OPT) $< $@
dist/anki/%.apkg: %.gadict py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
- PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python -B py/gadict_srs_anki.py -name=$* -rich $(FREQLIST_OPT) $< $@
+ PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name=$* -rich $(FREQLIST_OPT) $< $@
.PHONY: tab
tab: $(SRS_TAB_FILES)
--- a/py/gadict_srs_anki.py Wed Jan 31 00:27:20 2018 +0200
+++ b/py/gadict_srs_anki.py Fri Feb 09 15:05:35 2018 +0200
@@ -222,7 +222,7 @@
deck_id = collection.decks.id(self.name)
# It is essential to keep model['id'] unchanged between upgrades!!
- model_id = int(hashlib.sha1(self.name).hexdigest(), 16) % (2**63)
+ model_id = int(hashlib.sha1(self.name.encode('utf-8')).hexdigest(), 16) % (2**63)
################################################################
# Regular card model. SafeBack doesn't include examples to not spoil
@@ -340,9 +340,9 @@
:unambiguous used if several subsequent article with same headword (and different pronunciation)
"""
if unambiguous > 0:
- h = hashlib.md5(":".join((self.name, nodetype, headword, str(unambiguous))))
+ h = hashlib.md5(":".join((self.name, nodetype, headword, str(unambiguous))).encode('utf-8'))
else:
- h = hashlib.md5(":".join((self.name, nodetype, headword)))
+ h = hashlib.md5(":".join((self.name, nodetype, headword)).encode('utf-8'))
return h.hexdigest()
def add_note(self, headword, unambiguous, front, back, safeback, freq="", tags=None):
--- a/www/HACKING.rst Wed Jan 31 00:27:20 2018 +0200
+++ b/www/HACKING.rst Fri Feb 09 15:05:35 2018 +0200
@@ -48,11 +48,26 @@
$ make dict
-To produce Anki decks install Anki v... on Linux or get Anki sources at specific
-version (before port to Python 3)::
+To make Anki decks checkout Anki sources::
$ git clone https://github.com/dae/anki.git
$ cd anki
+
+and update to specific revision (before strong dependency to ``pyaudio`` which
+is not available on Cygwin)::
+
+ $ git co 1d75cff5e7458c6538a4e75728c16bef8b7adb3e^
+
+ $ git show 1d75cff5e7458c6538a4e75728c16bef8b7adb3e
+ commit 1d75cff5e7458c6538a4e75728c16bef8b7adb3e
+ Author: Damien Elmes <git@ichi2.net>
+ Date: 2016-06-23 12:04:48 +1000
+
+ pyaudio is no longer optional
+
+Previously build uses Python 2 and depends on earlier source revitions (before
+port to Python 3)::
+
$ git co 15b349e3^
$ git show 15b349e3