2020-11-01 05:26:58 +01:00
|
|
|
# Anki development
|
2020-08-03 07:31:22 +02:00
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
## Packaged betas
|
2020-08-03 07:31:22 +02:00
|
|
|
|
2020-01-02 10:55:27 +01:00
|
|
|
For non-developers who want to try this development code, the easiest way is
|
2020-08-03 07:31:22 +02:00
|
|
|
to use a packaged version - please see:
|
2020-01-02 10:55:27 +01:00
|
|
|
|
2020-08-03 07:31:22 +02:00
|
|
|
https://betas.ankiweb.net/#/
|
2020-01-02 10:55:27 +01:00
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
You are welcome to run Anki from source instead, but it is expected that you can
|
|
|
|
sort out issues by yourself - we are not able to provide support for problems
|
|
|
|
you encounter when running from source.
|
2020-01-02 10:55:27 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Pre-built Python wheels
|
2020-08-03 07:31:22 +02:00
|
|
|
|
|
|
|
If you want to run Anki from a local Python installation but don't want
|
|
|
|
to make changes to the source code, you can install pre-built packages from PyPI.
|
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
For older versions:
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
```
|
2020-08-03 07:31:22 +02:00
|
|
|
$ python -m venv pyenv
|
|
|
|
$ pyenv/bin/pip install aqt anki ankirspy pyqt5 pyqtwebengine
|
|
|
|
$ pyenv/bin/python -c 'import aqt; aqt.run()'
|
2020-11-01 05:26:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
From Anki 2.1.36 onwards:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ python -m venv pyenv
|
|
|
|
$ pyenv/bin/pip install aqt anki pyqtwebengine
|
|
|
|
$ pyenv/bin/python -c 'import aqt; aqt.run()'
|
|
|
|
```
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
## Building from source
|
2020-08-03 07:31:22 +02:00
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
Platform-specific instructions:
|
|
|
|
|
|
|
|
- [Windows](./windows.md)
|
|
|
|
- [Mac](./mac.md)
|
|
|
|
- [Linux](./linux.md)
|
2020-01-02 10:55:27 +01:00
|
|
|
|
2020-09-07 08:03:21 +02:00
|
|
|
Don't name the Git checkout ~/Anki or ~/Documents/Anki, as those folders
|
|
|
|
were used on old Anki versions and will be automatically moved.
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
Before contributing code, please see [Contributing](./contributing.md).
|
2020-01-02 10:55:27 +01:00
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
If you'd like to contribute translations, please see <https://translating.ankiweb.net/#/>.
|
2020-01-02 10:55:27 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Running tests
|
2020-01-02 10:55:27 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
From inside the source folder:
|
2020-11-01 05:26:58 +01:00
|
|
|
|
2020-04-16 10:19:56 +02:00
|
|
|
```
|
2020-11-04 05:01:14 +01:00
|
|
|
bazel test //...
|
2020-04-16 10:19:56 +02:00
|
|
|
```
|
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Fixing formatting
|
2020-11-01 05:26:58 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
If the format tests fail, most can be fixed by running format_fix
|
|
|
|
in the relevant folder:
|
2020-04-11 06:36:05 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
```
|
|
|
|
bazel run //rslib:format_fix
|
|
|
|
bazel run //pylib:format_fix
|
|
|
|
bazel run //pylib/rsbridge:format_fix
|
|
|
|
bazel run //qt:format_fix
|
|
|
|
```
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
Currently the typescript code needs to be formatted differently:
|
2020-11-01 05:26:58 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
```
|
|
|
|
cd ts
|
|
|
|
./node_modules/.bin/prettier --write .
|
|
|
|
```
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Building redistributable wheels
|
2020-11-01 05:26:58 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
```
|
|
|
|
bazel build -c opt //pylib/anki:wheel
|
|
|
|
bazel build -c opt //qt/aqt:wheel
|
|
|
|
```
|
2020-10-09 11:19:54 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Tracing build problems
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
You can run bazel with '-s' to print the commands that are being executed.
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Subcomponents
|
2020-11-01 05:26:58 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
- pylib contains a Python module (anki) with the non-GUI Python code,
|
|
|
|
and a bridge to the Rust code.
|
|
|
|
- qt contains the Qt GUI implementation (aqt).
|
|
|
|
- rslib contains the parts of the code implemented in Rust.
|
|
|
|
- ts contains Anki's typescript and sass files.
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Environmental Variables
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
If ANKIDEV is set before starting Anki, some extra log messages will be printed on stdout,
|
|
|
|
and automatic backups will be disabled - so please don't use this except on a test profile.
|
2020-11-01 05:26:58 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
If LOGTERM is set before starting Anki, warnings and error messages that are normally placed
|
|
|
|
in the collection2.log file will also be printed on stdout.
|
2020-10-09 11:19:54 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
## Mixing development and study
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
You may wish to create a separate profile with File>Switch Profile for use
|
|
|
|
during development. You can pass the arguments "-p [profile name]" when starting
|
|
|
|
Anki to load a specific profile.
|
2020-11-01 05:26:58 +01:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
If you're using PyCharm:
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
- right click on the "run" file in the root of the PyCharm Anki folder
|
|
|
|
- click "Edit 'run'..." - in Script options and enter:
|
|
|
|
"-p [dev profile name]" without the quotes
|
|
|
|
- click "Ok"
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
# Instructions need updating:
|
2020-10-03 07:26:34 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
optional deps:
|
|
|
|
pyaudio
|
|
|
|
dpkg: portaudio19-dev
|
2020-04-11 06:36:05 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
mpv
|
|
|
|
lame
|
2020-04-11 06:36:05 +02:00
|
|
|
|
2020-11-04 05:01:14 +01:00
|
|
|
1. Download and install the pyaudio wheel from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
|