设置.pym上的安装文件

2024-05-13 03:31:02 发布

您现在位置:Python中文网/ 问答频道 /正文

但我不想在mac操作系统上安装neuron脚本

首先我试着做了这个按摩:

tittorento:nrnpython Dani$ python setup.py install --with-nrnpython=dynamic
  File "setup.py", line 79
    = [ epre+libdirs[0],epre+libdirs[1] ],
    ^
SyntaxError: invalid syntax

对应代码:

^{pr2}$

如果我把那句话注释掉,它会说:

tittorento:nrnpython Dani$ python setup.py install --with-nrnpython=dynamic
Error:
NEURON configure time python:   
Python presently executing setup.py: /usr/local/opt/python/bin/python2.7   2.7
These do not match, and they should!

我不知道该怎么办。我需要为我的科学工作设置这个模块。在

给出此错误的代码如下:

#setup.py
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_version

import sys
import os

# NRNPYTHON_DEFINES which were enabled at configure time
extern_defines = ""
nrnpython_exec = ""
nrnpython_pyver = ""
nrn_srcdir = "."
build_rx3d = 0
ivlibdir = "/Applications/NEURON-7.3/iv/x86_64/lib"
if ivlibdir == "" :
    ivlibdir = '.'

destdir = os.getenv("DESTDIR")
if not destdir:
  destdir = ""

instdir = destdir + "/Applications/NEURON-7.3/iv"
if nrn_srcdir[0] != '/' :
    nrn_srcdir = '../../' + nrn_srcdir

if nrnpython_pyver!=get_python_version():
    print "Error:"
    print "NEURON configure time python: "+nrnpython_exec+"  "+ nrnpython_pyver
    print "Python presently executing setup.py: "+sys.executable+"   "+ get_python_version()
    print "These do not match, and they should!"
    sys.exit(1)


ldefs = extern_defines.split('-D')

# if using MPI then at least for linking need special paths and libraries
mpicc_bin = "gcc"
mpicxx_bin = "g++"
import os
os.environ["CC"]=mpicc_bin
os.environ["CXX"]=mpicxx_bin

# apparently we do not need the following
#################################
## following http://code.google.com/p/maroonmpi/wiki/Installation
## hack into distutils to replace the compiler in "linker_so" with mpicxx_bin
#
#import distutils
#import distutils.unixccompiler
#
#class MPI_UnixCCompiler(distutils.unixccompiler.UnixCCompiler):
#    __set_executable = distutils.unixccompiler.UnixCCompiler.set_executable
#
#    def set_executable(self,key,value):
#   print "MPI_UnixCCompiler ", key, " | ", value
#        if key == 'linker_so' and type(value) == str:
#            value = mpicxx_bin + ' ' + ' '.join(value.split()[1:])
#
#        return self.__set_executable(key,value)
#    
#distutils.unixccompiler.UnixCCompiler = MPI_UnixCCompiler
#################################

include_dirs = [nrn_srcdir+'/src/oc', '../oc', nrn_srcdir+'/src/nrnmpi']
defines = []

libdirs = [destdir + "/Applications/NEURON-7.3/iv/x86_64/lib",
  ivlibdir
]
epre='-Wl,-R'



hoc_module = Extension(
      "neuron.hoc",
      ["inithoc.cpp"],
      #library_dirs=libdirs,
      #= [ epre+libdirs[0],epre+libdirs[1] ],
      #extra_objects = [],

      libraries = [
    "nrnpython",
        "nrnoc", "oc", "nrniv", "ivoc",
        "memacs",
    "meschach", "neuron_gnu",
    "nrnmpi",
        "scopmath", "sparse13", "sundials",
    "readline",
    "IVhines",
      ],
      include_dirs = include_dirs,
      define_macros=defines
    )

# specify that the data_files paths are relative to same place as python files
# from http://stackoverflow.com/questions/1612733/including-non-python-files-with-setup-py
from distutils.command.install import INSTALL_SCHEMES
for scheme in INSTALL_SCHEMES.values():
    scheme['data'] = scheme['purelib']

ext_modules = [hoc_module]
if build_rx3d:
  try:
    import numpy
    # TODO: do we need to use os.path.join?
    src_path = nrn_srcdir + '/share/lib/python/neuron/rxd/geometry3d/'
    build_path = '../../share/lib/python/neuron/rxd/geometry3d/'
    include_dirs = [nrn_srcdir + '/share/lib/python/neuron/rxd/geometry3d', '.', numpy.get_include()]
    ext_modules=[hoc_module,
                   Extension("neuron.rxd.geometry3d.graphicsPrimitives",
                             sources=[build_path + "graphicsPrimitives.cpp"],
                             include_dirs=include_dirs),
                   Extension("neuron.rxd.geometry3d.ctng",
                             sources=[build_path + "ctng.cpp"],
                             include_dirs=include_dirs),
                   Extension("neuron.rxd.geometry3d.surfaces",
                             sources=[build_path + "surfaces.cpp", src_path + "marching_cubes2.c", src_path + "llgramarea.c"],
                             include_dirs=include_dirs)]    
  except:
    pass

packages=['neuron','neuron.neuroml','neuron.tests', 'neuron.rxd']
if build_rx3d:
  packages +=['neuron.rxd.geometry3d']

setup(name="NEURON", version="7.4",
      description = "NEURON bindings for python",
      package_dir = {'':instdir+'/share/nrn/lib/python'},
      packages=packages,
      data_files = [('neuron', [nrn_srcdir + '/share/lib/python/neuron/help_data.dat'])],
      ext_modules=ext_modules
)

Tags: pathpyimportifbinincludesetupdirs
1条回答
网友
1楼 · 发布于 2024-05-13 03:31:02

我认为本安装指南非常好,适用于os x: http://labrigger.com/blog/2012/08/30/getting-neuron-to-run-on-os-x-with-python-support/

也许你在调用install命令之前忘了构建模块?在

编辑:我建议使用工具“pip”来安装模块和软件包,但是2012年的一篇文章说,neuron不能通过pip在osx上使用,而是可以在windows和linux上使用。这篇文章已经发布了三年了,所以现在可能OSX已经被支持了。在

相关问题 更多 >