Skip to content

Commit

Permalink
Merge branch 'packaging'
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Jun 30, 2024
2 parents 9d2e2d9 + 3cfbd63 commit 3f8d6ea
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 92 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
required: false
default: ''
publish:
description: 'Set to "false" to skip publishing to PyPI'
description: 'Publish package to PyPI'
required: false
default: 'true'

Expand All @@ -29,7 +29,7 @@ jobs:
build-app-packages:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
fail-fast: false
defaults:
run:
Expand All @@ -46,7 +46,7 @@ jobs:

# Install binary + python dependencies
- name: Install system packages
if: ${{ matrix.os == 'ubuntu-latest' }}
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install -y '^libxcb.*-dev' libegl-dev libwebp-dev libpng16-16 libx11-xcb-dev rpm
- name: Cache python packages
id: cache
Expand All @@ -57,15 +57,15 @@ jobs:
- name: Install python packages
if: steps.cache.outputs.cache-hit != 'true'
run: |
poetry install -v --without dev
poetry install -v --only main
poetry run pip install -U pyinstaller setuptools
- name: Build pyinstaller package
run: poetry run pyinstaller -y packaging/naturtag.spec

# Include taxon FTS db, compress, and set platform name
- name: Finish pyinstaller package (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
if: startsWith(matrix.os, 'ubuntu')
run: |
ASSETS=dist/naturtag/_internal/assets/data
tar -xvzf $ASSETS/taxonomy.tar.gz --directory $ASSETS/
Expand All @@ -74,7 +74,7 @@ jobs:
echo "DIST_NAME=linux" >> $GITHUB_ENV
- name: Finish pyinstaller package (macOS)
if: ${{ matrix.os == 'macos-latest' }}
if: startsWith(matrix.os, 'macos')
run: |
ASSETS=dist/naturtag.app/Contents/Resources/assets/data
tar -xvzf $ASSETS/taxonomy.tar.gz --directory $ASSETS/
Expand All @@ -83,7 +83,7 @@ jobs:
echo "DIST_NAME=macos" >> $GITHUB_ENV
- name: Finish pyinstaller package (Windows)
if: ${{ matrix.os == 'windows-latest' }}
if: startsWith(matrix.os, 'windows')
run: |
ASSETS=dist/naturtag/_internal/assets/data
tar -xvzf $ASSETS/taxonomy.tar.gz --directory $ASSETS/
Expand All @@ -93,7 +93,7 @@ jobs:
# Build deb, snap, and rpm packages
- name: Build Linux packages with FPM
if : ${{ matrix.os == 'ubuntu-latest' }}
if : startsWith(matrix.os, 'ubuntu')
run: |
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
Expand All @@ -103,7 +103,7 @@ jobs:
# Build dmg package
- name: Build disk image (macOS)
if: ${{ matrix.os == 'macos-latest' }}
if: startsWith(matrix.os, 'macos')
run: |
brew install create-dmg
cd packaging
Expand All @@ -117,14 +117,14 @@ jobs:
path: naturtag-${{ env.DIST_NAME }}.tar.gz

- name: Upload disk image (macOS)
if: ${{ matrix.os == 'macos-latest' }}
if: startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v4
with:
name: naturtag.dmg
path: dist/naturtag.dmg

- name: Upload FPM workflow artifacts (Linux)
if : ${{ matrix.os == 'ubuntu-latest' }}
if : startsWith(matrix.os, 'ubuntu')
uses: actions/upload-artifact@v4
with:
name: naturtag-fpm
Expand All @@ -148,6 +148,10 @@ jobs:
uses: softprops/action-gh-release@v2
with:
files: 'naturtag*'
body: |
See changelog for release details: https://github.com/pyinat/naturtag/blob/main/HISTORY.md
See docs for installation instructions: https://naturtag.readthedocs.io/en/stable/installation.html
draft: true

# Publish python package to PyPI
release-pypi-package:
Expand Down
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* In refresh mode, check for taxonomy changes and update tags with the new taxon (1:1 changes only)

**Database:**
* Update packaged taxonomy db with iNaturalist data from June 2024
* Include data for most commonly observed taxa with PyInstaller packages and platform-specific installers
* Pre-compute ancestor IDs, child IDs, iconic taxon, observation count, and leaf taxon count based
on RG observations from GBIF export
Expand Down
Binary file modified assets/data/taxonomy.tar.gz
Binary file not shown.
16 changes: 14 additions & 2 deletions packaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@ This directory contains scripts and config for building Naturtag packages in the
* Taxonomy full text search database (optional download)

# Release steps

## Build taxonomy db
* Locally build full taxonomy FTS database with `build_taxon_db.py`. For reference, see:
* [pyinaturalist_convert.dwca](https://pyinaturalist-convert.readthedocs.io/en/stable/modules/dwca.html)
* [pyinaturalist_convert.taxonomy](https://pyinaturalist-convert.readthedocs.io/en/stable/modules/taxonomy.html)
* [pyinaturalist_convert.fts](https://pyinaturalist-convert.readthedocs.io/en/stable/modules/fts.html)
* Export subset of db (English language, common species only) with `export_taxa.sh`
* Commit to repo under `assets/data/taxonomy.tar.gz`
* Export full db with `export_taxa_full.sh`
* This will create a file `taxonomy-full.tar.gz` to upload later

## Windows Installer
* Update version in `pyproject.toml` and Actual Installer config (`naturtag.aip`)
* On a Windows machine or VM, build the project locally and create an installer with Actual Installer.
* See steps in `build_win.ps1` for details (not fully automated; requires GUI interaction)

## Release
* Create and push new git tag. This will trigger jobs to build packages and create a new GitHub release.
* Export full db with `export_taxa_full.sh`
* After the release jobs complete, manually upload this to the release assets
* Most release assets will be built by the CI job, except for the following, which must be uploaded manually:
* Full taxonomy db (`taxonomy-full.tar.gz`)
* Windows installer (`naturtag-installer.exe`)
* Publish the GitHub release (by default, it will be created in draft mode)
12 changes: 5 additions & 7 deletions packaging/build_win.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Build pyinstaller package prior to creating Windows installer

# Create virtualenv
# python -m venv $env:USERPROFILE\.virtualenvs\naturtag
# Create virtualenv (if needed)
# python3.11 -m venv $env:USERPROFILE\.virtualenvs\naturtag

# Install poetry
# Install poetry (if needed)
# Invoke-WebRequest -Uri https://install.python-poetry.org -OutFile install-poetry.py
# python install-poetry.py --preview
# ~\AppData\Roaming\Python\Scripts\poetry.exe config virtualenvs.create false

# Install dependencies
. ~\.virtualenvs\naturtag\Scripts\activate.ps1
poetry install -v --no-dev
poetry self update
poetry install -v --only main
pip install -U setuptools pyinstaller
pyinstaller -y packaging\naturtag.spec

Expand All @@ -19,6 +20,3 @@ pyinstaller -y packaging\naturtag.spec
# 2. Run installer
# 3. Open Naturtag and test basic features
Invoke-Item packaging\naturtag.aip

# Launch InstallForge
# Invoke-Item packaging\naturtag.ifp
21 changes: 17 additions & 4 deletions packaging/naturtag.aip
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[Setup]
AIVersion=9.3
AIVersion=10.0
AIEdition=1
GUID={01329D81-576C-42FE-9850-9C4C03F161FB}
AppName=Naturtag
AppEdition=
AppVersion=v0.8.0-beta
GetVerFromExe=0
AppDescription=
CompanyName=
WebSite=https://naturtag.readthedocs.io
SupportLink=https://naturtag.readthedocs.io
Copyright=Copyright © 2024 Jordan Cook
GetCopyrightFromExe=0
InstallLevel=1
UpgradeMode=0
IfInstalled=0
Expand Down Expand Up @@ -51,12 +55,15 @@ UninstallCloseMainExe=1
UninstallCloseApp=0
UninstallCloseAppFile=File.exe
UninstallCloseAppText=App
UninstallForceCloseApp=0
Updater=1
UpdateURL=https://raw.githubusercontent.com/pyinat/naturtag/main/packaging/latest.txt
CheckUpdateBefore=0
CheckUpdaterTitle=0
CheckUseDownloader=0
AllowChangeUpdate=0
GetVerFrom=2
UpdateMethod=0
CheckUseDownloader=0
AutoCheckUpdate=0
UpdateFrequency=2
AutoSilentUpdate=0
Expand All @@ -67,6 +74,7 @@ CheckUpdatePassParam=0
CheckUpdaterParam=?id=<AppVersion>
UpdaterParameters=
LaunchOnStatup=0
RegisterAppPath=0
SelectFolderMode=0
AltInstallDir=<AppData>\<AppName>
DataExtractParam=-o"<InstallDir>" -aoa
Expand Down Expand Up @@ -99,18 +107,22 @@ HideOtherLanguages=0
QueryText=0
QueryTextName=
QueryTextReq=0
QueryTextDis=0
QueryTextHide=0
QueryCustom=0
QueryCustomName=
QueryCustomReq=0
QueryCustomDis=0
QueryCustomHide=0
QueryCustomType=0
QueryCustomMustExists=0
QueryKey=0
QueryKeyName=Key:
QueryKeyReq=0
QueryKeyDis=0
QueryKeyHide=0
QueryKeyHideReg=0
QueryKeyHidePass=0
KeysCount=0
InfoCustomBox=0
InfoCustomBoxReq=0
Expand All @@ -120,6 +132,7 @@ CustomComboBoxName=
CustomComboBoxItems=
CustomComboDefItem=
ComboBoxDisableOnUpgrade=0
ComboBoxUpdateInstallDir=0
CustomComponents=0
CustomComponentsText=
CustomComponentsDesc=
Expand All @@ -139,8 +152,8 @@ CustomActionCommand=<WebSite>
CustomActionChecked=0
CustomActionAdmin=0
TotalFiles=2
SourceDirFiles=1050
SourceDirSize=162253011
SourceDirFiles=472
SourceDirSize=168013728

[GUI]
FontName=Verdana
Expand Down
20 changes: 13 additions & 7 deletions packaging/naturtag.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path

from PyInstaller.compat import is_darwin, is_linux, is_win
from PyInstaller.utils.hooks import copy_metadata

BUILD_PY_VERSION = '3.11'
PROJECT_NAME = 'naturtag'
Expand All @@ -17,9 +18,16 @@ VENV_DIR = CI_VENV_DIR if CI_VENV_DIR.is_dir() else LOCAL_VENV_DIR
LIB_DIR_WIN = VENV_DIR / 'Lib' / 'site-packages' / 'pyexiv2' / 'lib'
LIB_DIR_NIX = VENV_DIR / 'lib' / f'python{BUILD_PY_VERSION}' / 'site-packages' / 'pyexiv2' / 'lib'

# Define platform-specific dependencies
binaries = []
datas = [
(str(ICONS_DIR / '*.ico'), 'assets/icons'),
(str(ICONS_DIR / '*.png'), 'assets/icons'),
(str(ASSETS_DATA_DIR / '*.qss'), 'assets/data'),
(str(ASSETS_DATA_DIR / '*.tar.gz'), 'assets/data'),
]
hiddenimports = []

# Define platform-specific dependencies
if is_win:
binaries = [
(str(LIB_DIR_WIN / 'exiv2.dll'), '.'),
Expand All @@ -39,16 +47,14 @@ elif is_linux:
else:
raise NotImplementedError

# Ensure package metadata is available for importlib.metadata
datas += copy_metadata('naturtag')

a = Analysis(
[str(PACKAGE_DIR / 'app' / 'app.py')],
pathex=[str(PROJECT_DIR)],
binaries=binaries,
datas=[
(str(ICONS_DIR / '*.ico'), 'assets/icons'),
(str(ICONS_DIR / '*.png'), 'assets/icons'),
(str(ASSETS_DATA_DIR / '*.qss'), 'assets/data'),
(str(ASSETS_DATA_DIR / '*.tar.gz'), 'assets/data'),
],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
Expand Down
Loading

0 comments on commit 3f8d6ea

Please sign in to comment.