Conversation
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)
…ion (2.x) already
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>
…plus_examples into add_pyinstaller_build
Reviewer's GuideThis PR integrates a robust Windows executable build pipeline via GitHub Actions with caching, security scans, and automated releases, extends application code to locate config files when bundled, adds PyInstaller as a dependency and updates lint tooling, and makes tests compatible with Python 3.11’s tomllib. Sequence Diagram for Configuration File Fallback LogicsequenceDiagram
participant AppLogic as "Application Logic"
participant FileSystem as "File System"
participant ExecutionContext as "Execution Context (sys.executable)"
AppLogic->>FileSystem: Attempt to resolve config file path (e.g., relative to __file__)
alt Primary path resolution successful
FileSystem-->>AppLogic: Config file found at primary path
AppLogic->>AppLogic: Load config from primary path
else Primary path resolution failed (e.g., __file__ context unavailable in bundle)
FileSystem-->>AppLogic: Config file not found at primary path
AppLogic->>ExecutionContext: Get executable directory
ExecutionContext-->>AppLogic: Executable directory path
AppLogic->>FileSystem: Attempt to resolve config file path (relative to executable directory)
alt Fallback path resolution successful
FileSystem-->>AppLogic: Config file found at fallback path
AppLogic->>AppLogic: Load config from fallback path
else Fallback path resolution failed
FileSystem-->>AppLogic: Config file not found at fallback path
AppLogic->>AppLogic: Raise FileNotFoundError
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…s been zipped in to dist/config.zip)
for Copy-Item command
|
I worked out the details in this PR (after jamming in just the workflow in to main...). |
There was a problem hiding this comment.
Hey @sjswerdloff - I've reviewed your changes - here's some feedback:
- You now have two nearly identical GitHub workflow files (
alt_build_executables.ymlandbuild-executables.yml); consider consolidating them to avoid duplication and simplify maintenance. - The tomli/tomllib import fallback is copy-pasted across many tests—extract it into a shared helper or pytest fixture to DRY up your test suite.
- Your complex cache key (including branch-id and weekly rotation) may reduce cache hits; consider simplifying the key to improve cache reuse across runs.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Can you explain to me how starting around line #389 you can tell if it's a relative path in the configuration?
This needs to change to something like:
if getattr(sys, 'frozen', False):
current_dir = os.path.dirname(sys.executable)
elif __file__:
current_dir = os.path.dirname(__file__)
# current_dir = os.path.abspath(os.path.dirname(__file__))
for a pyinstaller .exe
One of the Issues I created was consolidation of this type of logic (it's a bit of a hack elsewhere, but I think this code fragment is the right way to get this information).
There was a problem hiding this comment.
In the meantime, I just configured an absolute path in the upsscp ini file and that worked.
There was a problem hiding this comment.
The os.path.join takes care of this. If the second arg is an absolute path, it does ignore the first arg.
So with:
# Set the instance storage and database directories to current directory
# if setting is not an absolute path
current_dir = os.path.abspath(os.path.dirname(__file__))
instance_dir = os.path.join(current_dir, app_config["instance_location"])
instance_dir_path = os.path.abspath(instance_dir)instance_dir will be either
- ./tdwii_plus_examples/cli/upsscp/<instance_location> if <instance_location> is a relative path or
- <instance_location> if <instance_location> is an absolute path
The 3rd line is actually useless as in both cases instance_dir will be an absolute path.
There was a problem hiding this comment.
I agree there is a need for a change when packaging the scripts into executables as the file is not valid without a script file.
The proposed change should work to get current_dir and use it in the second line of the code block above to get the absolute path using the config parameter whether it is absolute or relative to the executable location.
I cancelled the other workflow. |
fix bug in handling ScanSpotMetersetWeights (list vs. float for single spot) when generating treatment record added tdd to build of executables
removed files from release that won't be there, only using the zip (might be worth revisiting the packaging approach)
…a paid service, more grief than it's worth
|
I did clone the branch to try the executables on my Windows 11 minipc but I did not find the dist directory, I don't see it in the branch code on GitHub either. λ tdwii_config_dump
Traceback (most recent call last):
File "config_dump.py", line 42, in <module>
File "config_dump.py", line 27, in main
File "tdwii_plus_examples\tdwii_config.py", line 18, in load_ae_config
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\david\\AppData\\Local\\Temp\\_MEI48442\\tdwii_plus_examples\\config\\ApplicationEntities.json'
[PYI-15460:ERROR] Failed to execute script 'config_dump' due to unhandled exception! |
dwikler
left a comment
There was a problem hiding this comment.
I left comments in the pull request after trying to run the executables and experiencing some errors. Adding a markdown file to explain how to download or build the executables may help.

Summary by Sourcery
Enable end-to-end Windows executable builds with improved caching, security scanning, automated release note generation, and robust packaging; enhance configuration file lookup for bundled apps; and update tests and dependencies for Python 3.11+ compatibility
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Tests: