Compare commits
7 Commits
v4.2.1
...
worktree-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1630d044aa | ||
|
|
c2a0a731d7 | ||
|
|
89de839fd8 | ||
|
|
49566292ba | ||
|
|
9f0e0afeb6 | ||
|
|
398a359778 | ||
|
|
86aa5cbddf |
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -37,6 +37,7 @@ jobs:
|
||||
publish:
|
||||
needs: test # Only run if tests pass
|
||||
runs-on: ubuntu-latest
|
||||
environment: pypi
|
||||
|
||||
# Required for PyPI trusted publishing (recommended)
|
||||
permissions:
|
||||
|
||||
64
INSTALL.md
64
INSTALL.md
@@ -20,22 +20,23 @@ Complete installation instructions for all platforms and deployment methods.
|
||||
|
||||
## Requirements
|
||||
|
||||
### ⚠️ Python Version Requirements
|
||||
### Python Version Requirements
|
||||
|
||||
| Python Version | Status | Notes |
|
||||
|----------------|--------|-------|
|
||||
| 3.10 | ✅ Supported | |
|
||||
| 3.11 | ✅ Supported | Recommended |
|
||||
| 3.10 | ❌ Not Supported | Dropped in v4.2.1 |
|
||||
| 3.11 | ✅ Supported | Minimum version |
|
||||
| 3.12 | ✅ Supported | Recommended |
|
||||
| 3.13 | ❌ **Not Supported** | jpegio C extension incompatible |
|
||||
| 3.13 | ✅ Supported | |
|
||||
| 3.14 | ✅ Supported | Tested on Arch |
|
||||
|
||||
**Important:** Python 3.13 (released October 2024) is **not compatible** with jpegio due to C extension ABI changes. Use Python 3.12 or earlier.
|
||||
**Note:** v4.2.1 switched from `jpegio` to `jpeglib` for DCT steganography, enabling Python 3.11-3.14 support.
|
||||
|
||||
### Minimum Requirements
|
||||
|
||||
| Requirement | Value |
|
||||
|-------------|-------|
|
||||
| Python | 3.10-3.12 |
|
||||
| Python | 3.11-3.14 |
|
||||
| RAM | 512 MB minimum (256MB for Argon2) |
|
||||
| Disk | ~100 MB |
|
||||
|
||||
@@ -423,16 +424,61 @@ pip install jpegio
|
||||
|
||||
### Windows
|
||||
|
||||
1. Install Python 3.12 from [python.org](https://python.org) (NOT 3.13!)
|
||||
2. Install Visual Studio Build Tools
|
||||
Windows users have three options, listed from easiest to most complex:
|
||||
|
||||
#### Option 1: Docker Desktop (Recommended)
|
||||
|
||||
The easiest way to run Stegasoo on Windows. No Python installation needed.
|
||||
|
||||
1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
||||
2. Enable WSL2 backend when prompted
|
||||
3. Clone and run:
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/adlee-was-taken/stegasoo.git
|
||||
cd stegasoo
|
||||
docker-compose -f docker/docker-compose.yml up -d web
|
||||
```
|
||||
|
||||
Access at http://localhost:5000
|
||||
|
||||
#### Option 2: WSL2 (Windows Subsystem for Linux)
|
||||
|
||||
Run the Linux version natively on Windows.
|
||||
|
||||
```powershell
|
||||
# Install WSL2 with Ubuntu
|
||||
wsl --install -d Ubuntu
|
||||
|
||||
# Open Ubuntu terminal, then follow Linux instructions:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.12 python3.12-venv libzbar0 libjpeg-dev
|
||||
git clone https://github.com/adlee-was-taken/stegasoo.git
|
||||
cd stegasoo
|
||||
python3.12 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -e ".[all]"
|
||||
stegasoo --version
|
||||
```
|
||||
|
||||
#### Option 3: Native Windows (Advanced)
|
||||
|
||||
Native Windows installation requires Visual Studio Build Tools for compiling C extensions.
|
||||
|
||||
1. Install Python 3.11 or 3.12 from [python.org](https://python.org)
|
||||
2. Install [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) with "Desktop development with C++"
|
||||
3. Install from pip:
|
||||
|
||||
```powershell
|
||||
python -m venv venv
|
||||
.\venv\Scripts\activate
|
||||
pip install stegasoo[all]
|
||||
pip install stegasoo[cli] # CLI only (easiest)
|
||||
# or
|
||||
pip install stegasoo[all] # Full install (may require additional setup)
|
||||
```
|
||||
|
||||
**Note:** Native Windows installation may have issues with `jpegio` (DCT mode). Docker or WSL2 is recommended for full functionality.
|
||||
|
||||
### Raspberry Pi
|
||||
|
||||
Stegasoo works on Raspberry Pi 4/5 (4GB+ RAM recommended for Web UI).
|
||||
|
||||
@@ -4,7 +4,7 @@ A secure steganography system for hiding encrypted messages in images using hybr
|
||||
|
||||
[](https://github.com/adlee-was-taken/stegasoo/actions/workflows/test.yml)
|
||||
[](https://github.com/adlee-was-taken/stegasoo/actions/workflows/lint.yml)
|
||||

|
||||

|
||||
[](LICENSE)
|
||||

|
||||
|
||||
|
||||
102
aur-api/README.md
Normal file
102
aur-api/README.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# Stegasoo API AUR Package
|
||||
|
||||
REST API server package for programmatic steganography operations. Includes HTTPS support and API key authentication.
|
||||
|
||||
## Installation
|
||||
|
||||
### From AUR (once published)
|
||||
```bash
|
||||
yay -S stegasoo-api-git
|
||||
# or
|
||||
paru -S stegasoo-api-git
|
||||
```
|
||||
|
||||
### Manual build
|
||||
```bash
|
||||
git clone https://aur.archlinux.org/stegasoo-api-git.git
|
||||
cd stegasoo-api-git
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
## What Gets Installed
|
||||
|
||||
- `/opt/stegasoo-api/venv/` - Self-contained Python venv with API dependencies
|
||||
- `/opt/stegasoo-api/config/` - API key storage
|
||||
- `/opt/stegasoo-api/certs/` - TLS certificates
|
||||
- `/usr/bin/stegasoo` - CLI executable
|
||||
- `/usr/lib/systemd/system/stegasoo-api.service` - Systemd service
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# 1. Create an API key
|
||||
sudo -u stegasoo stegasoo api keys create mykey
|
||||
|
||||
# 2. Start the service
|
||||
sudo systemctl enable --now stegasoo-api
|
||||
|
||||
# 3. Test the API
|
||||
curl -k -H "X-API-Key: YOUR_KEY" https://localhost:8000/
|
||||
```
|
||||
|
||||
## Service Details
|
||||
|
||||
| Setting | Value |
|
||||
|---------|-------|
|
||||
| Port | 8000 |
|
||||
| Protocol | HTTPS (self-signed cert auto-generated) |
|
||||
| API Docs | https://localhost:8000/docs |
|
||||
| OpenAPI | https://localhost:8000/openapi.json |
|
||||
|
||||
## API Key Management
|
||||
|
||||
```bash
|
||||
# List all keys
|
||||
stegasoo api keys list
|
||||
|
||||
# Create a new key
|
||||
sudo -u stegasoo stegasoo api keys create <name>
|
||||
|
||||
# Revoke a key
|
||||
sudo -u stegasoo stegasoo api keys revoke <name>
|
||||
```
|
||||
|
||||
## TLS Configuration
|
||||
|
||||
```bash
|
||||
# View current certificate info
|
||||
stegasoo api tls info
|
||||
|
||||
# Generate new self-signed certificate
|
||||
sudo -u stegasoo stegasoo api tls generate
|
||||
|
||||
# Use custom certificates (edit service)
|
||||
sudo systemctl edit stegasoo-api
|
||||
# Add:
|
||||
# [Service]
|
||||
# ExecStart=
|
||||
# ExecStart=/opt/stegasoo-api/venv/bin/stegasoo api serve \
|
||||
# --host 0.0.0.0 --port 8000 \
|
||||
# --cert /path/to/cert.pem --key /path/to/key.pem
|
||||
```
|
||||
|
||||
## Manual Run (without systemd)
|
||||
|
||||
```bash
|
||||
# Development mode (auto-reload)
|
||||
/opt/stegasoo-api/venv/bin/stegasoo api serve --reload
|
||||
|
||||
# Production mode
|
||||
/opt/stegasoo-api/venv/bin/stegasoo api serve --host 0.0.0.0 --port 8000
|
||||
```
|
||||
|
||||
## For Web UI
|
||||
|
||||
Install the full package instead:
|
||||
```bash
|
||||
yay -S stegasoo-git
|
||||
```
|
||||
|
||||
## Maintainer
|
||||
|
||||
Aaron D. Lee
|
||||
@@ -10,25 +10,40 @@ post_install() {
|
||||
chown -R stegasoo:stegasoo /opt/stegasoo-api/certs 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "Stegasoo API installed successfully!"
|
||||
echo "==============================================="
|
||||
echo " Stegasoo API installed successfully!"
|
||||
echo "==============================================="
|
||||
echo ""
|
||||
echo "Quick Start:"
|
||||
echo "-----------------------------------------------"
|
||||
echo " Quick Start"
|
||||
echo "-----------------------------------------------"
|
||||
echo " 1. Create an API key:"
|
||||
echo " stegasoo api keys create mykey"
|
||||
echo " sudo -u stegasoo stegasoo api keys create mykey"
|
||||
echo ""
|
||||
echo " 2. Start the API server:"
|
||||
echo " sudo systemctl start stegasoo-api"
|
||||
echo " sudo systemctl enable stegasoo-api # auto-start"
|
||||
echo ""
|
||||
echo " 3. Access the API:"
|
||||
echo " curl -k -H 'X-API-Key: YOUR_KEY' https://localhost:8000/"
|
||||
echo ""
|
||||
echo "Management commands:"
|
||||
echo "-----------------------------------------------"
|
||||
echo " Service Details"
|
||||
echo "-----------------------------------------------"
|
||||
echo " Port: 8000 (HTTPS by default)"
|
||||
echo " Docs: https://localhost:8000/docs"
|
||||
echo " Status: sudo systemctl status stegasoo-api"
|
||||
echo ""
|
||||
echo "-----------------------------------------------"
|
||||
echo " Management Commands"
|
||||
echo "-----------------------------------------------"
|
||||
echo " stegasoo api keys list # List API keys"
|
||||
echo " stegasoo api keys create X # Create new key"
|
||||
echo " stegasoo api tls generate # Generate TLS certs"
|
||||
echo " stegasoo api tls info # Show certificate info"
|
||||
echo " stegasoo api serve --help # Server options"
|
||||
echo ""
|
||||
echo "API docs available at: https://localhost:8000/docs"
|
||||
echo "==============================================="
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
||||
62
aur-cli/README.md
Normal file
62
aur-cli/README.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Stegasoo CLI AUR Package
|
||||
|
||||
Lightweight CLI-only package for steganography operations. No web UI or API server.
|
||||
|
||||
## Installation
|
||||
|
||||
### From AUR (once published)
|
||||
```bash
|
||||
yay -S stegasoo-cli-git
|
||||
# or
|
||||
paru -S stegasoo-cli-git
|
||||
```
|
||||
|
||||
### Manual build
|
||||
```bash
|
||||
git clone https://aur.archlinux.org/stegasoo-cli-git.git
|
||||
cd stegasoo-cli-git
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
## What Gets Installed
|
||||
|
||||
- `/opt/stegasoo-cli/venv/` - Self-contained Python venv with CLI dependencies only
|
||||
- `/usr/bin/stegasoo` - CLI executable
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Show all commands
|
||||
stegasoo --help
|
||||
|
||||
# Generate credentials (passphrase + PIN)
|
||||
stegasoo generate
|
||||
stegasoo generate --words 5 --pin-length 8
|
||||
|
||||
# Generate with RSA keys and QR codes
|
||||
stegasoo generate --rsa --qr-ascii
|
||||
|
||||
# Encode a message
|
||||
stegasoo encode -i carrier.jpg -r reference.jpg -m "secret message" \
|
||||
-P "word1 word2 word3 word4" -p 123456
|
||||
|
||||
# Decode a message
|
||||
stegasoo decode -i encoded.png -r reference.jpg \
|
||||
-P "word1 word2 word3 word4" -p 123456
|
||||
|
||||
# Image tools
|
||||
stegasoo tools --help
|
||||
stegasoo tools compress image.png
|
||||
stegasoo tools rotate image.jpg 90
|
||||
```
|
||||
|
||||
## For Web UI or REST API
|
||||
|
||||
Install the full package instead:
|
||||
```bash
|
||||
yay -S stegasoo-git
|
||||
```
|
||||
|
||||
## Maintainer
|
||||
|
||||
Aaron D. Lee
|
||||
@@ -1,12 +1,15 @@
|
||||
post_install() {
|
||||
echo ""
|
||||
echo "Stegasoo CLI installed successfully!"
|
||||
echo "==============================================="
|
||||
echo " Stegasoo CLI installed successfully!"
|
||||
echo "==============================================="
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " stegasoo --help # Show all commands"
|
||||
echo " stegasoo generate # Generate passphrase + PIN"
|
||||
echo " stegasoo encode ... # Hide data in an image"
|
||||
echo " stegasoo decode ... # Extract hidden data"
|
||||
echo " stegasoo tools --help # Image tools (compress, rotate, etc.)"
|
||||
echo " stegasoo tools --help # Image tools (compress, etc.)"
|
||||
echo ""
|
||||
echo "For web UI or REST API, install stegasoo-git instead."
|
||||
echo ""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Stegasoo AUR Package
|
||||
|
||||
> **Note:** Uses Python 3.12 via `python312` AUR package (jpegio not yet compatible with 3.13)
|
||||
Full package with CLI, Web UI, and REST API. Supports Python 3.11-3.14.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -20,15 +20,15 @@ makepkg -si
|
||||
|
||||
## What Gets Installed
|
||||
|
||||
- `/opt/stegasoo/venv/` - Self-contained Python 3.12 venv with all dependencies
|
||||
- `/opt/stegasoo/venv/` - Self-contained Python venv with all dependencies
|
||||
- `/usr/bin/stegasoo` - CLI symlink
|
||||
- `/usr/lib/systemd/system/stegasoo-web.service` - Web UI service
|
||||
- `/usr/lib/systemd/system/stegasoo-api.service` - REST API service
|
||||
- `/usr/lib/systemd/system/stegasoo-web.service` - Web UI service (port 5000)
|
||||
- `/usr/lib/systemd/system/stegasoo-api.service` - REST API service (port 8000, HTTPS)
|
||||
|
||||
## Optional Dependencies
|
||||
|
||||
```bash
|
||||
# QR code reading from webcam/images
|
||||
# QR code reading from webcam/images (recommended)
|
||||
sudo pacman -S zbar
|
||||
```
|
||||
|
||||
@@ -39,41 +39,52 @@ All other dependencies are bundled in the venv.
|
||||
### CLI
|
||||
```bash
|
||||
stegasoo --help
|
||||
stegasoo generate --rsa --qr-ascii
|
||||
stegasoo encode -i carrier.jpg -r reference.jpg -m "secret" -P passphrase -p 123456
|
||||
stegasoo generate # Generate passphrase + PIN
|
||||
stegasoo generate --rsa --qr-ascii # With RSA keys and QR codes
|
||||
stegasoo encode -i carrier.jpg -r reference.jpg -m "secret" -P "word1 word2 word3 word4" -p 123456
|
||||
stegasoo decode -i encoded.png -r reference.jpg -P "word1 word2 word3 word4" -p 123456
|
||||
```
|
||||
|
||||
### Web UI (systemd)
|
||||
### Web UI
|
||||
```bash
|
||||
# Create service user (first time)
|
||||
sudo useradd -r -s /usr/bin/nologin stegasoo
|
||||
|
||||
# Start service
|
||||
# Start service (user created automatically on install)
|
||||
sudo systemctl enable --now stegasoo-web
|
||||
|
||||
# Access at http://localhost:5000
|
||||
```
|
||||
|
||||
### REST API (systemd)
|
||||
### REST API
|
||||
```bash
|
||||
# Start service
|
||||
# Create an API key first
|
||||
sudo -u stegasoo stegasoo api keys create mykey
|
||||
|
||||
# Start service (HTTPS with auto-generated self-signed cert)
|
||||
sudo systemctl enable --now stegasoo-api
|
||||
|
||||
# Access at http://localhost:8000/docs
|
||||
# Access docs at https://localhost:8000/docs
|
||||
curl -k -H "X-API-Key: YOUR_KEY" https://localhost:8000/
|
||||
```
|
||||
|
||||
### Manual run (without systemd)
|
||||
### HTTPS Configuration
|
||||
|
||||
The API uses HTTPS by default with auto-generated self-signed certificates.
|
||||
|
||||
```bash
|
||||
# Web UI
|
||||
/opt/stegasoo/venv/bin/python -m gunicorn -b 0.0.0.0:5000 \
|
||||
--chdir /opt/stegasoo/venv/lib/python3.12/site-packages/frontends/web app:app
|
||||
# View certificate info
|
||||
stegasoo api tls info
|
||||
|
||||
# REST API
|
||||
/opt/stegasoo/venv/bin/uvicorn \
|
||||
--app-dir /opt/stegasoo/venv/lib/python3.12/site-packages/frontends/api \
|
||||
main:app --host 0.0.0.0 --port 8000
|
||||
# Generate new self-signed cert
|
||||
sudo -u stegasoo stegasoo api tls generate
|
||||
|
||||
# Use custom certs (edit service file)
|
||||
sudo systemctl edit stegasoo-api
|
||||
```
|
||||
|
||||
## Alternative Packages
|
||||
|
||||
- `stegasoo-cli-git` - CLI only, minimal dependencies
|
||||
- `stegasoo-api-git` - CLI + REST API, no web UI
|
||||
|
||||
## Maintainer
|
||||
|
||||
Aaron D. Lee
|
||||
|
||||
@@ -9,16 +9,51 @@ post_install() {
|
||||
chown -R stegasoo:stegasoo /opt/stegasoo/venv/var/app-instance 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "Stegasoo installed successfully!"
|
||||
echo "==============================================="
|
||||
echo " Stegasoo installed successfully!"
|
||||
echo "==============================================="
|
||||
echo ""
|
||||
echo "CLI usage:"
|
||||
echo " stegasoo --help"
|
||||
echo " stegasoo generate # Generate credentials"
|
||||
echo " stegasoo encode # Encode a message"
|
||||
echo " stegasoo decode # Decode a message"
|
||||
echo ""
|
||||
echo "To start the web UI:"
|
||||
echo " sudo systemctl start stegasoo-web"
|
||||
echo "-----------------------------------------------"
|
||||
echo " Web UI Service"
|
||||
echo "-----------------------------------------------"
|
||||
echo " Port: 5000 (HTTP)"
|
||||
echo " Start: sudo systemctl start stegasoo-web"
|
||||
echo " Enable: sudo systemctl enable stegasoo-web"
|
||||
echo " Status: sudo systemctl status stegasoo-web"
|
||||
echo " Access: http://localhost:5000"
|
||||
echo ""
|
||||
echo "To start the REST API:"
|
||||
echo " sudo systemctl start stegasoo-api"
|
||||
echo "-----------------------------------------------"
|
||||
echo " REST API Service"
|
||||
echo "-----------------------------------------------"
|
||||
echo " Port: 8000 (HTTPS by default)"
|
||||
echo " Start: sudo systemctl start stegasoo-api"
|
||||
echo " Enable: sudo systemctl enable stegasoo-api"
|
||||
echo " Status: sudo systemctl status stegasoo-api"
|
||||
echo " Access: https://localhost:8000"
|
||||
echo ""
|
||||
echo "-----------------------------------------------"
|
||||
echo " HTTPS Configuration"
|
||||
echo "-----------------------------------------------"
|
||||
echo " The API generates self-signed certs on first run."
|
||||
echo " To pre-generate or use custom certificates:"
|
||||
echo ""
|
||||
echo " # Generate self-signed certs"
|
||||
echo " sudo -u stegasoo stegasoo api tls generate"
|
||||
echo ""
|
||||
echo " # Use custom certs (edit the service file)"
|
||||
echo " sudo systemctl edit stegasoo-api"
|
||||
echo " # Add: ExecStart= with --cert and --key flags"
|
||||
echo ""
|
||||
echo " # Create API keys for authentication"
|
||||
echo " sudo -u stegasoo stegasoo api keys create <name>"
|
||||
echo ""
|
||||
echo "==============================================="
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 62 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 60 KiB |
@@ -16,11 +16,11 @@
|
||||
<img src="{{ url_for('static', filename='logo.svg') }}" alt="Stegasoo" height="28">
|
||||
</a>
|
||||
{% if channel_configured %}
|
||||
<span class="badge bg-success bg-opacity-25 small" style="padding-left: 0.35rem;" title="Private Channel: {{ channel_fingerprint }}">
|
||||
<span class="badge bg-success bg-opacity-25 small me-auto" style="padding-left: 0.35rem;" title="Private Channel: {{ channel_fingerprint }}">
|
||||
<i class="bi bi-shield-lock me-2" style="color: #6ee7b7;"></i><code style="font-size: 0.7rem; font-weight: 300; color: #c9a860;">{{ channel_fingerprint[:4] }}-••••-{{ channel_fingerprint[-4:] }}</code>
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary bg-opacity-25 small text-muted" style="padding-left: 0.35rem;" title="Public Channel: No shared channel key configured. Messages use only passphrase and PIN for encryption.">
|
||||
<span class="badge bg-secondary bg-opacity-25 small text-muted me-auto" style="padding-left: 0.35rem;" title="Public Channel: No shared channel key configured. Messages use only passphrase and PIN for encryption.">
|
||||
<i class="bi bi-globe me-1"></i>Public Channel
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
@@ -114,6 +114,13 @@ include = [
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/stegasoo", "frontends"]
|
||||
|
||||
[tool.hatch.build.targets.wheel.sources]
|
||||
"src" = ""
|
||||
|
||||
# Include data files in the wheel
|
||||
[tool.hatch.build.targets.wheel.force-include]
|
||||
"src/stegasoo/data/bip39-words.txt" = "stegasoo/data/bip39-words.txt"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
python_files = ["test_*.py"]
|
||||
|
||||
@@ -25,6 +25,7 @@ BREAKING CHANGES in v3.2.0:
|
||||
- Renamed day_phrase → passphrase throughout codebase
|
||||
"""
|
||||
|
||||
import importlib.resources
|
||||
from pathlib import Path
|
||||
|
||||
# ============================================================================
|
||||
@@ -177,15 +178,32 @@ BATCH_OUTPUT_SUFFIX = "_encoded"
|
||||
|
||||
|
||||
def get_data_dir() -> Path:
|
||||
"""Get the data directory path."""
|
||||
# Check multiple locations
|
||||
"""Get the data directory path.
|
||||
|
||||
Checks locations in order:
|
||||
1. Package data (installed via pip/wheel) using importlib.resources
|
||||
2. Development layout (src/stegasoo -> project root/data)
|
||||
3. Docker container (/app/data)
|
||||
4. Current working directory fallbacks
|
||||
"""
|
||||
# Try package data first (works when installed via pip)
|
||||
try:
|
||||
pkg_data = importlib.resources.files("stegasoo.data")
|
||||
# Check if the package data directory exists and has our files
|
||||
if (pkg_data / "bip39-words.txt").is_file():
|
||||
# Return as Path - importlib.resources.files returns a Traversable
|
||||
return Path(str(pkg_data))
|
||||
except (ModuleNotFoundError, TypeError):
|
||||
pass
|
||||
|
||||
# Fallback to file-based locations
|
||||
# From src/stegasoo/constants.py:
|
||||
# .parent = src/stegasoo/
|
||||
# .parent.parent = src/
|
||||
# .parent.parent.parent = project root (where data/ lives)
|
||||
candidates = [
|
||||
Path(__file__).parent / "data", # Installed package (stegasoo/data/)
|
||||
Path(__file__).parent.parent.parent / "data", # Development: src/stegasoo -> project root
|
||||
Path(__file__).parent / "data", # Installed package
|
||||
Path("/app/data"), # Docker
|
||||
Path.cwd() / "data", # Current directory
|
||||
Path.cwd().parent / "data", # One level up from cwd
|
||||
@@ -196,8 +214,8 @@ def get_data_dir() -> Path:
|
||||
if path.exists():
|
||||
return path
|
||||
|
||||
# Default to first candidate
|
||||
return candidates[0]
|
||||
# Default to package data path for clearer error messages
|
||||
return Path(__file__).parent / "data"
|
||||
|
||||
|
||||
def get_bip39_words() -> list[str]:
|
||||
|
||||
1
src/stegasoo/data/__init__.py
Normal file
1
src/stegasoo/data/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# Package data directory for stegasoo
|
||||
2048
src/stegasoo/data/bip39-words.txt
Normal file
2048
src/stegasoo/data/bip39-words.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user