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

Windows and OSX versions #27

Open
fabriziosalmi opened this issue Jun 23, 2024 · 1 comment
Open

Windows and OSX versions #27

fabriziosalmi opened this issue Jun 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@fabriziosalmi
Copy link
Owner

Is your feature request related to a problem? Please describe.

Windows and OSX versions needed.

Describe the solution you'd like

To adapt the workflow to build native applications based on the provided approach for running the UglyFeed web application, we need to:

  1. Use streamlit as the primary command to start the application.
  2. Ensure the entry point for the application is gui.py.
  3. Use PyInstaller and py2app to package the application, ensuring that the Streamlit command is correctly configured within the native app's execution context.

Here's the adapted build-native-apps.yml workflow configuration:

Updated build-native-apps.yml

name: Build Native Apps

on:
  workflow_run:
    workflows: ["Release"]
    types:
      - completed

jobs:
  build-windows:
    runs-on: windows-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.8'

      - name: Install dependencies
        run: pip install -r requirements.txt

      - name: Install PyInstaller
        run: pip install pyinstaller

      - name: Create executable with PyInstaller
        run: |
          # Create a custom script to run Streamlit
          echo -e "import os\nos.system('streamlit run gui.py --server.address 0.0.0.0 --browser.gatherUsageStats false')" > start_uglyfeed.py
          # Use PyInstaller to package the application
          pyinstaller --onefile --windowed --name UglyFeed start_uglyfeed.py

      - name: Upload Windows executable
        uses: actions/upload-artifact@v2
        with:
          name: UglyFeed-Windows
          path: dist/UglyFeed.exe

  build-macos:
    runs-on: macos-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.8'

      - name: Install dependencies
        run: pip install -r requirements.txt

      - name: Install py2app
        run: pip install py2app

      - name: Create custom setup.py for py2app
        run: |
          echo "from setuptools import setup" > setup.py
          echo "import os" >> setup.py
          echo "APP = ['start_uglyfeed.py']" >> setup.py
          echo "OPTIONS = {'argv_emulation': True, 'packages': ['streamlit'], 'plist': {'LSUIElement': True}}" >> setup.py
          echo "setup(app=APP, options={'py2app': OPTIONS})" >> setup.py
          # Create a custom script to run Streamlit
          echo -e "import os\nos.system('streamlit run gui.py --server.address 0.0.0.0 --browser.gatherUsageStats false')" > start_uglyfeed.py

      - name: Build macOS application
        run: python setup.py py2app

      - name: Upload macOS application
        uses: actions/upload-artifact@v2
        with:
          name: UglyFeed-macOS
          path: dist/UglyFeed.app

  create-release:
    needs: [build-windows, build-macos]
    runs-on: ubuntu-latest
    steps:
      - name: Download Windows artifact
        uses: actions/download-artifact@v2
        with:
          name: UglyFeed-Windows
          path: ./dist/windows

      - name: Download macOS artifact
        uses: actions/download-artifact@v2
        with:
          name: UglyFeed-macOS
          path: ./dist/macos

      - name: Create GitHub release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: |
            Automated build for UglyFeed version ${{ github.ref }}
          draft: false
          prerelease: false
          files: |
            ./dist/windows/UglyFeed.exe
            ./dist/macos/UglyFeed.app

Explanation:

  1. Trigger the Workflow:

    • The workflow triggers on the completion of the Release workflow, ensuring it runs only after the PyPI deployment.
  2. Windows Build:

    • Custom Script: A temporary start_uglyfeed.py script is created to run the Streamlit command.
    • PyInstaller: This script is packaged into a standalone executable using PyInstaller.
  3. macOS Build:

    • Custom Script: The same start_uglyfeed.py script is used for the macOS build.
    • py2app: This script is packaged into a macOS application using py2app.
    • Setup for py2app: The setup.py is dynamically created to configure py2app.
  4. Uploading Artifacts:

    • Both Windows and macOS applications are uploaded as artifacts after the build.
  5. Creating a GitHub Release:

    • After building the native applications, a new release is created on GitHub, attaching the built executables.

Notes:

  • Custom Script (start_uglyfeed.py):

    • This script runs the Streamlit command to start gui.py as specified in your deployment instructions.
    • This approach ensures the application is packaged correctly with the required command to start the Streamlit app.
  • Streamlit Dependencies:

    • Ensure requirements.txt includes all dependencies, especially streamlit.
  • Path Adjustments:

    • Verify the paths to UglyFeed.exe and UglyFeed.app match the expected output locations of the build tools.
@fabriziosalmi fabriziosalmi added the enhancement New feature or request label Jun 24, 2024
@fabriziosalmi
Copy link
Owner Author

postponed to 0.1.x versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant