Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix OMSimulator pip package #1285

Merged
merged 4 commits into from
Mar 20, 2024
Merged

Conversation

arun3688
Copy link
Contributor

@arun3688 arun3688 commented Mar 15, 2024

Related Issues

#1283

Purpose

This PR fixes the OMSimulator pip package according to the new cmake build system.

TODO

  • fix the setup.py file to copy the dlls according to the new build path

@arun3688 arun3688 merged commit 10671e8 into OpenModelica:master Mar 20, 2024
2 checks passed
@arun3688 arun3688 deleted the pippackage branch March 20, 2024 22:03
@bilderbuchi
Copy link

@arun3688 was this change tested on Windows? I am running OMSimulator from within OMEdit v1.24.0-dev-230-g20a061263e (64-bit), and on simulating an ssp, I get

Traceback (most recent call last):
  File "C:/OpenModelica1.24.0-dev-64bit/share/OMSimulator/scripts/OMSimulatorServer.py", line 11, in <module>
    import OMSimulator as oms
  File "C:\OpenModelica1.24.0-dev-64bit\lib\omc\OMSimulator\__init__.py", line 17, in <module>
    Scope._init()
  File "C:\OpenModelica1.24.0-dev-64bit\lib\omc\OMSimulator\Scope.py", line 5, in _init
    _capi = capi()
            ^^^^^^
  File "C:\OpenModelica1.24.0-dev-64bit\lib\omc\OMSimulator\capi.py", line 16, in __init__
    dllDir = os.add_dll_directory(os.path.dirname(omslib))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 1119, in add_dll_directory
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\OpenModelica1.24.0-dev-64bit\\lib\\omc\\OMSimulator\\../../bin'
Simulation process failed. Exited with code 0x00000001.

It looks like that path is off by one level, there is one /.. missing, as the logged path resolves to C:/OpenModelica1.24.0-dev-64bit/lib/bin' (which does not exist), not to C:/OpenModelica1.24.0-dev-64bit/bin', which is the intention AFAICT.

This was working in OM 1.23.1

@arun3688
Copy link
Contributor Author

@bilderbuchi i did a quick test in OMEdit and it works for me

image

this is my omc version v1.24.0-dev-223-g596b7d3d68-cmake

@arun3688
Copy link
Contributor Author

@bilderbuchi i think you are somehow having the old version of omsimulator, the current version of omsimulator checks for 3 directories up see the below code in

    if not os.path.exists(omslib):
      if os.name == 'nt': # Windows
        omslib = os.path.join(dirname, "../../../bin", "libOMSimulator.dll")
        dllDir = os.add_dll_directory(os.path.dirname(omslib))
        dllSearchPath = True
      else:
        # attempt to fix #8163 on Linux
        omslib = os.path.join(dirname, "..", "libOMSimulator.dll")

please make sure in your installed path C:\\OpenModelica1.24.0-dev-64bit\\lib\\omc\\OMSimulator\\capi.py in line number :13 , you should have the above code otherwise you are having older version of omsimulator

@bilderbuchi
Copy link

bilderbuchi commented Aug 20, 2024

No, I have

    ## look for dll in the OpenModelica top level directory or OMSimulator stand alone directory
    if not os.path.exists(omslib):
      if os.name == 'nt': # Windows
        omslib = os.path.join(dirname, "../../bin", "libOMSimulator.dll")
        dllDir = os.add_dll_directory(os.path.dirname(omslib))
        dllSearchPath = True
      else:
        # attempt to fix #8163 on Linux
        omslib = os.path.join(dirname, "..", "libOMSimulator.dll")

I installed with the nightly installer from today, on Windows 10.

I see some templating going on in

omslib = os.path.join(dirname, "@OMSIMULATOR_PYTHON_RELATIVE_DLL_DIR@", "@OMSIMULATORLIB_STRING@")

I'm guessing this is replaced during packaging the pip package, building the OMEdit installer or at install time? Something going wrong with OMSIMULATOR_PYTHON_RELATIVE_DLL_DIR, maybe here:
## If OMSimulator is being built as part of OpenModelica and that is set by "OPENMODELICA_NEW_CMAKE_BUILD"
## account for the "omc" directory added in the lib dir (lib/omc/OMSimulator versus lib/OMSimulator)
## currently this sets the path only for windows
## TODO fix the paths for linux
if(OPENMODELICA_NEW_CMAKE_BUILD)
set(OMSIMULATOR_PYTHON_RELATIVE_DLL_DIR "../../../bin")
else()
set(OMSIMULATOR_PYTHON_RELATIVE_DLL_DIR "../../bin")
endif()
?
It looks to me like OPENMODELICA_NEW_CMAKE_BUILD could not be set when generating the nightly installer that I used?

@arun3688
Copy link
Contributor Author

@bilderbuchi Aha i see that i have complied omc via cmake and i guess the nightly builds still uses the makefile to compile the omc, i did not realize this, For now in your capi.py just change to this omslib = os.path.join(dirname, "../../../bin", "libOMSimulator.dll") and it should work fine i will fix the cmake file

@bilderbuchi
Copy link

For now in your capi.py just change to this omslib = os.path.join(dirname, "../../../bin", "libOMSimulator.dll") and it should work fine i will fix the cmake file

Yes, that's what I did. Thanks!

@bilderbuchi
Copy link

i will fix the cmake file

Should I create a separate ticket for tracking this, does that help you?

@arun3688
Copy link
Contributor Author

@bilderbuchi it would be good if you can create a seperate ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants