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

Python bindings: Unresolved symbols #3964

Closed
jmarrec opened this issue May 4, 2020 · 13 comments · Fixed by #4122
Closed

Python bindings: Unresolved symbols #3964

jmarrec opened this issue May 4, 2020 · 13 comments · Fixed by #4122

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented May 4, 2020

Issue overview

This expands on #3961 fixed by #3963 which specifically only dealt with the broken build itself.

Now that the python bindings are built properly, they still don't work.

Current Behavior

Using #3963 :

(py38)julien@python (3961_Python_zlib *+%>)$ pwd
/home/julien/Software/Others/OpenStudio/python
(py38)julien@python (3961_Python_zlib *%=)$ PYTHONPATH=~/Software/Others/OS-build-release/Products/python/:~/Software/Others/OS-build-release/Products/:~/Software/Others/OS-build-release/python_wrapper/generated_sources/ python testpath.py 
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudioairflow.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudioenergyplus.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudiogbxml.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudioisomodel.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudiomeasure.so: undefined symbol: _ZTVN10openstudio5model5ModelE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudiomodel.so: undefined symbol: _ZTIN10openstudio9WorkspaceE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudioosversion.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudioradiance.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
ImportError: /home/julien/Software/Others/OS-build-release/Products/python/_openstudiosdd.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
Traceback (most recent call last):
  File "testpath.py", line 4, in <module>
    print(openstudio.toString(openstudio.runmanager.RunManager().dbPath()))
AttributeError: module 'openstudio_dynamic' has no attribute 'toString

Expected Behavior

The bindings should work

Steps to Reproduce

Build with -DBUILD_PYTHON_BINDINGS:BOOL=ON. I use Python 3.8 from a virtual env myself.
Now try to run the above command.

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version):
  • Version of OpenStudio (if using an intermediate build, include SHA):

Context

@ghost
Copy link

ghost commented May 4, 2020

The problem starts in configuring step


damian@damian-hp:~/OpenStudio-3.0.0-zlib/build$ cmake .. -DBUILD_PYTHON_BINDINGS=ON -DPYTHON_EXECUTABLE=/usr/bin/python3.6m -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so -DCMAKE_INSTALL_PREFIX=/usr/local/openstudio-3.0.0-python3.6


WARN: openstudio_ruby/2.5.5@nrel/stable: requirement zlib/1.2.11 overridden by your conanfile to zlib/1.2.11@nrel/testing 
WARN: boost/1.71.0: requirement zlib/1.2.11 overridden by your conanfile to zlib/1.2.11@nrel/testing 
WARN: cpprestsdk/2.10.14@bincrafters/stable: requirement openssl/1.1.1d overridden by your conanfile to openssl/1.1.0l 
WARN: cpprestsdk/2.10.14@bincrafters/stable: requirement zlib/1.2.11 overridden by your conanfile to zlib/1.2.11@nrel/testing 
WARN: websocketpp/0.8.1@bincrafters/stable: requirement openssl/1.1.1d overridden by cpprestsdk/2.10.14@bincrafters/stable to openssl/1.1.0l 
WARN: websocketpp/0.8.1@bincrafters/stable: requirement zlib/1.2.11 overridden by cpprestsdk/2.10.14@bincrafters/stable to zlib/1.2.11@nrel/testing 
cpprestsdk/2.10.14@bincrafters/stable: WARN: Can't update, no package in remote


-- Configuring done
-- Generating done
-- Build files have been written to: /home/damian/OpenStudio-3.0.0-zlib/build


Mismatched libraries

Thank you

@jmarrec
Copy link
Collaborator Author

jmarrec commented May 4, 2020

That's just a warning and shouldn't pose problems, as you can see "Generating done".

I opened a PR upstream to conan zlib for this anyways conan-io/conan-center-index#1526

@mcneillj
Copy link

mcneillj commented May 11, 2020

It would be very helpful to have these bindings work. I have a number of workflows that use the Python bindings in Jupyter, but these won't work with latest version of OS. This causes me to look for other solutions, but OS bindings in Python is my preferred solution. Hoping this can be solved in a future version. Otherwise, I think it's best to note the lack of support for Python in the wiki and documentation.

@tijcolem tijcolem added this to Current Backlog in OpenStudio May 29, 2020
@tijcolem tijcolem added this to the OpenStudio SDK 3.1.0 milestone Jul 10, 2020
@tijcolem tijcolem removed this from the OpenStudio SDK 3.1.0 milestone Aug 7, 2020
@jmarrec
Copy link
Collaborator Author

jmarrec commented Oct 6, 2020

Please note that the bindings actually work when installed. They aren't working right now inside the build folder.

@ghost
Copy link

ghost commented Oct 11, 2020

Thank you very much @jmarrec
I will find time to test them, from the installation folder, although I am currently using direct connection in c +
Good night

@ghost
Copy link

ghost commented Oct 13, 2020

develop

damian@damian-HP:~$ conan --version
Conan version 1.28.0
damian@damian-HP:~$ g++ -v
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
/home/damian/cmake-3.17.3-Linux-x86_64/bin/cmake ../openstudio -DBUILD_PYTHON_BINDINGS=ON -DBUILD_RUBY_BINDINGS=OFF -DCMAKE_INSTALL_PREFIX=/home/damian/openstudio-python-install
CMake Error at cmake_install.cmake:137 (file):
  file INSTALL cannot find
  "/home/damian/openstudio-python-build/openstudio-gems/Gemfile": No such
  file or directory.


