Files
PDF-Downloaders/Scribd/BUILD.md
T

179 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Building installable apps
You can ship **Scribd PDF Downloader** as a standalone app on Windows and macOS. Each platform must be built **on that OS** (you cannot build a Mac `.app` from Windows).
| Platform | Output | Build machine |
|----------|--------|---------------|
| Windows | `dist/Scribd PDF Downloader/Scribd PDF Downloader.exe` + zip | Windows PC |
| macOS | `dist/Scribd PDF Downloader.app` + zip | MacBook Pro / any Mac |
| Linux | `dist/Scribd PDF Downloader/` + `.tar.gz` | Linux PC |
The app bundles **Python + Chromium** (~200–850 MB). No separate Python install is required on the target machine.
---
## CI builds (Gitea / GitHub Actions)
Automated builds for **Windows, macOS, and Linux** run from the repo root.
| Workflow | Trigger | Output |
|----------|---------|--------|
| **Build Scribd** | Push to `main`, PR, or manual | Artifacts per OS |
| **Release Scribd** | Tag `v*` (e.g. `v1.0.0`) | Gitea Release with all zips |
### Enable on Gitea (git.masengr.com)
1. **Site admin:** enable **Actions** for the instance.
2. **Repo → Settings → Actions:** allow workflows.
3. Register **act runners** with the right labels.
#### Runners (match your other repos)
**Build Scribd** uses your **Linux runner** (`ubuntu-latest`) for two jobs:
| Job | What you get | Notes |
|-----|----------------|-------|
| **Linux** | `Scribd-PDF-Downloader-Linux.tar.gz` | Full standalone app (PyInstaller + Chromium) |
| **Windows portable** | `Scribd-PDF-Downloader-Windows-Portable.zip` | Source + `Install Scribd Downloader.bat` |
### Why not a Windows `.exe` from Linux?
Playwright ships **OS-specific Chromium**. PyInstaller cannot cross-compile this app from Linux to a real Windows `.exe`. That requires either:
- A **Windows machine** / `windows-latest` runner, or
- Local build: `.\build\windows\build.ps1` on your PC
### Windows portable zip (from Linux CI)
1. Download artifact **`scribd-windows-portable`**
2. Extract on a Windows PC
3. Run **`Install Scribd Downloader.bat`** (installs Python deps + Chromium once, then opens GUI)
### Linux CI artifact
```bash
tar -xzf Scribd-PDF-Downloader-Linux.tar.gz
./Scribd\ PDF\ Downloader/Scribd\ PDF\ Downloader
```
4. Open **Actions** → **Build Scribd** on push to `main`.
### Workflows (repo root)
```
.gitea/workflows/build-scribd.yml # Windows + macOS + Linux on push
.gitea/workflows/release-scribd.yml # all platforms on tag v*
.github/workflows/build-scribd.yml # GitHub mirror
```
CI scripts live in `Scribd/build/ci/` (`build-windows.ps1`, `build-unix.sh`).
### Create a release
```bash
git tag v1.0.0
git push origin v1.0.0
```
Optional: add repo secret **`GITEA_TOKEN`** (releases scope) for `release-scribd.yml`.
### Artifact names
| Artifact | File |
|----------|------|
| `scribd-linux` | `Scribd-PDF-Downloader-Linux.tar.gz` |
| `scribd-windows-portable` | `Scribd-PDF-Downloader-Windows-Portable.zip` |
For a full Windows `.exe`, build locally with `.\build\windows\build.ps1`.
> **Note:** Each archive is large (~500–900 MB) because Chromium is bundled. Hosted runners may hit artifact size limits; self-hosted runners avoid that.
---
## Windows (.exe)
1. Open **PowerShell** in the project folder.
2. Run:
```powershell
.\build\windows\build.ps1
```
3. When finished:
- **Folder:** `dist\Scribd PDF Downloader\`
- **Zip:** `dist\Scribd-PDF-Downloader-Windows.zip`
Copy the whole folder (or unzip the archive) to any Windows PC and run **Scribd PDF Downloader.exe**.
---
## macOS (.app)
On your **MacBook Pro** (or any Mac):
```bash
chmod +x build/macos/build.sh
./build/macos/build.sh
```
Outputs:
- **App:** `dist/Scribd PDF Downloader.app`
- **Zip:** `dist/Scribd-PDF-Downloader-macOS.zip`
### First launch on Mac
macOS may block unsigned apps:
1. Right-click the app → **Open** → **Open** again, or
2. **System Settings → Privacy & Security → Open Anyway**
### Optional: ad-hoc sign (reduces warnings)
```bash
codesign --force --deep --sign - "dist/Scribd PDF Downloader.app"
```
For distribution outside your Mac, use an **Apple Developer ID** certificate and notarize the app.
---
## Linux
```bash
chmod +x build/ci/build-unix.sh
./build/ci/build-unix.sh
```
Output: `dist/Scribd-PDF-Downloader-Linux.tar.gz`
Extract and run:
```bash
tar -xzf dist/Scribd-PDF-Downloader-Linux.tar.gz -C dist
./dist/Scribd\ PDF\ Downloader/Scribd\ PDF\ Downloader
```
Requires a desktop environment (GUI uses tkinter).
---
## Troubleshooting builds
| Issue | Fix |
|-------|-----|
| `pyinstaller` not found | Run build script again (installs `requirements-build.txt`) |
| Chromium missing at runtime | Rebuild after `PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium` |
| Windows SmartScreen | Expected for unsigned exe; click **More info → Run anyway** |
| Mac “damaged” message | Run `xattr -cr "dist/Scribd PDF Downloader.app"` or ad-hoc sign above |
---
## What gets built
- **GUI only** (`gui.py`) — same as **Start Scribd Downloader.bat**
- **config.ini** copied next to the executable
- **session.json** and downloaded PDFs are saved in the same folder as the `.exe` / `.app`
Command-line use (`main.py`) is not included in the frozen build; use the source project with `.venv` for CLI.