1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# Choose the correct python and virtualenv commands:
PYTHON := python
VIRTUALENV := virtualenv
SPHINXBUILD := sphinx-build
# If `python2` exists:
ifeq (1,$(shell python2 -c "print(1)" 2>&- ))
PYTHON := python2
endif
# If we are on cygwin:
ifeq (1,$(shell /cygdrive/c/Python27/python.exe -c "print(1)" 2>&- ))
PYTHON := /cygdrive/c/Python27/python.exe
endif
# If `virtualenv2` exists:
ifneq (,$(shell virtualenv2 --version 2>&- ))
VIRTUALENV := virtualenv2
endif
# If "--system-site-packages" supported:
ifneq (,$(shell $(VIRTUALENV) --system-site-packages --version 2>&- ))
VIRTUALENV += --system-site-packages
endif
# If `sphinx-build2` exists:
ifneq (,$(shell command -v sphinx-build2 2>&- ))
SPHINXBUILD := sphinx-build2
endif
export PYTHON # pass the variable to sub-makefiles through the environment
# Allow specifying an alternate root destination dir for system-wide installation:
ifdef DESTDIR
INSTALL_OPTS += --root="$(DESTDIR)"
endif
install-and-run-virtual-env: install-virtual-env
./bin/mnemosyne -d dot_mnemosyne2
install-virtual-env:
cd mnemosyne/pyqt_ui && make
cd mnemosyne/pyqt_ui && pyrcc4 -o mnemosyne_rc.py mnemosyne.qrc
./bin/python setup.py develop
setup:
$(VIRTUALENV) --python=$(PYTHON) .
./bin/easy_install nose
./bin/easy_install coverage
cd po && make
setup-windows:
virtualenv --system-site-packages --python=C:/python27/python.exe .
cp C:/python27/mplayer.exe Scripts/
cp C:/python27/qt.conf Scripts/
Scripts/easy_install.exe nose
Scripts/easy_install.exe coverage
install-virtual-env-windows:
cd mnemosyne/pyqt_ui && make
cd mnemosyne/pyqt_ui && pyrcc4 -o mnemosyne_rc.py mnemosyne.qrc
Scripts/python.exe setup.py develop
install-system:
# Also rebuilds the docs and the translations.
cd mnemosyne/libmnemosyne/docs && make SPHINXBUILD=$(SPHINXBUILD) html
cd mnemosyne/pyqt_ui && make clean
cd mnemosyne/pyqt_ui && make
cd mnemosyne/pyqt_ui && pyrcc4 -o mnemosyne_rc.py mnemosyne.qrc
cd po && make update
cd po && make
$(PYTHON) setup.py install $(INSTALL_OPTS)
rm -f -R build
build-all-deps:
# Also rebuilds the docs and the translations.
cd mnemosyne/libmnemosyne/docs && make SPHINXBUILD=$(SPHINXBUILD) html
# cd mnemosyne/pyqt_ui && make clean
cd mnemosyne/pyqt_ui && make
cd mnemosyne/pyqt_ui && pyrcc4 -o mnemosyne_rc.py mnemosyne.qrc
cd po && make update
cd po && make
test: install-virtual-env
./bin/nosetests tests
test-windows:
Scripts/nosetests.exe tests
coverage: install-virtual-env
rm -rf .coverage cover htmlcov
./bin/nosetests --with-coverage --cover-erase \
--cover-package=mnemosyne.libmnemosyne,openSM2sync || (echo "testsuite failed")
./bin/coverage html
google-chrome htmlcov/index.html
coverage-windows: install-virtual-env-windows
rm -rf .coverage cover htmlcov
Scripts/nosetests --with-coverage --cover-erase \
--cover-package=mnemosyne.libmnemosyne,openSM2sync || (echo "testsuite failed")
Scripts/coverage html
google-chrome htmlcov/index.html
profile: install-virtual-env
echo "from hotshot import stats" > process_profile.py
echo "s = stats.load(\"stats.dat\")" >> process_profile.py
echo "s.sort_stats(\"time\").print_stats()" >> process_profile.py
./bin/nosetests --with-profile --profile-stats-file=stats.dat
$(PYTHON) process_profile.py
gui-profile:
./bin/python -m cProfile -s cumulative bin/mnemosyne -d ./dot_mnemosyne2/ | more
benchmark: install-virtual-env
./bin/python tests/benchmark.py
osx: # Contributed by Patrick Kenny.
# You might need to making a pyrcc symlink from the Macports pyrcc4-x.x in /usr/bin
#
# make sure there are no existing build files
sudo rm -rf build/ dist/
# build the UI and the translations
cd mnemosyne/pyqt_ui && make clean
cd mnemosyne/pyqt_ui && make
cd mnemosyne/pyqt_ui && pyrcc4 -o mnemosyne_rc.py mnemosyne.qrc
cd po && make
# build the app with py2app
sudo $(PYTHON) setup.py py2app
# add a blank qt.conf so that the system will used the bundled qt instead of the system qt if the system already has qt installed
sudo touch dist/Mnemosyne.app/Contents/Resources/qt.conf
# copy qt_menu.nib directory: the application will not launch without this (assumes qt was installed with MacPorts)
sudo cp -R /opt/local/lib/Resources/qt_menu.nib dist/Mnemosyne.app/Contents/Resources/qt_menu.nib
# create the directory for the translations
sudo mkdir -p dist/Mnemosyne.app/Contents/Resources/share
# add the translations
sudo cp -R mo dist/Mnemosyne.app/Contents/Resources/share/locale
# by default, qt looks in the plugins directory in the root folder
sudo mkdir -p dist/Mnemosyne.app/Contents/plugins
# copy the dylib directory into plugins
sudo cp -R /opt/local/share/qt4/plugins/sqldrivers dist/Mnemosyne.app/Contents/plugins
# dylib must be relinked to use the bundled copy of Qt and not the system copy
sudo install_name_tool -change /opt/local/lib/libsqlite3.0.dylib @executable_path/../Frameworks/libsqlite3.0.dylib dist/Mnemosyne.app/Contents/plugins/sqldrivers/libqsqlite.dylib
sudo install_name_tool -change /opt/local/lib/libQtSql.4.dylib @executable_path/../Frameworks/libQtSql.4.dylib dist/Mnemosyne.app/Contents/plugins/sqldrivers/libqsqlite.dylib
sudo install_name_tool -change /opt/local/lib/libQtCore.4.dylib @executable_path/../Frameworks/libQtCore.4.dylib dist/Mnemosyne.app/Contents/plugins/sqldrivers/libqsqlite.dylib
# add directory to plugins to allow for imageformats support (we don't add all imageformats automatically because they all have to be relinked with install_name_tool, which is a real pain, so we pick and choose the formats to support)
sudo mkdir -p dist/Mnemosyne.app/Contents/plugins/imageformats
# add GIF support
sudo cp -R /opt/local/share/qt4/plugins/imageformats/libqgif.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqgif.dylib
sudo install_name_tool -change /opt/local/lib/libQtGui.4.dylib @executable_path/../Frameworks/libQtGui.4.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqgif.dylib
sudo install_name_tool -change /opt/local/lib/libQtCore.4.dylib @executable_path/../Frameworks/libQtCore.4.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqgif.dylib
# add JPG support
sudo cp -R /opt/local/share/qt4/plugins/imageformats/libqjpeg.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqjpeg.dylib
sudo install_name_tool -change /opt/local/lib/libQtGui.4.dylib @executable_path/../Frameworks/libQtGui.4.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqjpeg.dylib
sudo install_name_tool -change /opt/local/lib/libQtCore.4.dylib @executable_path/../Frameworks/libQtCore.4.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqjpeg.dylib
sudo cp /opt/local/lib/libjpeg.dylib dist/Mnemosyne.app/Contents/Frameworks/libjpeg.dylib
sudo install_name_tool -change /opt/local/lib/libjpeg.dylib @executable_path/../Frameworks/libjpeg.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqjpeg.dylib
sudo install_name_tool -change /opt/local/lib/libjpeg.dylib @executable_path/../Frameworks/libjpeg.dylib dist/Mnemosyne.app/Contents/Frameworks/libjpeg.dylib
# add TIFF support
sudo cp -R /opt/local/share/qt4/plugins/imageformats/libqtiff.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqtiff.dylib
sudo install_name_tool -change /opt/local/lib/libQtGui.4.dylib @executable_path/../Frameworks/libQtGui.4.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqtiff.dylib
sudo install_name_tool -change /opt/local/lib/libQtCore.4.dylib @executable_path/../Frameworks/libQtCore.4.dylib dist/Mnemosyne.app/Contents/plugins/imageformats/libqtiff.dylib
sudo cp /opt/local/lib/libtiff.dylib dist/Mnemosyne.app/Contents/Frameworks/libtiff.dylib
sudo install_name_tool -change /opt/local/lib/libtiff.dylib @executable_path/../Frameworks/libtiff.dylib dist/Mnemosyne.app/Contents/Frameworks/libtiff.dylib
sudo cp /opt/local/lib/libz.1.dylib dist/Mnemosyne.app/Contents/Frameworks/libz.1.dylib
sudo install_name_tool -change /opt/local/lib/libz.1.dylib @executable_path/../Frameworks/libz.1.dylib dist/Mnemosyne.app/Contents/Frameworks/libtiff.dylib
sudo install_name_tool -change /opt/local/lib/libjpeg.dylib @executable_path/../Frameworks/libjpeg.dylib dist/Mnemosyne.app/Contents/Frameworks/libtiff.dylib
wm: install-virtual-env
cp mnemosyne/ppygui_ui/ppygui_ui/*.py mnemosyne/ppygui_ui/
./bin/python mnemosyne/ppygui_ui/Mnemosyne\ Mobile.py
docs:
cd mnemosyne/libmnemosyne/docs && make html
android: # Creats the assets file with the Python code.
rm -f mnemosyne/android/mnemosyne/assets/mnemosyne.zip
#python -m compileall mnemosyne
zip -r mnemosyne/android/mnemosyne/assets/mnemosyne.zip openSM2sync -i \*.py
zip -r mnemosyne/android/mnemosyne/assets/mnemosyne.zip mnemosyne/libmnemosyne -i \*.py
zip -r mnemosyne/android/mnemosyne/assets/mnemosyne.zip mnemosyne/cle -i \*.py
zip mnemosyne/android/mnemosyne/assets/mnemosyne.zip mnemosyne/version.py mnemosyne/__init__.py
windows-installer:
rm -rf dist
rm -rf build
cd mnemosyne/pyqt_ui && make clean
cd mnemosyne/pyqt_ui && make
cd mnemosyne/pyqt_ui && pyrcc4 -o mnemosyne_rc.py mnemosyne.qrc
cd po && make
$(PYTHON) setup.py py2exe
read -p "Press any key when InnoSetup has finished..."
V=`$(PYTHON) mnemosyne/version.py` && cp dist/Output/setup.exe mnemosyne-$${V}-setup.exe
clean:
rm -f *~ *.pyc *.tgz process_profile.py
rm -f -R Mnemosyne.egg-info
rm -f -R distrib build bin lib include dot_mnemosyne2 dot_test dot_sync_*
rm -f -R dot_benchmark dist
cd mnemosyne/pyqt_ui && make clean
cd po && make clean
rm -f mnemosyne/*~ mnemosyne/*.pyc
rm -f mnemosyne/libmnemosyne/*~ mnemosyne/libmnemosyne/*.pyc
distrib: FORCE
rm -rf dist
cd po && make
cd mnemosyne/libmnemosyne/docs && make html
cd mnemosyne/pyqt_ui && make
$(PYTHON) setup.py sdist --formats=gztar
distrib-WM: FORCE
# Windows Mobile.
mkdir distrib
cp mnemosyne/ppygui_ui/INSTALL Mnemosyne\ Mobile.py distrib
mkdir distrib/ppygui_ui
cp -r mnemosyne/ppygui_ui/*.py distrib/ppygui_ui
V=`$(PYTHON) mnemosyne/version.py` && mv distrib mnemosyne-WM-$${V}
V=`$(PYTHON) mnemosyne/version.py` && tar cvfz mnemosyne-WM-$${V}.tgz \
mnemosyne-WM-$${V}/*
V=`$(PYTHON) mnemosyne/version.py` && rm -R mnemosyne-WM-$${V}
FORCE:
|