jfreissmann / heatpumps

Collection of TESPy heat pump models and additional Streamlit dashboard.
MIT License
19 stars 5 forks source link

Add Mac/Linux support #9

Closed nkiessling closed 6 months ago

nkiessling commented 6 months ago

Hi,

I have been using the heat pump simulation with the web GUI and really enjoy trying out different design configurations. However, switching to Mac/Linux-based operating systems, I encountered the following problem.

Problem description

When running heatpumps under Mac/Linux, the usage of paths as follows is not feasible and causes the program to crash instantly (example):

cd example_directory/example_file.txt/../

whereas on Windows-based machines the directory would be changed to example_directory. This kind of formulation is used heavily in combination with various functions from the os module, e. g.

src_path = os.path.join(root_path, '..', 'src') or os.mkdir(os.path.join(__file__, '..', 'stable'))

Necessary steps

Consider replacing the aforementioned combinations, maybe sth. like os.path.dirname(__file__) might ensure platform independent compatibility.

Best regards Niklas

jfreissmann commented 6 months ago

Hey Niklas,

thank you for the kind words and the valuable hint. We're happy to hear you are getting use out of the library.

The issue with paths across os platforms must have slipped through. I have implemented your suggestion and added a call to os.path.abspath in addition. I think the latter might be the most important, since it also normalizes backwards relative paths with the '..' string literal. The use of os.path.dirname(__file__) looks more ideomatic to me either way.

I hope this fixed your issues on Linux or MacOS. If you have any other feedback, we are always happy to hear it.

Best regards Jonas