Loop3D / LoopStructural

LoopStructural is an open-source 3D structural geological modelling library.
MIT License
178 stars 35 forks source link

[BUG] surfepy install #59

Closed awickert closed 3 years ago

awickert commented 3 years ago

I attempted to run https://github.com/Loop3D/LoopStructural/blob/master/examples/1_basic/example_surfe.py.

The system the noted that I did not have surfe. Should this be made a dependency?

My attempts to pip3 install surfepy failed, and then I noticed that it is prepared only for Windows: https://pypi.org/project/surfepy/0.32/#files

Would it be possible to generate a cross-platform release?

lachlangrose commented 3 years ago

Hi, I'm working on it but I am having issues with the building the wheel. It will work if you clone the loop3d/surfe repository and pip install .

I will try and get either a conda or pip compiled version to work in the future.

Cheers

lachlangrose commented 3 years ago

possible causes may be related to r path - https://github.com/pypa/auditwheel/issues/29

awickert commented 3 years ago

I cloned and tried to build after a quick pip3 install scikit-build.

I received an error with the key lines (I think) being:

    CMake Error at CMakeLists.txt:37 (add_subdirectory):
      The source directory

        /tmp/pip-req-build-osqhi9u1/pybind11

      does not contain a CMakeLists.txt file.

I do have pybind11 installed. But there is no directory pip-req-build-osqhi9u1 within /tmp/ on my computer.

This is the full error dump (sorry but better to have more info?):

