Skip to content

Add pyinstaller build#143

Closed
sjswerdloff wants to merge 11 commits intomainfrom
add_pyinstaller_build
Closed

Add pyinstaller build#143
sjswerdloff wants to merge 11 commits intomainfrom
add_pyinstaller_build

Conversation

@sjswerdloff
Copy link
Copy Markdown
Owner

@sjswerdloff sjswerdloff commented May 21, 2025

and touch up modules that were hardcoding file to use for relative offsets.

Summary by Sourcery

Prepare project for PyInstaller builds by adding executable packaging support, updating resource path handling for bundled apps, and introducing a CI workflow.

New Features:

  • Add PyInstaller packaging support to produce standalone executables

Enhancements:

  • Update config path resolution to fallback to executable directory in bundled apps
  • Bump Ruff version to v0.11.10 in pre-commit configuration

Build:

  • Include pyinstaller as a project dependency in pyproject.toml

CI:

  • Add GitHub Actions workflow to build, package, and release PyInstaller executables

make tdwii_config look for configuration files relative to executable (sys.argv[0]) if __file__ isn't found
	which is the situation when the app is built in to an exe
add build-executables CI workflow (manual trigger)
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented May 21, 2025

Reviewer's Guide

This PR adds PyInstaller support by updating project dependencies and CI configuration to build and package executables, enhances file‐path resolution in key modules to fall back on the executable directory when file is unavailable, and includes a minor help‐message formatting cleanup.

File-Level Changes

Change Details Files
Enable PyInstaller builds and packaging via CI workflow
  • Added pyinstaller to main, dev, and tool groups in pyproject.toml
  • Bumped ruff version in .pre-commit-config.yaml
  • Introduced .github/workflows/build-executables.yml with steps to install dependencies, run PyInstaller, compress artifacts, and create GitHub releases
pyproject.toml
.pre-commit-config.yaml
.github/workflows/build-executables.yml
Fallback to executable directory for config file paths
  • In upsscp CLI: check for config file via file, then sys.executable directory, raising an error if missing
  • In handlers: adjust ApplicationEntities.json lookup to fall back to executable path when file lookup fails
  • In tdwii_config: drop back to sys.executable directory if module path is invalid, with error on missing directory
tdwii_plus_examples/cli/upsscp/upsscp.py
tdwii_plus_examples/cli/upsscp/handlers.py
tdwii_plus_examples/tdwii_config.py
Clean up help string concatenation
  • Replaced two‐part string concatenation in database clean option help text with a single literal
tdwii_plus_examples/cli/upsscp/upsscp.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sjswerdloff sjswerdloff self-assigned this May 21, 2025
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sjswerdloff - I've reviewed your changes - here's some feedback:

  • Extract and centralize the fallback logic for resolving config paths into a shared helper instead of duplicating it across multiple modules.
  • Use PyInstaller’s --add-data option or a dedicated packaging script to include config/data files, rather than manual copy commands in the GitHub Actions workflow.
  • Parameterize OS-specific path separators and build steps in the CI workflow to simplify extending support to macOS and Linux builds.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

sjswerdloff and others added 4 commits May 21, 2025 18:50
correct to FileNotFoundError

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
removed platform-name and path-sep because they aren't being used.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
corrected name of upload artefact

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@sjswerdloff
Copy link
Copy Markdown
Owner Author

Hey @sjswerdloff - I've reviewed your changes - here's some feedback:

  • Extract and centralize the fallback logic for resolving config paths into a shared helper instead of duplicating it across multiple modules.
  • Use PyInstaller’s --add-data option or a dedicated packaging script to include config/data files, rather than manual copy commands in the GitHub Actions workflow.
  • Parameterize OS-specific path separators and build steps in the CI workflow to simplify extending support to macOS and Linux builds.

Here's what I looked at during the review
Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

The configuration files have to be modified by the user after installation, so --add-data isn't appropriate.
I did parameterise the OS-specific path separators and builds steps but commented out the macOS and Linux builds because delivering binaries on MacOS requires an Apple developer account and signature, and those who use Linux can readily download the code and run it directly with their own python interpreter.

@sjswerdloff sjswerdloff requested a review from dwikler May 21, 2025 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant