Skip to content

Commit 113b82f

Browse files
committed
Add option to set birdnet app data manually
1 parent 85f788b commit 113b82f

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

docs/setup.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ All BirdNET data (models, benchmarks) is stored in the application-data director
281281
- **macOS:** ``~/Library/Application Support/birdnet``
282282
- **Windows:** ``%APPDATA%/birdnet``
283283

284+
The default location can be overridden by setting the ``BIRDNET_APP_DATA`` environment variable to any absolute path before the ``birdnet`` package is imported.::
285+
286+
# Windows pre-execution script
287+
set BIRDNET_APP_DATA=C:\Program Files\BirdNET-Analyzer\birdnet-data
288+
289+
# Linux / macOS pre-execution script
290+
export BIRDNET_APP_DATA=/opt/birdnet-analyzer/birdnet-data
291+
284292
Why is Python 3.10 not supported?
285293
^^^^
286294

src/birdnet/globals.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@
145145

146146
PKG_NAME = "birdnet"
147147

148+
ENV_VAR_APP_DATA = "BIRDNET_APP_DATA"
149+
148150
# flag for "can be written to" = free
149151
WRITABLE_FLAG = np.uint8(0)
150152

src/birdnet/utils/local_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from birdnet.globals import (
66
ACOUSTIC_MODEL_VERSIONS,
7+
ENV_VAR_APP_DATA,
78
GEO_MODEL_VERSIONS,
89
MODEL_BACKEND_PB,
910
MODEL_BACKEND_TF,
@@ -38,6 +39,9 @@ def get_app_data_path() -> Path:
3839

3940

4041
def get_birdnet_app_data_folder() -> Path:
42+
override = os.getenv(ENV_VAR_APP_DATA)
43+
if override is not None:
44+
return Path(override)
4145
app_data = get_app_data_path()
4246
result = app_data / PKG_NAME
4347
return result

0 commit comments

Comments
 (0)