Makefile:105: fallo en las instrucciones para el objetivo 'install'
make: *** [install] Error 1
Python 3.6.9 (default, Jul 17 2020, 12:50:27) 
[GCC 8.4.0] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> Gui.runCommand('Std_Workbench',17)
>>> Gui.runCommand('Std_ViewStatusBar',1)
>>> import sys
>>> sys.path.append('/home/damian/openstudio-python-install/Python')
>>> import openstudio
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/damian/openstudio-python-install/Python/openstudio.py", line 41, in <module>
    import openstudioairflow as airflow
  File "/home/damian/openstudio-python-install/Python/openstudioairflow.py", line 15, in <module>
    import _openstudioairflow
ImportError: /home/damian/openstudio-python-install/Python/_openstudioairflow.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
>>> 

@ghost
Copy link

ghost commented Oct 13, 2020

-DBUILD_RUBY_BINDINGS=ON -DBUILD_CLI=ON
>>> import openstudio
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/damian/openstudio-python-install/Python/openstudio.py", line 41, in <module>
    import openstudioairflow as airflow
  File "/home/damian/openstudio-python-install/Python/openstudioairflow.py", line 15, in <module>
    import _openstudioairflow
ImportError: /home/damian/openstudio-python-install/Python/_openstudioairflow.so: undefined symbol: _ZTIN10openstudio5model11ModelObjectE
>>> 

@jmarrec
Copy link
Collaborator Author

jmarrec commented Oct 14, 2020

You're having a completely different error it seems?

CMake Error at cmake_install.cmake:137 (file):
  file INSTALL cannot find
  "/home/damian/openstudio-python-build/openstudio-gems/Gemfile": No such
  file or directory.

Anyways, if you want to play with python bindings right now, I'm toying with making a pip package. I have wheels ready for Linux, and for Windows (python 3.7 / 3.8). You do not need to compile openstudio or even have openstudio installed, it's self contained. Install via pip install -i https://test.pypi.org/simple/ openstudio==3.1.0rc8 (note: I'm succeptible of pulling this version at any time, no guarantee given there)

pip uninstall openstudio && pip install -i https://test.pypi.org/simple/ openstudio==3.1.0rc8

In [1]: import openstudio
In [2]: m = openstudio.model.Model()
In [3]: s = openstudio.model.Space(m)
In [4]: print(m)
OS:Version,
  {35a358d8-9513-4e6e-8961-63685c0dbede}, !- Handle
  3.1.0,                                  !- Version Identifier
  rc3;                                    !- Prerelease Identifier
OS:Space,
  {f775b395-fa6d-4cee-8ee7-c7077fc7dc1e}, !- Handle
  Space 1;                                !- Name

@ghost
Copy link

ghost commented Oct 15, 2020

The install error was because I specified -DBUILD_RUBY_BINDINGS=OFF

I'm interested in these python bindings, of course. Thank you.

@jmarrec
Copy link
Collaborator Author

jmarrec commented Oct 15, 2020

@damianCaceres If you are on linux, use pip install -i https://test.pypi.org/simple/ openstudio==3.1.0rc9

I built the rc8 on python 3.9 and realized after trying to install them on a python3.8 machine that there is ABI breakage. With rc9 I built them on python3.8 and tested that they work on both py38 and py39

Do not mind the rc9... in fact these are the current develop, so openstudio sdk 3.1.0-rc4. It's just that everytime I notice an issue with my testpypi, I have to create a new release because I cannot overwrite anything

@ghost
Copy link

ghost commented Oct 17, 2020

Well, I'm especially interested in the package, but more for the pypi wheel with compiled code you have made than for the bindings themselves. I'm introducing in pypi technology.
Of course I've the web direction with the available versions, and I'll follow it regularly.
Thanks.

@ghost
Copy link

ghost commented Oct 17, 2020

(openstudio) damian@damian-HP:~$ pip3.8 install -i https://test.pypi.org/simple openstudio==3.1.0rc9
Looking in indexes: https://test.pypi.org/simple
Collecting openstudio==3.1.0rc9
Downloading https://test-files.pythonhosted.org/packages/61/18/82d917c5467924160fa1cba88c04df02c868a7447ffa897d609c8031186c/openstudio-3.1.0rc9-py3-none-manylinux1_x86_64.whl (59.1 MB)
|████████████████████████████████| 59.1 MB 133 kB/s
Installing collected packages: openstudio
Successfully installed openstudio-3.1.0rc9

@ghost
Copy link

ghost commented Oct 22, 2020

bindings
I can see also the shared libraries there. I'll test them.
Thank you.

@tijcolem tijcolem moved this from Current Backlog to Ready to Test in OpenStudio Oct 30, 2020
OpenStudio automation moved this from Ready to Test to Done Nov 3, 2020
tijcolem added a commit that referenced this issue Nov 3, 2020
Fix #3964 - Adjustments to python bindings and produce a pypi package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
OpenStudio
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants