Skip to content

Improve cross-platform development setup (solver path handling + dependency conflict) #10

@parthdagia05

Description

@parthdagia05

Description: Improve Cross-Platform Development Setup (macOS/Linux)

Closes #10

Summary

This PR addresses two primary blockers for running MUIO from source on non-Windows platforms (specifically macOS/Apple Silicon and Linux). It refactors solver path resolution to move away from hard-coded Windows-centric paths and fixes a dependency conflict that prevented clean environment builds.


Changes

1. Dynamic Solver Path Handling

Refactored OsemosysClass.py and Config.py to move away from hard-coded, platform-specific directory strings.

Resolution Priority Logic:

  1. Environment Variables: Checks for MUIO_GLPK_PATH or MUIO_CBC_PATH (useful for custom CI/CD or container setups).
  2. Windows Defaults: Preserves existing behavior using SOLVERs_FOLDER if on Windows.
  3. System Discovery: On macOS/Linux, it now uses shutil.which() to find glpsol or cbc in the user's $PATH (e.g., Homebrew or APT installs).

Technical Impact:

  • No import-time crashes if solvers are missing.
  • Runtime RuntimeError provides clear feedback if a solver is called but not found.
  • Full support for Apple Silicon via system-installed binaries.

2. Dependency Resolution Fix

Fixed a ResolutionImpossible error during pip install -r requirements.txt.

  • Conflict: botocore required urllib3 < 1.27, but requirements.txt pinned urllib3==2.2.1.
  • Fix: Downgraded pin to urllib3==1.26.18. This satisfies all current project dependencies and allows for clean virtual environment creation.

Manual Verification (macOS Apple Silicon)

Tests conducted on macOS 14.x (M1 Pro) in a fresh Python 3.9 environment.

  1. Installation: pip install -r requirements.txt now completes without errors.
  2. Discovery: * Installed glpk and cbc via Homebrew.
    • Verified Config.GLPK_PATH and Config.CBC_PATH correctly resolve to /opt/homebrew/bin and /opt/homebrew/opt/cbc/bin respectively.
  3. End-to-End: * Successfully launched the app via python API/app.py.
    • Triggered model execution from the UI; solvers executed correctly via the new path resolution logic.
    • Verified output results were generated without permission or path errors.

Backward Compatibility

  • Windows: The logic specifically preserves the existing Path(SOLVERs_FOLDER, ...) structure. Windows users and existing .exe build workflows are unaffected.
  • Logic: No changes were made to the actual solver execution arguments, only the directory resolution.

✅ Checklist

  • Code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings.
  • Dependency versions have been tested for compatibility.
  • Documentation/comments updated where necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions