Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging: build and package for MacOS (experimental) #195

Merged
merged 3 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ on:
# Globals
env:
PROJECT_FOLDER: "qgis_deployment_toolbelt"
PYTHON_VERSION: "3.10"
PYTHON_VERSION: "3.11"
PYINSTALLER_LOG_LEVEL: "DEBUG"

# Jobs definition
jobs:
build-python-wheel:
name: "📦 Python Wheel"
runs-on: ubuntu-20.04
name: "🐍 Python Wheel"
runs-on: ubuntu-22.04

steps:
- name: Get source code
Expand Down Expand Up @@ -66,9 +66,42 @@ jobs:
path: dist/*
if-no-files-found: error

build-macos:
name: "🍏 Mac OS"
runs-on: macos-12

steps:
- name: Get source code
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
cache-dependency-path: "requirements/*.txt"

- name: Install project requirements
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements.txt
python -m pip install -U -r requirements/packaging.txt

- name: Install project as a package
run: python -m pip install -e .

- name: Generates Executable
run: python -O ./builder/pyinstaller_build_macos.py

- uses: actions/upload-artifact@v3
with:
name: macos_executable
path: dist/*
if-no-files-found: error

build-ubuntu:
name: "📦 Ubuntu LTS"
runs-on: ubuntu-20.04
name: "🐧 Ubuntu LTS"
runs-on: ubuntu-22.04

steps:
- name: Get source code
Expand Down Expand Up @@ -100,8 +133,7 @@ jobs:
if-no-files-found: error

build-windows:
name: "📦 Windows"

name: "🏠 Windows"
runs-on: windows-latest

steps:
Expand Down Expand Up @@ -140,7 +172,7 @@ jobs:
release:
name: "🚀 GitHub Release"
runs-on: ubuntu-latest
needs: [build-python-wheel, build-ubuntu, build-windows]
needs: [build-macos, build-python-wheel, build-ubuntu, build-windows]

if: startsWith(github.ref, 'refs/tags/')

Expand All @@ -151,6 +183,12 @@ jobs:
name: python_wheel
path: builds/wheel/

- name: Retrieve artifact from MacOS build
uses: actions/download-artifact@v3
with:
name: macos_executable
path: builds/macos/

- name: Retrieve artifact from Ubuntu build
uses: actions/download-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
lint-ubuntu:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Get source code
Expand Down
48 changes: 48 additions & 0 deletions builder/pyinstaller_build_macos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! python3 # noqa: E265

"""
Launch PyInstaller using a Python script.
"""

# #############################################################################
# ########## Libraries #############
# ##################################

# Standard library
import platform
import sys
from os import getenv
from pathlib import Path

# 3rd party
import PyInstaller.__main__

# package
sys.path.insert(0, str(Path(".").resolve()))
from qgis_deployment_toolbelt import __about__ # noqa: E402

# #############################################################################
# ########### MAIN #################
# ##################################
package_folder = Path("qgis_deployment_toolbelt")

mac_os_version, _, _ = platform.mac_ver()
mac_os_version = "-".join(mac_os_version.split(".")[:2])

PyInstaller.__main__.run(
[
"--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")),
"--name={}_{}_MacOS{}_Python{}-{}".format(
__about__.__title_clean__,
__about__.__version__.replace(".", "-"),
mac_os_version,
platform.python_version_tuple()[0],
platform.python_version_tuple()[1],
),
"--noconfirm",
"--noupx",
"--onefile",
"--console",
str(package_folder / "cli.py"),
]
)