def amusifier(): uc = ParseCommandLine() uc.start() if uc.options.get_amuse_dir: print(get_amuse_root_dir()) exit(0) elif uc.options.get_amuse_configmk: with open(os.path.join(get_amuse_root_dir(), "config.mk")) as f: print(f.read()) exit(0) elif uc.options.mode == 'dir': make_directory(uc) else: make_file(uc)
def amusifier(): uc = ParseCommandLine() uc.start() if uc.options.get_amuse_dir: print((get_amuse_root_dir())) exit(0) elif uc.options.mode == 'dir': make_directory(uc) else: make_file(uc)
def get_amuse_root_dir(): return get_amuse_root_dir()
def finalize_options(self): self.set_undefined_options( 'build', ('build_lib', 'build_lib'), ('build_temp', 'build_temp'), ('debug', 'debug'), ('force', 'force'), ) self.config = None if supportrc["framework_install"]: try: from . import config self.config = config except ImportError: # continue pass else: from amuse import config self.config = config if self.codes_dir is None: if self.inplace: self.codes_dir = os.path.join(self.amuse_src_dir, 'community') self.codes_src_dir = self.codes_dir else: #~ self.codes_dir = os.path.join(self.build_temp, 'src', 'amuse', 'community') self.codes_dir = os.path.join(self.build_temp, 'codes') self.codes_src_dir = os.path.join(self.amuse_src_dir, 'community') else: if self.inplace: self.codes_src_dir = self.codes_dir else: self.codes_src_dir = self.codes_dir #~ self.codes_dir=os.path.join(self.build_temp, 'src', 'amuse', 'community') self.codes_dir = os.path.join(self.build_temp, 'codes') if self.lib_dir is None: if self.inplace: self.lib_dir = os.path.join('lib') self.lib_src_dir = self.lib_dir else: self.lib_dir = os.path.join(self.build_temp, 'lib') self.lib_src_dir = os.path.join('lib') else: if self.inplace: self.lib_src_dir = self.codes_dir else: self.lib_src_dir = self.codes_dir self.lib_dir = os.path.join(self.build_temp, 'lib') if self.config: self.environment['PYTHON'] = self.config.interpreters.python else: self.environment['PYTHON'] = sys.executable self.set_cuda_variables() self.set_mpi_variables() self.set_compiler_variables() self.set_fortran_variables() if 'FORTRAN' in self.environment: self.environment['F90'] = self.environment['FORTRAN'] self.environment['FC'] = self.environment['FORTRAN'] self.set_java_variables() self.set_openmp_flags() self.set_libdir_variables() self.set_libs_variables() self.save_cfgfile_if_not_exists() if 'MSYSCON' in os.environ: pass else: if not supportrc["framework_install"]: try: from amuse.support import get_amuse_root_dir except ImportError: raise Exception( "AMUSE framework needs to be installed and environment set up." ) self.environment['AMUSE_DIR'] = get_amuse_root_dir() else: if self.inplace: self.environment['AMUSE_DIR'] = os.path.abspath( os.getcwd()) else: self.environment['AMUSE_DIR'] = os.path.abspath( self.build_temp) if self.inplace: self.environment['MUSE_PACKAGE_DIR'] = os.path.abspath( os.getcwd()) else: self.environment['MUSE_PACKAGE_DIR'] = os.path.abspath( self.build_temp)
c_int_pointer = ctypes.POINTER(ctypes.c_int) class simple_hash(ctypes.Structure): _fields_ = [ ("m_cells", cell_pointer), ("m_arraySize", ctypes.c_size_t), ("m_population", ctypes.c_size_t), ("m_zeroUsed", ctypes.c_bool), ("m_zeroCell", cell), ] from amuse.support import get_amuse_root_dir librarypath = os.path.join(get_amuse_root_dir(), "lib", "simple_hash", "libsimplehash.so") lib_simple_hash = ctypes.CDLL(librarypath) class SimpleHash(object): def __init__(self): self._map = simple_hash() self._dummy = ctypes.c_size_t() self._lib = lib_simple_hash self._map_ref = ctypes.byref(self._map) if self._lib.init_hash(ctypes.byref(self._map), 128) != 0: raise MemoryError("allocation of SimpleHash") self.lock = threading.Lock() def __del__(self):
def amuse_root_dir(self): return get_amuse_root_dir()
_fields_ = [("key", ctypes.c_size_t), ("value", ctypes.c_size_t)] cell_pointer = ctypes.POINTER(cell) c_size_t_pointer = ctypes.POINTER(ctypes.c_size_t) c_int_pointer = ctypes.POINTER(ctypes.c_int) class simple_hash(ctypes.Structure): _fields_ = [("m_cells", cell_pointer), ("m_arraySize", ctypes.c_size_t), ("m_population", ctypes.c_size_t), ("m_zeroUsed", ctypes.c_bool), ("m_zeroCell", cell)] from amuse.support import get_amuse_root_dir librarypath = os.path.join(get_amuse_root_dir(), "lib", "simple_hash", "libsimplehash.so") lib_simple_hash = ctypes.CDLL(librarypath) class SimpleHash(object): def __init__(self): self._map = simple_hash() self._dummy = ctypes.c_size_t() self._lib = lib_simple_hash self._map_ref = ctypes.byref(self._map) if self._lib.init_hash(ctypes.byref(self._map), 128) != 0: raise MemoryError("allocation of SimpleHash") self.lock = threading.Lock()
for line in lines: if "=" in line: var, value = line.split("=", 1) if "@" in value: warnings.warn( "possible configuration error/ unconfigured variable in {0}" .format(filename)) cfgvars[var] = value.strip() return cfgvars try: configmk = parse_configmk("config.mk") except IOError: from amuse.support import get_amuse_root_dir configmk = parse_configmk(os.path.join(get_amuse_root_dir(), "config.mk")) class interpreters(object): python = configmk["PYTHON"] class compilers(object): cxx = configmk["CXX"] cc = configmk["CC"] fc = configmk["FC"] cxx_flags = configmk["CXXFLAGS"] cc_flags = configmk["CFLAGS"] fc_flags = configmk["FCFLAGS"] ld_flags = configmk["LDFLAGS"]