Anki Release (Dependency Locker)

25.9.2 · active · verified Sun Apr 12

Anki-release is a Python meta-package designed to lock the dependencies required for the Anki desktop application's Python components, ensuring a consistent and compatible environment for developers building on the Anki backend. It does not provide direct user-facing API but facilitates the installation of the core `anki` and `aqt` libraries along with their many transitive dependencies. It follows Anki's rapid release cadence, with the current version being 25.9.2.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates installing `anki-release` and then provides a minimal example of how to interact with the Anki backend (`anki` package) by opening an Anki collection. This package primarily sets up the environment, and direct programmatic interaction is typically done through the `anki` and `aqt` libraries it depends on.

import os
from anki.collection import Collection
from anki.stdrepl import repl

# NOTE: For anki-release, the primary use case is to ensure backend dependencies.
# The actual Anki backend interaction is via the 'anki' package.

# Create a temporary Anki collection for demonstration
# In a real scenario, you'd likely open an existing collection.
COLLECTION_PATH = os.environ.get('ANKI_TEST_COLLECTION_PATH', 'temp_collection.anki2')

# Ensure the directory exists if not in the current working directory
collection_dir = os.path.dirname(COLLECTION_PATH)
if collection_dir and not os.path.exists(collection_dir):
    os.makedirs(collection_dir)

# Open or create an Anki collection
col = Collection(COLLECTION_PATH)
print(f"Opened Anki collection at: {col.path}")

# Example: Get number of notes (0 for a new collection)
print(f"Number of notes: {col.note_count()}")

# Clean up the temporary collection if created new
# In a real application, you'd manage persistence carefully.
# col.close()
# if not os.environ.get('ANKI_TEST_COLLECTION_PATH'):
#     os.remove(COLLECTION_PATH)

# Anki's internal Python environment might use a custom REPL for debugging
# For general scripting, standard Python interactions apply.
# You might interact with objects like col.models, col.decks, etc.

view raw JSON →