2016-02-09 56 views
0

我試圖安裝一個名爲mtspec的python包,它是一些Fortran 90代碼的包裝。 (鏈接:https://pypi.python.org/pypi/mtspec)。然而,這個軟件包相當老舊(2010年最後一次更新),並且我無法使setup.py腳本在Mac OSX 10.10.5上正確編譯代碼。由於distutils中的一些明顯變化,我不得不自己破解setup.py腳本。原來,在setup.py 48行是這樣的:「movq」的後綴或操作數無效的原因是什麼?

from distutils.unixccompiler import UnixCCompiler, _darwin_compiler_fixup 

我改成

from distutils.unixccompiler import UnixCCompiler#, _darwin_compiler_fixup 
from _osx_support import compiler_fixup as _darwin_compiler_fixup 

沒有這一點,只需setup.py引發異常cannot import name _darwin_compiler_fixup。我對distutils瞭解不多,所以請告訴我,如果這是錯誤的。但是在更改之後,它至少會嘗試編譯代碼。然而,現在gfortran拋出以下錯誤:

/var/folders/vt/9jwlypbs5rz8hy6d_h02pg8xg967kg/T//ccm4Gy5y.s:25:suffix or operands invalid for `movq' 
/var/folders/vt/9jwlypbs5rz8hy6d_h02pg8xg967kg/T//ccm4Gy5y.s:27:suffix or operands invalid for `movq' 
/var/folders/vt/9jwlypbs5rz8hy6d_h02pg8xg967kg/T//ccm4Gy5y.s:28:suffix or operands invalid for `movq' 
/var/folders/vt/9jwlypbs5rz8hy6d_h02pg8xg967kg/T//ccm4Gy5y.s:34:suffix or operands invalid for `movq' 
/var/folders/vt/9jwlypbs5rz8hy6d_h02pg8xg967kg/T//ccm4Gy5y.s:79:suffix or operands invalid for `movq' 
/var/folders/vt/9jwlypbs5rz8hy6d_h02pg8xg967kg/T//ccm4Gy5y.s:115:suffix or operands invalid for `movq' 

我不是很有經驗的Fortran語言,所以我不知道這意味着什麼,以及在計算器上和谷歌搜索還沒有止跌回升的任何解決問題的對策。我在另一個網站上看到的一個建議(不記得我在哪看到的)建議刪除-O編譯器標誌,但這會使問題變得更糟;錯誤更頻繁地拋出。運行setup.pyconda虛擬環境也沒有幫助。在這一點上我不知道該怎麼做。我之前已經在Cray Linux和Red Hat Linux上安裝了這個軟件包,通過簡單地註釋掉所有對Darwin的引用(setup.py;這只是Mac給我帶來的麻煩。

萬一有幫助,這裏的代碼setup.py了配置編譯塊:

from distutils.unixccompiler import UnixCCompiler#, _darwin_compiler_fixup 
from _osx_support import compiler_fixup as _darwin_compiler_fixup 
# Monkey patch UnixCCompiler for Unix, Linux and darwin 
UnixCCompiler.src_extensions.append(".f90") 
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): 
     compiler_so = self.compiler_so 
     if sys.platform == 'darwin': 
      compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) 
     if ext == ".f90": 
      if sys.platform == 'darwin' or sys.platform == 'linux2': 
       compiler_so = ["gfortran"] 
       cc_args = ["-O", "-fPIC", "-c", "-ffree-form"] 
     try: 
      self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) 
     except DistutilsExecError, msg: 
      raise CompileError, msg 
UnixCCompiler._compile = _compile 
# set library dir for mac and linux 
libs=['gfortran'] 
+1

這些錯誤不是Fortran錯誤,而是程序集錯誤。注意後綴'.s'而不是'.f90'。 –

回答

4

因爲你提到它只是在Mac上造成麻煩。難道你的機器上安裝了macports和homebrew?

我碰到了同樣的錯誤編譯一個不同的庫,以下鏈接解決了這個問題對我來說:https://github.com/Homebrew/legacy-homebrew/issues/45258

移除的MacPorts(例如須藤MV /選擇/本地〜/ macport)一切正常後。

相關問題