krischer / mtspec

Python library for multitaper spectral estimations
http://krischer.github.io/mtspec/
GNU General Public License v3.0
69 stars 44 forks source link

Compile on debian 11 with python 3.9 and gcc10 #37

Open marcelobianchi opened 2 years ago

marcelobianchi commented 2 years ago

I was not able to compile it on a Debian 11 with plain python 3.9 and gcc10. The first issue is a type mismatch on GCC and the second issue is the order to compile the Fortran files. The spectra.f90 should be the first one to be compiled but distutils does not respect that.

Solutions:

  1. Add the option -fallow-argument-mismatch" to the compile flag.
  2. Create a secondary fake library to force distutil to compile spectra.f90 first (this is hackish) but point me to the solution.

What I did to get it installed and compiled in a pretty hackish manner, don't recommend to anyone, but pointing to what should be properly done on distutils:

stavanger:~/mtspec$ git diff
diff --git a/setup.py b/setup.py
index b7ac047..d6ddbd3 100644
--- a/setup.py
+++ b/setup.py
@@ -141,10 +141,20 @@ if arch_flag:
 else:
     extra_link_args = None

+liba = MyExtension('mtspeca',
+                  libraries=["gfortran"],
+                  library_dirs=get_libgfortran_dir(),
+                  extra_link_args=extra_link_args,
+                  extra_compile_args = ["-fallow-argument-mismatch"],
+                  sources=[
+                      src + 'spectra.f90'])
+
+
 lib = MyExtension('mtspec',
                   libraries=["gfortran"],
                   library_dirs=get_libgfortran_dir(),
                   extra_link_args=extra_link_args,
+                  extra_compile_args = ["-fallow-argument-mismatch"],
                   sources=[
                       src + 'spectra.f90', src + 'adaptspec.f90',
                       src + 'atanh2.f90',
@@ -187,7 +197,7 @@ setup_config = dict(
         'tests': ['flake8>=3']
     },
     ext_package='mtspec.lib',
-    ext_modules=[lib],
+    ext_modules=[liba, lib],
     classifiers=[
         'Development Status :: 4 - Beta',
         'Environment :: Console',