Commit Graph

165 Commits

Author SHA1 Message Date
Abdo
50c0f22af4 Define env vars for n2's hide_success/hide_progress 2026-05-05 22:33:09 +03:00
Abdo
4f86576f1d feat: Use Briefcase on Linux (#4774)
## Linked issue

#4769

## Summary

This switches Anki to use Briefcase for Linux packaging instead of
PyInstaller:
- Use the default
[briefcase-linux-system-template](https://github.com/beeware/briefcase-linux-system-template)
with some changes to link the binary against an embedded Python build
instead of the system's Python.
- Define a custom "zip" output format implemented via a Briefcase
plugin. This serves as a replacement for the build.sh script and allows
us to bypass the system Python check Briefcase enforces for the default
"system" format.

## How to test

- Build the zip: `./ninja installer:package`.
- Extract the zip under `out/installer/dist`, install and run.
- If you have access to a distro with a different system Python version,
copy the zip there and confirm it's working.
2026-05-04 21:15:50 +03:00
Abdo
e633196f32 Fix formatting & clippy errors 2026-05-03 18:16:38 +03:00
Andrew Sanchez
233ae4e9aa Add support for releasing to justfile. 2026-05-01 12:21:41 -04:00
Andrew Sanchez
e7c0d03bd6 Simplify release inputs. 2026-05-01 12:05:29 -04:00
Andrew Sanchez
c1ae5a1d62 fix: Sign Windows Anki.exe before MSI packaging (#4767) 2026-04-30 14:26:28 -04:00
Abdo
4ca399b4f9 docs: Expand releasing notes (#4759)
## Linked issue

#4701

## Summary

Move release workflow notes added in #4632 to docs/releasing.md and add
a section about public announcements.
2026-04-28 19:33:56 +03:00
Andrew Sanchez
47bc74deeb Release action (#4632)
Add a GitHub Actions workflow for building andreleasing Anki Desktop
---
Co-authored-by: Andrew Sanchez <andrewsanchez@users.noreply.github.com>
Co-authored-by: Abdo <abdo@abdnh.net>
Co-authored-by: Fernando Lins <1887601+fernandolins@users.noreply.github.com>
2026-04-27 17:45:07 -04:00
Abdo
6b4aca995b Merge branch 'main' into briefcase 2026-04-27 20:31:17 +03:00
Abdo
81eefc5f71 Render GH Markdown alerts in Sphinx docs (#4663)
See
https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts

We started using this syntax recently: #4466 #4662

## How to test

See preview:
https://anki-core--4663.org.readthedocs.build/en/4663/windows.html
2026-04-08 19:10:17 +03:00
cypher
65f45ea87d Update docker build command for syncserver (#4562)
The command for building the image does not include the` --platform`
flag which prevents the image from running across all architectures. For
example, if I build the image on an ARM system and then try running on
x86, it won’t work.

This issue can be fixed by using `docker buildx` and adding the flag to
include all of the platforms. I have tested this by building the image
with the `linux/arm64` and `linux/amd64` platform flags on an ARM system
and then running a container with that image on an x86 system.

This would be useful in scenarios where the syncserver runs on devices
that cannot do builds.

The correct command would be 
```bash
# Builds for all existing platforms supported by Docker
docker buildx build -f <Dockerfile> --platform linux/amd64,linux/arm64,windows/amd64 --no-cache --build-arg ANKI_VERSION=<version> -t anki-sync-server .
```
Reference: https://docs.docker.com/build/building/multi-platform/
2026-04-07 16:51:28 +03:00
Fernando Lins
447795bbb9 Add pre-commit for automated pre-push checks (#4660)
## Description / motivation

Versioned hook configuration and a single documented install path reduce
friction and drift between machines compared to copy-pasted shell hooks.

## How to test

1. `$ uv sync --group dev`
2. `$ uv run pre-commit install --hook-type pre-push`
3. Make any change, commit it, and push it

<img width="908" height="253" alt="image"
src="https://github.com/user-attachments/assets/d492e2a8-9f33-4adf-866e-04c54cbf57d9"
/>

### Details

- Add `.pre-commit-config.yaml` with a **pre-push** hook that runs
`./ninja check`
- Add `pre-commit` to the `dev` dependency group and refresh `uv.lock`.
- Update `docs/contributing.md`: contributors install hooks via `uv run
pre-commit` / `python -m pre_commit`, and drop the old suggestion of
manual `.git/hooks` scripts.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
2026-04-06 12:04:49 -03:00
user1823
869cfad899 Update Windows developer docs (#4662)
When I started building on Windows, I noticed some issues in the
documentation. This fixes most of them.
2026-04-03 15:41:44 +03:00
Daniela Silva
3ecde15621 Add Windows quick start guide for new contributors (#4466)
This pull request adds a beginner-friendly quick start guide for
building Anki on Windows.

The guide is intended to help first-time contributors set up their
development environment more easily, without replacing or modifying the
existing official documentation.

No existing files were changed; this contribution only adds a
complementary Markdown document.

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
2026-04-02 20:44:34 +03:00
Abdo
3628ef66cf Merge branch 'main' into briefcase 2026-04-01 20:34:09 +03:00
Oli
f8669fc4be Add punctuation, convert raw URLs to markdown links in READMEs (#4570) 2026-04-01 10:23:23 -03:00
Andrew Sanchez
6b61393d87 Build and publish dev docs (#4579) 2026-03-31 08:26:59 -04:00
Abdo
f44ab04bfa Update installer docs (#4645)
Add a small section about the Briefcase/PyInstaller installer to
docs/development.md.
2026-03-30 16:47:42 +03:00
user1823
b40c3c8e6b Docs/Add more required packages to Linux build guide (#4432)
* Docs/Add more required packages to Linux build guide

Updated package installation instructions for Debian/Ubuntu to include gcc-12 and libxkbfile1.

* Add Arch Linux requirements
2026-02-11 16:57:11 +07:00
GithubAnon0000
a203b0b3e5 UPDATE(docs): Add build dependencies and instructions for building / running the launcher (#4380)
* ADD Dependencies for linux when building the launcher

I only downloaded `gcc-aarch64-linux-gnu` (on my x86_64 debian sid) and it was able to successfully build the launcher.

* ADD example build / run instructions for the launcher for linux

* CHORE: ninja format && fix

* ADD: Entries for Mac and Windows

* FIX: Wrong level was applied to a header

* CHORE: ninja fix && format

* FIX: Sentence structure

* FIX: casing (thanks dae)

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* FIX: casing

* FIX: binary statement (only linux has amd64 and arm64 versions)

* UPDATE: Include env vars for Win and Mac

* CHANGE: include env vars for Win and Mac in the table instead
2026-02-11 15:14:55 +07:00
Abdo
d3ca0cd0b3 Update PyCharm docs (#4389)
* Add .idea.dist

* Update PyCharm docs
2025-10-27 19:27:50 +07:00
Emil Hamrin
7e8a1076c1 Updated Dockerfile to use Ninja build system (#4321)
* Updated Dockerfile to support ninja build

* Install python using uv

* Bumped python version

* Add disclaimer (dae)
2025-09-17 14:02:09 +10:00
Abdo
f94d05bcbe Switch to Ruff (#4119)
* Add check:ruff build action

* Add fix:ruff action

* Add Ruff config

Mostly generated by Cursor

* Handle rest of lints

* Fix formatting

* Replace black and isort with ruff-format

* Run ruff-format

* Fix lint errors

* Remove pylint disables

* Remove .pylintrc

* Update docs

* Fix check:format not just checking

* Fix isort rule being ignored

* Sort imports

* Ensure ./ninja format also handles import sorting

* Remove unused isort cfg

* Enable unsafe fixes in fix:ruff, and enable unused var warning

* Re-run on config change; enable unnecessary ARG ignores

* Use all pycodestyle errors, and add some more commented-out ones

Latter logged on https://github.com/ankitects/anki/issues/4135
2025-06-29 14:38:35 +07:00
Damien Elmes
8e20973c52 Drop remaining qt5 code 2025-06-20 16:13:50 +07:00
Damien Elmes
04996c77f3 Migrate build system to uv (#4074)
* Migrate build system to uv

Closes #3787, and is a step towards #3081 and #4022

This change breaks our PyOxidizer bundling process. While we probably
could update it to work with the new venvs & lockfile, my intention
is to use this as a base to try out a uv-based packager/installer.

Some notes about the changes:

- Use uv for python download + venv installation
- Drop python/requirements* in favour of pyproject files / uv.lock
- Bumped to latest Python 3.9 version. The move to 3.13 should be
a fairly trivial change when we're ready.
- Dropped the old write_wheel.py in favour of uv/hatchling. This has
the unfortunate side-effect of dropping leading zeros in our wheels,
which we could try hack around in the future.
- Switch to Qt 6.7 for the dev repo, as it's the first PyQt version
with a Linux/ARM WebEngine wheel.
- Unified our macOS deployment target with minimum required for ARM.
- Dropped unused fluent python files
- Dropped unused python license generation
- Dropped helpers to run under Qt 5, as our wheels were already
requiring Qt 6 to install.

* Build action to create universal uv binary

* Drop some PyOxidizer-related files

* Use Windows ARM64 cargo/node binaries during build

We can't provide ARM64 wheels to users yet due to #4079, but we can
at least speed up the build.

The rustls -> native-tls change on Windows is because ring requires
clang to compile for ARM64, and I figured it's best to keep our Windows
deps consistent. We already built the wheels with native-tls.

* Make libankihelper a universal library

We were shipping a single arch library in a purelib, leading to
breakages when running on a different platform.

* Use Python wheel for mpv/lame on Windows/Mac

This is convenient, but suboptimal on a Mac at the moment. The first
run of mpv will take a number of seconds for security checks to run,
and our mpv code ends up timing out, repeating the process each time.
Our installer stub will need to invoke mpv once first to get it validated.

We could address this by distributing the audio with the installer/stub,
or perhaps by putting the binaries in a .pkg file that's notarized+stapled
and then included in the wheel.

* Add some helper scripts to build a fully-locked wheel

* Initial macOS launcher prototype

* Add a hidden env var to preload our libs and audio helpers on macOS

* qt/bundle -> qt/launcher

- remove more of the old bundling code
- handle app icon

* Fat binary, notarization & dmg

* Publish wheels on testpypi for testing

* Use our Python pin for the launcher too

* Python cleanups

* Extend launcher to other platforms + more

- Switch to Qt 6.8 for repo default, as 6.7 depends on an older
libwebp/tiff which is unavailable on newer installs
- Drop tools/mac-x86, as we no longer need to test against Qt 5
- Add flags to cross compile wheels on Mac and Linux
- Bump glibc target to 2_36, building on Debian Stable
- Increase mpv timeout on macOS to allow for initial gatekeeper checks
- Ship both arm64 and amd64 uv on Linux, with a bash stub to pick
the appropriate arch.

* Fix pylint on Linux

* Fix failure to run from /usr/local/bin

* Remove remaining pyoxidizer refs, and clean up duplicate release folder

* Rust dep updates

- Rust 1.87 for now (1.88 due out in around a week)
- Nom looks involved, so I left it for now
- prost-reflect depends on a new prost version that got yanked

* Python 3.13 + dep updates

Updated protoc binaries + add helper in order to try fix build breakage.
Ended up being due to an AI-generated update to pip-system-certs that
was not reviewed carefully enough:
https://gitlab.com/alelec/pip-system-certs/-/issues/36

The updated mypy/black needed some tweaks to our files.

* Windows compilation fixes

* Automatically run Anki after installing on Windows

* Touch pyproject.toml upon install, so we check for updates

* Update Python deps

- urllib3 for CVE
- pip-system-certs got fixed
- markdown/pytest also updated
2025-06-19 14:03:16 +07:00
Kolby Moroz Liebl
6427ff3db5 Fix dockerimage, by bumping rust version (#3993) 2025-05-15 16:09:27 +10:00
Divyansh Kushwaha
6a07c6e561 docs: correct reference for linux dockerfile (#3982) 2025-05-05 18:57:08 +10:00
Arthur Milchior
ab75e3d49b Introduce language_bridge.md (#3572)
This commit explains how to calls a method implemented in a language
from a different language.

This explains how to declare the RPCs, how to call them and how to
implement them. This is based on examples of code at main at the time
of writting. I used permalink to ensure that the links remains
relevant even if the specific examples change later.

The last section is about the special case of calling TypeScript from
Python, which does not use RPC but is still relevant in a bridge
document.

This commit also add a paragraph explaining what protobuf is in the
protobuf documentation, so that new contributors who don't know what
protobuf is can understand why we use it.
2025-04-10 15:30:18 +10:00
llama
d809ee92db Fix cargo ignoring lockfile when building syncserver image (#3856)
* pass --locked to cargo invocation

* update Dockerfile.distroless as well

Co-authored-by: Simon <8466614+SimonBaars@users.noreply.github.com>

---------

Co-authored-by: Simon <8466614+SimonBaars@users.noreply.github.com>
2025-03-14 17:04:56 +07:00
Omar Kohl
eaec53bfc4 Ignore SYNC_PORT and SYNC_BASE in syncserver Dockerfile (#3716)
Hardcode them to:

    SYNC_PORT=8080
    SYNC_BASE=/anki_data

If these env variables are passed into the container with different values,
they are ignored.

The reasons is if the user modifies SYNC_BASE they risk data loss since
anki-sync-server will no longer write data into the volume. If they change
SYNC_PORT they need to also change it when mapping this internal port to the
external port of the container, which could be confusing plus it has no benefit
to allow this since it's always possible to change the external port even if
the internal port is fixed to 8080 (e.g. `-p 1234:8080`).

In both cases there is no benefit to making these values configurable and there
are risks associated.

Unfortunately there is no easy way of implementing this for the
Dockerfile.distroless so it's up to the user not to modify these values.
2025-01-25 19:28:55 +11:00
Omar Kohl
71e2a6f782 Introduce PUID and PGID env variables to syncserver Dockerfile (#3714)
PUID and PGID are optional env variables to specify the user and group id of
the user that the anki-sync-server process should run with.

This gives more flexibility for solving permission problems with volumes and is
a common pattern for Docker images (e.g. see here:
https://docs.linuxserver.io/general/understanding-puid-and-pgid/)

The anki-sync-server process will write any files with the permissions of the
user it's running with, which can be a problem when you need to access those
files from outside the container or when they are being written into a bind
mount that is owned by a particular user on the host system.

To be able to implement this the entrypoint.sh needs to run as root (since it
needs to create a user and change file permissions). anki-sync-server then
needs to be started with the user 'anki', which is why the new dependency
'su-exec' is required. The user 'anki' and group 'anki-group' can no longer be
created at image build time because then their ids would be fixed.

Also update the build instructions to require building the Docker image inside
the directory where the Dockerfile resides since the build now needs to copy
the entrypoint.sh and it seems wrong the specify the path
docs/syncserver/entrypoint.sh inside the Dockerfile.
2025-01-25 18:19:38 +11:00
Damien Elmes
9a5c21739c Remove stale comment 2025-01-13 15:56:33 +11:00
Damien Elmes
2a85c6a2c0 glibc notes apply to AMD64 too 2025-01-12 15:07:12 +11:00
Damien Elmes
6966da14c2 Start installing PyQt6 into the Linux ARM64 venv by default
Now that an ARM wheel is on PyPI, we no longer need to rely on a
system PyQt to build on ARM. The install is skipped when PYTHONPATH
is set, so older distros with glibc <2.39 can continue to use the
system packages instead.
2025-01-10 22:26:30 +11:00
Damien Elmes
256822bbb1 Improve error when n2/ninja missing 2025-01-10 22:26:30 +11:00
Omar Kohl
b189820218 Ensure data is stored in a volume in anki-sync-server Docker image (#3674)
Otherwise data would be lost by default when removing (or re-creating) a
container.

It would be possible to expose the default directory (e.g.
/home/anki/.syncserver) but it would be different for the two Dockerfiles and
less convenient for users of the Docker container to specify such a long path
when naming their volumes.

Setting the permissions is necessary since anki will be running with 'anki'
user permissions inside the container.
2025-01-10 21:42:55 +11:00
Damien Elmes
5d150c74a4 Qt 6.8.1 (#3633)
* Qt 6.8.1

Bumps minimum glibc to 2.35, and minimum macOS to 12

* Drop generation of Qt5 packaged build

Closes #3615

* Include qt6 requirements in aqt wheel; drop extra deps

* Fix aqt wheels growing over time
2025-01-09 20:07:12 +11:00
Omar Kohl
6f2c959dc3 replace localhost with 127.0.0.1 in syncserver Dockerfile (#3673)
* Add myself to CONTRIBUTORS file

* replace localhost with 127.0.0.1 in syncserver Dockerfile

The healthcheck was failing, presumably because localhost was resolving to ::1
(IPv6), as detailed in this issue: https://github.com/maildev/maildev/pull/500
2025-01-05 01:24:29 +03:00
Niclas Heinz
936e10bd76 update docker deps and docker docs (#3671)
* docs(docker): Change suggested version numbre

* deps(docker): Bump rust to 1.83.0 and alpine to 3.21.0

* deps(docker): Bump rust to 1.83.0

* CONTRIBUTORS: Add my name
2025-01-04 17:58:54 +03:00
Omar Kohl
7f12814bbe avoid warning by setting SYNC_PORT as ARG in Dockerfile (#3675)
* Add myself to CONTRIBUTORS file

* avoid warning by setting SYNC_PORT as ARG in Dockerfile

    1 warning found (use docker --debug to expand):
    - UndefinedVar: Usage of undefined variable '$SYNC_PORT'
2025-01-04 17:51:43 +03:00
Jean Khawand
15fde04264 Bump rust base image 1.80.1 to 1.82.0 (#3587) 2024-11-18 23:42:24 +10:00
Jean Khawand
83fe301c1c Add distroless Dockerfile and implement internal health check (#3366)
- rslib(http_server): add `is_running()` method
- rslib(sync): introduce `--healthcheck` argument for health probe in distroless
- doc(syncserver): add table comparing Dockerfile and Dockerfile.distroless
- Expand cross-platform support with distroless
- add `Dockerfile.distroless`

- Dockerfile: bump rust `1.79` to `1.80.1`
- Dockerfile: bump alpine `3.20` to `3.20.2`

Note: Implemented an internal health check because distroless images do not include curl, which is used to reduce image size and attack surface. For more details, see https://blog.sixeyed.com/docker-healthchecks-why-not-to-use-curl-or-iwr/
https://github.com/GoogleContainerTools/distroless

fix: failed: check:format:rust

typo

remove extra space

fix failed:check:format:rust

update doc

fetch `host` and `port` using envy

fix: failed: check:format:rust

Update doc + add dockerignore

- dockerignore: This helps avoid sending unwanted files and directories to the builder
- add new line
- I am still experimenting cross platform compilation, I am getting
4.337 From https://github.com/ankitects/rust-url
4.337  * [new ref]         bb930b8d089f4d30d7d19c12e54e66191de47b88 -> refs/commit/bb930b8d089f4d30d7d19c12e54e66191de47b88
4.397 error: failed to get `percent-encoding-iri` as a dependency of package `anki v0.0.0 (/app/rslib)`

still checking what could be the issue

fix: failed: check:format:dprint
2024-08-29 17:05:33 +07:00
Damien Elmes
5f80ddf27d Remove outdated comments in contributing, and mention refactoring 2024-08-10 18:43:11 +07:00
Jean Khawand
56a085bc21 Update base images and introduce health endpoint (#3273)
* Update base images and introduce health endpoint

sync-server: introduce `/health` endpoint to check if the service is reachable.

bump(alpine): bump alpine base image from `3.19` to `3.20`

bump(rust): bump rust-alpine build image from `1.76` to `1.79`

* fix cargo fmt

* add allow clippy::extra_unused_type_parameters

* Remove unused type param (dae)

* Route /health directly (dae)

* Fix for latest axum (dae)
2024-07-10 20:35:21 +07:00
Damien Elmes
690866b090 Update instructions for Debian 12 2024-04-04 16:34:57 +07:00
Damien Elmes
022a95db25 Mention missing libraries 2024-04-03 14:41:28 +07:00
antecrescent
58ce29f461 Refactor offline build process and add offline generation of Sphinx docs (#3082)
* Simplify the offline build

The two environment variables OFFLINE_BUILD and NO_VENV jointly provide
the ability to build Anki fully offline. This commit boils them down
into just one, namely OFFLINE_BUILD.

The rationale being that first, OFFLINE_BUILD implies the use of
a custom non-networked Python environment.
Second, building Anki with a custom Python environment in a networked
setting is a use case, that we currently do not support.
Developers in need of such a solution may want to give containerized
development environments a try. Users could also look into building
Anki fully offline instead.

* Add documentation for offline builds.

* Add support for offline generation of Sphinx documentation.

Control installation of Sphinx dependencies via the network through the
OFFLINE_BUILD environment variable.

* Add documentation for offline generation of Sphinx documentation.
2024-03-27 13:51:09 +00:00
Jean Khawand
a694889bca 🐬Containerize anki-sync-server (#3036)
* 🐬Containerize anki-sync-server

* rename directory to syncserver

* update contributors

* fix format

* format README

* - make ANKI_VERSION mandatory
- remove SYNC_USERS and stick unique vars
- update doc

* update doc

* update doc

* - remove hardcoded ANKI_VERSION arg
- update readme
2024-03-01 15:15:02 +07:00
Damien Elmes
8f77e5198b Add make to build reqs; update ARM docs 2023-12-30 09:45:39 +10:00
antecrescent
ecd4c3f172 Mention YARN_BINARY in documentation (#2851) 2023-11-27 11:50:23 +10:00