hydrogeoscience / pygtide

A Python module and wrapper for ETERNA PREDICT to compute gravitational tides on Earth
Mozilla Public License 2.0
50 stars 19 forks source link

Installable package #2

Closed onewhaleid closed 5 years ago

onewhaleid commented 5 years ago

This pull request makes pygtide an installable package, using:

git clone https://github.com/hydrogeoscience/pygtide.git
cd pygtide
pip install .

or simply

pip install git+https://github.com/hydrogeoscience/pygtide.git

Windows DLLs for python 3.7 have been added, along with Linux and Mac OS shared objects for python 3.6 and 3.7.

File paths have been updated to make them platform independent.

jnsebgosselin commented 5 years ago

Which compilers did you use to build the extension for Python 3.7 on Windows? Would it be possible to build it using static linking so that we don't need to actually install the compilers to use the package?

I haven't been able to import your etpred extension for Python 3.7 and Windows yet on my system. I always end up with the following error:

ImportError: DLL load failed: The specified module could not be found.

onewhaleid commented 5 years ago

I used f2py to create the windows DLL. I think it used mingw.

@hydrogeoscience knows more about FORTRAN compilers than I do.

jnsebgosselin commented 5 years ago

Ok thanks

Using your branch, I haven't been able to run pygtide successfully on Python 3.7 yet. I'm missing some shared libraries and it is difficult to know which one without knowing exactly which compilers were used to build the extension (f2py can be used with different compilers). I'll still continue to investigate and report back if I succeed.

However, I'm a able to run it in Python 3.6. Looking at the difference of size of the etpred extensions for Pythons 3.6 and 3.7, my guess is that the 3.6 one was compiled with some flags to statically link some of the libraries. So that is why it is working in 3.6 and not in 3.7.

As I have mentioned, in Issue #3, the best would be to provide the modified ETERNA PREDICT Fortran source code (if this is possible) so that it would be possible to compile the etpred extension with python setup.py build_ext instead of distributing the compiled extensions along with the source code.

trichter commented 5 years ago

Hi, I tried to run your branch of pygtide on Linux with conda installed Python 3.6.

First I created symlinks for the files in commdat folder, because the file names seem to be hardcoded with windows path separators in the fortran code:

for file in `ls commdat`
do
  ln -s commdat/$file commdat\\$file
done

The initialization pt = pygtide.pygtide() was successful with this hack. Unfortunately, now it errors at the pt.predict() call:

$ python test.py
ETERNA PREDICT v3.4 (10/02/2013) is calculating, please wait ...
At line 421 of file etpred.f90 (unit = 11, file = '�<�&�~')
Fortran runtime error: File 'NUL' does not exist

Do you have an idea what is going wrong?

hydrogeoscience commented 5 years ago

Hello, thanks for your interest. Yes, this has been optimised for Windows only. I am working on a Linux and Mac OS version.

trichter commented 5 years ago

:thumbsup: Thanks for your efforts.

Fyi, I got one step further, by creating another symlink from NUL to /dev/null (this could be fixed in the source by a precompiler).

Now, there is another problem:

ETERNA PREDICT v3.4 (10/02/2013) is calculating, please wait ...
corrupted size vs. prev_size
Aborted (core dumped)

Edit: If the arguments passed to pt.predict are changed in test.py it's working for me now.