andy@cuesta:~/dataanalysis/surfe$ pip3 install .
Defaulting to user installation because normal site-packages is not writeable
Processing /home/andy/dataanalysis/surfe
Building wheels for collected packages: surfepy
  Building wheel for surfepy (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-osqhi9u1/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-osqhi9u1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-uwbb2yej
       cwd: /tmp/pip-req-build-osqhi9u1/
  Complete output (101 lines):
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extra_objects'
    warnings.warn(msg)

  --------------------------------------------------------------------------------
  -- Trying "Ninja" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  -- The C compiler identification is GNU 9.3.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- The CXX compiler identification is GNU 9.3.0
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /tmp/pip-req-build-osqhi9u1/_cmake_test_compile/build
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Ninja" generator - success
  --------------------------------------------------------------------------------

  Configuring Project
    Working directory:
      /tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-build
    Command:
      cmake /tmp/pip-req-build-osqhi9u1 -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-install/surfepy -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPYTHON_VERSION_STRING:STRING=3.8.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so -DSKBUILD:BOOL=TRUE -DCMAKE_MODULE_PATH:PATH=/home/andy/.local/lib/python3.8/site-packages/skbuild/resources/cmake -DEIGEN3_INCLUDE_DIR=eigen-git-mirror '-DCMAKE_INSTALL_RPATH="$ORIGIN/../lib:$ORIGIN/../..' -DCMAKE_BUILD_TYPE:STRING=Release

  -- The C compiler identification is GNU 9.3.0
  -- The CXX compiler identification is GNU 9.3.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found OpenMP_C: -fopenmp (found version "4.5")
  -- Found OpenMP_CXX: -fopenmp (found version "4.5")
  -- Found OpenMP: TRUE (found version "4.5")
  CMake Error at cmake/FindEigen3.cmake:33 (file):
    file failed to open for reading (No such file or directory):

      /tmp/pip-req-build-osqhi9u1/eigen-git-mirror/Eigen/src/Core/util/Macros.h
  Call Stack (most recent call first):
    cmake/FindEigen3.cmake:59 (_eigen3_check_version)
    CMakeLists.txt:17 (find_package)

  CMake Error at CMakeLists.txt:37 (add_subdirectory):
    The source directory

      /tmp/pip-req-build-osqhi9u1/pybind11

    does not contain a CMakeLists.txt file.

  CMake Error at CMakeLists.txt:39 (pybind11_add_module):
    Unknown CMake command "pybind11_add_module".

  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-build/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "/home/andy/.local/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 582, in setup
      env = cmkr.configure(cmake_args,
    File "/home/andy/.local/lib/python3.8/site-packages/skbuild/cmaker.py", line 229, in configure
      raise SKBuildError(

  An error occurred while configuring with CMake.
    Command:
      cmake /tmp/pip-req-build-osqhi9u1 -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-install/surfepy -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPYTHON_VERSION_STRING:STRING=3.8.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so -DSKBUILD:BOOL=TRUE -DCMAKE_MODULE_PATH:PATH=/home/andy/.local/lib/python3.8/site-packages/skbuild/resources/cmake -DEIGEN3_INCLUDE_DIR=eigen-git-mirror '-DCMAKE_INSTALL_RPATH="$ORIGIN/../lib:$ORIGIN/../..' -DCMAKE_BUILD_TYPE:STRING=Release
    Source directory:
      /tmp/pip-req-build-osqhi9u1
    Working directory:
      /tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-build
  Please see CMake's output for more information.
  ----------------------------------------
  ERROR: Failed building wheel for surfepy
  Running setup.py clean for surfepy
Failed to build surfepy
Installing collected packages: surfepy
    Running setup.py install for surfepy ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-osqhi9u1/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-osqhi9u1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-pckl8b16/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/andy/.local/include/python3.8/surfepy
         cwd: /tmp/pip-req-build-osqhi9u1/
    Complete output (101 lines):
    /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extra_objects'
      warnings.warn(msg)

    --------------------------------------------------------------------------------
    -- Trying "Ninja" generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    -- The C compiler identification is GNU 9.3.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- The CXX compiler identification is GNU 9.3.0
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/pip-req-build-osqhi9u1/_cmake_test_compile/build
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying "Ninja" generator - success
    --------------------------------------------------------------------------------

    Configuring Project
      Working directory:
        /tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-build
      Command:
        cmake /tmp/pip-req-build-osqhi9u1 -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-install/surfepy -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPYTHON_VERSION_STRING:STRING=3.8.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so -DSKBUILD:BOOL=TRUE -DCMAKE_MODULE_PATH:PATH=/home/andy/.local/lib/python3.8/site-packages/skbuild/resources/cmake -DEIGEN3_INCLUDE_DIR=eigen-git-mirror '-DCMAKE_INSTALL_RPATH="$ORIGIN/../lib:$ORIGIN/../..' -DCMAKE_BUILD_TYPE:STRING=Release

    -- The C compiler identification is GNU 9.3.0
    -- The CXX compiler identification is GNU 9.3.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found OpenMP_C: -fopenmp (found version "4.5")
    -- Found OpenMP_CXX: -fopenmp (found version "4.5")
    -- Found OpenMP: TRUE (found version "4.5")
    CMake Error at cmake/FindEigen3.cmake:33 (file):
      file failed to open for reading (No such file or directory):

        /tmp/pip-req-build-osqhi9u1/eigen-git-mirror/Eigen/src/Core/util/Macros.h
    Call Stack (most recent call first):
      cmake/FindEigen3.cmake:59 (_eigen3_check_version)
      CMakeLists.txt:17 (find_package)

    CMake Error at CMakeLists.txt:37 (add_subdirectory):
      The source directory

        /tmp/pip-req-build-osqhi9u1/pybind11

      does not contain a CMakeLists.txt file.

    CMake Error at CMakeLists.txt:39 (pybind11_add_module):
      Unknown CMake command "pybind11_add_module".

    -- Configuring incomplete, errors occurred!
    See also "/tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-build/CMakeFiles/CMakeOutput.log".
    Traceback (most recent call last):
      File "/home/andy/.local/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 582, in setup
        env = cmkr.configure(cmake_args,
      File "/home/andy/.local/lib/python3.8/site-packages/skbuild/cmaker.py", line 229, in configure
        raise SKBuildError(

    An error occurred while configuring with CMake.
      Command:
        cmake /tmp/pip-req-build-osqhi9u1 -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-install/surfepy -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPYTHON_VERSION_STRING:STRING=3.8.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so -DSKBUILD:BOOL=TRUE -DCMAKE_MODULE_PATH:PATH=/home/andy/.local/lib/python3.8/site-packages/skbuild/resources/cmake -DEIGEN3_INCLUDE_DIR=eigen-git-mirror '-DCMAKE_INSTALL_RPATH="$ORIGIN/../lib:$ORIGIN/../..' -DCMAKE_BUILD_TYPE:STRING=Release
      Source directory:
        /tmp/pip-req-build-osqhi9u1
      Working directory:
        /tmp/pip-req-build-osqhi9u1/_skbuild/linux-x86_64-3.8/cmake-build
    Please see CMake's output for more information.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-osqhi9u1/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-osqhi9u1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-pckl8b16/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/andy/.local/include/python3.8/surfepy Check the logs for full command output.
lachlangrose commented 3 years ago

Hi,

Pybind11 and Eigen are submodules of the surfe repository, if you use git submodule update --init --recursive it should clone the repos and they will work. Thinking about it I could actually add this into the setup.py file.

Good luck!

awickert commented 3 years ago

Ah, perfect! Yes, sorry that I didn't think to check for submodules. Successfully built locally!

I am now down to an error on import, but I think that this is something that could be solved by bundling for pip and that the solution is quite close at hand:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-edc635b4bf7a> in <module>
----> 1 import surfepy

~/.local/lib/python3.8/site-packages/surfepy/__init__.py in <module>
      2 # add the installation folder to the path so that the c++ libs can be used
      3 sys.path.append(os.path.dirname(__file__))
----> 4 from ._surfepy import *
      5 __version__ = '0.32'

ModuleNotFoundError: No module named 'surfepy._surfepy'
lachlangrose commented 3 years ago

Are you running python inside the folder you installed surfepy in? If so its because the init.py file in the surfepy is loaded rather than the installed version. It means it can't find the object because it expects to find it in the same directory. Linking c++ and python code smoothly is difficult!

awickert commented 3 years ago

I have the same error no matter where I run Python. But I also think that debugging my specific C++/Python linking with your code might not be the best use of our time! At very least, you're aware of the "surfepy" installation issues as relates to LoopStructural.

Perhaps we could close this and open a related issue at the surfe repository? I'm also trying to keep my comments here focused within the scope of the GMD paper. I don't always go to GitHub for the papers I'm editing, and I don't want to start branching outside of the scope of your submission.

lachlangrose commented 3 years ago

That sounds good, I can move this issue to surfe. Out of interest are you using anaconda?

It is definitely an issue that I am trying to solve, but the best solution I have currently is to use docker.

lachlangrose commented 3 years ago

Actually, I can't transfer it so will close and open a new issue