Make package init cross-platform: fix Windows-only APIs and add configurable bin path suffix - #114
Make package init cross-platform: fix Windows-only APIs and add configurable bin path suffix#114ryan-kipawa with Copilot wants to merge 3 commits into
Conversation
…os.pathsep, add MIKEPLUSPY_INSTALL_BIN env var Co-authored-by: ryan-kipawa <74630349+ryan-kipawa@users.noreply.github.com>
| fallback_mikeplus_install_root=Path("C:/Program Files (x86)/DHI/MIKE+/2026"), | ||
| env_var_name_install_root="MIKEPLUSPY_INSTALL_ROOT", # set this environment variable to use custom install path | ||
| bin_path=Path("bin/x64"), | ||
| env_var_name_bin_path="MIKEPLUSPY_INSTALL_BIN", # set this environment variable to use a custom bin path suffix (e.g. 'bin/x64') |
There was a problem hiding this comment.
Combine this with the line above to just check that environment variable, and if not, pass the default. No need to pass the env variable name.
There was a problem hiding this comment.
Done in 8dd2f5a. The MIKEPLUSPY_INSTALL_BIN env var is now resolved at the call site via os.getenv("MIKEPLUSPY_INSTALL_BIN", "bin/x64"), and the env_var_name_bin_path parameter has been removed from setup_bin_path.
| _setup_called = False | ||
|
|
||
|
|
||
| def setup_bin_path( |
There was a problem hiding this comment.
Review this entire method to ensure it's functioning as intended. There should be helpful warning messages to the user to all possible outcomes that let them take corrective action.
There was a problem hiding this comment.
Addressed in 8dd2f5a. Added warning messages for all outcomes:
- Custom install root used: warns with the resolved path so the user can verify it's correct.
- DHI.Mike.Install auto-detection fails: warns with the exception message so the user knows why, and that it's falling back.
- Falling back to default path: existing warning already in place, kept as-is.
- Custom path not found:
FileNotFoundErrornow includes the env var name, its value, and a hint to unset it for auto-detection.
…r all setup_bin_path outcomes Co-authored-by: ryan-kipawa <74630349+ryan-kipawa@users.noreply.github.com>
The package init in
utils.pyusedos.add_dll_directory(Windows-only) unconditionally and hardcoded";"as the PATH separator, breaking on Linux/macOS. The bin folder suffix (bin/x64) was also hardcoded with no env var override, unlike the install root.Changes
os.add_dll_directory: Guarded all call sites withsys.platform == "win32"; returnsNoneon other platforms";"withos.pathsepin_update_python_env_pathand_try_mike_install_bin_setupMIKEPLUSPY_INSTALL_BINenvironment variable is resolved at the call site in__init__.pyand passed directly asbin_path, mirroring howMIKEPLUSPY_INSTALL_ROOTworks for the install rootsetup_bin_path:FileNotFoundErrorincludes the env var name, its value, and a hint to unset it for auto-detectionOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.