Skip to content

Development

shred86 edited this page Jun 7, 2024 · 11 revisions

The purpose of this page is to provide notes for users interested in modifying or helping develop Ortho4XP.

Using PyInstaller

PyInstaller is used to bundle Ortho4XP its dependencies into a single package allowing a user to run Ortho4XP without any additional setup.

The following arguments were used with PyInstaller to build the package:

Windows 11 (Command Prompt):

pyinstaller --noconfirm ^
    --paths=src ^
    --add-data="./Utils:./Ortho4XP_Data/Utils" ^
    --add-data="./Extents:./Ortho4XP_Data/Extents" ^
    --add-data="./Filters:./Ortho4XP_Data/Filters" ^
    --add-data="./Licence:./Ortho4XP_Data/Licence" ^
    --add-data="./Patches:./Ortho4XP_Data/Patches" ^
    --add-data="./Previews:./Ortho4XP_Data/Previews" ^
    --add-data="./Providers:./Ortho4XP_Data/Providers" ^
    --add-data="community_server.txt:./Ortho4XP_Data/" ^
    --hidden-import=PIL ^
    Ortho4XP.py

macOS 14.5:

pyinstaller --noconfirm \
    --paths=src \
    --add-data="./Utils:./Ortho4XP_Data/Utils" \
    --add-data="./Extents:./Ortho4XP_Data/Extents" \
    --add-data="./Filters:./Ortho4XP_Data/Filters" \
    --add-data="./Licence:./Ortho4XP_Data/Licence" \
    --add-data="./Patches:./Ortho4XP_Data/Patches" \
    --add-data="./Previews:./Ortho4XP_Data/Previews" \
    --add-data="./Providers:./Ortho4XP_Data/Providers" \
    --add-data="community_server.txt:./Ortho4XP_Data/" \
    --hidden-import=PIL \
    Ortho4XP.py

Linux (Debian):

pyinstaller --noconfirm \
    --paths=src \
    --add-data="./Utils:./Ortho4XP_Data/Utils" \
    --add-data="./Extents:./Ortho4XP_Data/Extents" \
    --add-data="./Filters:./Ortho4XP_Data/Filters" \
    --add-data="./Licence:./Ortho4XP_Data/Licence" \
    --add-data="./Patches:./Ortho4XP_Data/Patches" \
    --add-data="./Previews:./Ortho4XP_Data/Previews" \
    --add-data="./Providers:./Ortho4XP_Data/Providers" \
    --add-data="community_server.txt:./Ortho4XP_Data/" \
    --collect-all=PIL \
    Ortho4XP.py

Note: Using -collect-all was required to use on Linux or the map would not load in the Tile and management window.

When building the package on Windows, it has to be accomplished outside of a Python virtual environment (if used).

When building the package on macOS or Linux, it can be accomplished either outside or inside of a Python virtual environment.

For macOS, an additional step is required to get GDAL to work. Once the Ortho4XP package is built, copy the *.so files from your venv site-packages, /Users/user_name/Projects/Ortho4XP/venv/lib/python3.12/site-packages/osgeo and replace the ones in the package dist/Ortho4XP/_internal/osgeo folder. It's unknown at this time as to why this is required but was the only way to get GDAL to work properly.

Since each package is specific to the operating system and architecture, unnecessary files can be deleted before distribution to reduce file size. The current files that are being removed:

  • The win, mac and/or lin folder inside the Ortho4XP/Utils directory, depending on which platform it's being built for.
  • If building for Windows, removing the *.whl files that this forked version added in the win folder.
  • Old folder inside Ortho4XP/Utils/mac folder since they are unused.
Clone this wiki locally