openEMS/python
Yifeng Li 486f3140cb openEMS.pyx: check canonical path in assert, close #113.
Currently, running openEMS's example Python scripts on macOS always fails
with the following error:

    $ python3 MSL_NotchFilter.py
    Traceback (most recent call last):
      File "/Users/gentoo/code/openEMS-Project/openEMS/python/Tutorials/MSL_NotchFilter.py", line 103, in <module>
        FDTD.Run(Sim_Path, cleanup=True)
      File "openEMS/openEMS.pyx", line 489, in openEMS.openEMS.openEMS.Run
    AssertionError

This is caused by an oversight of an assertion in openEMS.pyx:

    os.chdir(sim_path)
    # ...
    assert os.getcwd() == sim_path

The problem here is that "sim_path" is not a canonical path name,
so the assertion would fail if the path we're switching into contains
a symbolic link. This problem affects all operating systems, it's not
limited to macOS. But on macOS, the problem is especially serious,
since macOS's "/tmp" is a link to "/private/tmp" by default. Thus, it
causes an AssertionError in all the included Python examples.

Instead of doing "assert os.getcwd() == sim_path", we should write
"assert os.getcwd() == os.path.realpath(sim_path)" to ensure that
we're checking a canonical path.

Signed-off-by: Yifeng Li <tomli@tomli.me>
2023-05-03 18:46:29 +02:00
..
Tutorials python tutorials: use new/better automesh options for CRLH examples 2023-01-07 20:52:36 +01:00
doc python: doc updates 2016-11-15 20:09:27 +01:00
openEMS openEMS.pyx: check canonical path in assert, close #113. 2023-05-03 18:46:29 +02:00
README.md fix typo, #35 2018-11-17 18:36:30 +01:00
setup.py python: language level 3 2022-12-29 10:06:11 +01:00

README.md

openEMS python interface

Install

  • Simple version:
python setup.py install
  • Extended options, e.g. for custom install path at /opt/openEMS:
python setup.py build_ext -I/opt/openEMS/include -L/opt/openEMS/lib -R/opt/openEMS/lib"
python setup.py install

Note: The install command may require root on Linux, or add --user to install to ~/.local