1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
# -*- coding: utf-8 -*-
# Package information, generated from cs_package.py.in by make.
#-------------------------------------------------------------------------------
# This file is part of Code_Saturne, a general-purpose CFD tool.
#
# Copyright (C) 1998-2021 EDF S.A.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
#-------------------------------------------------------------------------------
import os
import sys
try:
from code_saturne import cs_config
except Exception:
import cs_config
# Package information
#--------------------
class package:
def __init__(self,
scriptdir=None,
reload_config=False,
name="@PACKAGE_NAME@"):
base_package = 'code_saturne'
# System configuration (compilers, pre-requisites, ...)
if reload_config:
import importlib
try:
config = importlib.import_module('cs_config', package=base_package)
self.config = config.config()
except Exception: # Upon installation
import traceback
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.print_exception(exc_type, exc_value, exc_traceback,
limit=2, file=sys.stderr)
else:
self.config = cs_config.config()
# Package information
self.name = name
self.tarname = "@PACKAGE_TARNAME@"
self.pkgversion = "@PACKAGE_VERSION@"
self.string = "@PACKAGE_STRING@"
self.bugreport = "@PACKAGE_BUGREPORT@"
self.url = "@PACKAGE_URL@"
self.version = "@cs_version@"
self.version_full = "@cs_version_full@"
self.version_short = "@cs_version_short@"
self.revision = "@cs_revision@"
self.code_name = "Code_Saturne"
self.preprocessor = "cs_preprocess" + self.config.exeext
self.solver = self.config.solver_modules[name]['solver']
self.check_syntax = "cs_check_syntax" + self.config.exeext
self.io_dump = "cs_io_dump" + self.config.exeext
self.runcase = "runcase" + self.config.shext
self.runsolver = "run_solver" + self.config.shext
self.configfile = "code_saturne" + self.config.cfgext
self.scratchdir = 'tmp_Saturne'
# Installation directories
self.dirs = {'prefix': ("", "@prefix@"),
'exec_prefix': ("", "@exec_prefix@"),
'bindir': ("bin", "@bindir@"),
'includedir': ("include", "@includedir@"),
'pkgincludedir': (os.path.join("include", base_package),
"@pkgincludedir@"),
'libdir': ("lib", "@libdir@"),
'libexecdir': ("libexec", "@libexecdir@"),
'pkglibexecdir': (os.path.join("libexec", base_package),
"@pkglibexecdir@"),
'pythondir': (os.path.join("lib",
"python" + sys.version[:3],
"site-packages"),
"@pythondir@"),
'pkgpythondir': (os.path.join("lib",
"python" + sys.version[:3],
"site-packages",
base_package),
"@pkgpythondir@"),
'localedir': (os.path.join("share", "locale"),
"@localedir@"),
'datarootdir': ("share", "@datarootdir@"),
'datadir': ("share", "@datadir@"),
'pkgdatadir': (os.path.join("share", base_package),
"@pkgdatadir@"),
'docdir': (os.path.join("share", "doc", self.name),
"@docdir@"),
'pdfdir': (os.path.join("share", "doc", self.name),
"@pdfdir@"),
'sysconfdir': ("etc", "@sysconfdir@")}
# Adjust docdir for additional modules.
# We should try to find a cleaner/more consistant solution,
# perhaps storing all documents in the main module's
# directory (code_saturne).
docdir_1 = self.dirs['docdir'][1]
docdir_1 = os.path.join(os.path.split(docdir_1)[0], name)
self.dirs['docdir'] = (self.dirs['docdir'][0],
docdir_1)
def get_dir(self, installdir):
# First, handle the standard "non relocatable" case
if self.config.features['relocatable'] == "no":
return self.dirs[installdir][1]
# Second, check if CS_ROOT_DIR was forced, or if CS_ROOT_DIR is set
if 'cs_root_dir' in self.dirs:
prefix = self.dirs['cs_root_dir']
else:
prefix = os.getenv('CS_ROOT_DIR')
# Last, assume that the standard tree structure is used
if prefix == None:
prefix = os.path.dirname(os.path.realpath(__file__))
i = prefix.find(self.dirs['pythondir'][0])
if i > -1:
prefix = os.path.dirname(prefix[:i+1])
return os.path.join(prefix, self.dirs[installdir][0])
def get_preprocessor(self):
if self.config.features['frontend'] == "no":
raise Exception("This " + self.name + " build does not " + \
"include the front-end and Preprocessor.")
return os.path.join(self.get_dir("pkglibexecdir"),
self.preprocessor)
def get_io_dump(self):
return os.path.join(self.get_dir("pkglibexecdir"),
self.io_dump)
def get_solver(self):
return os.path.join(self.get_dir("pkglibexecdir"),
self.solver)
def get_check_syntax(self):
return os.path.join(self.get_dir("pkglibexecdir"),
self.check_syntax)
def get_io_dump(self):
return os.path.join(self.get_dir("pkglibexecdir"),
self.io_dump)
def get_global_configfile(self):
# Windows: C:\ProgramData
# Linux and co: /etc
if sys.platform.startswith("win"):
configdir = os.path.join(os.getenv("PROGRAMDATA"),
self.code_name, self.version_short)
else:
configdir = self.get_dir("sysconfdir")
return [os.path.join(configdir, self.configfile)]
def get_user_configfile(self):
# Windows: C:\Users\{user}\AppData\Roaming
# Linux and co: /home/{user} (or similar)
if sys.platform.startswith("win"):
configdir = os.path.join(os.getenv("APPDATA"),
self.code_name, self.version_short)
return [os.path.join(configdir, self.configfile)]
else:
configdir = os.path.expanduser("~")
return [os.path.join(configdir, "." + self.configfile)]
def get_configfiles(self):
u_cfg = self.get_user_configfile()
g_cfg = self.get_global_configfile()
return g_cfg + u_cfg
def get_batchdir(self):
return os.path.join(self.get_dir("pkgdatadir"),
'batch')
def get_pkgdatadir_script(self, script):
return os.path.join(self.get_dir("pkgdatadir"),
script)
def get_alternate_version(self, version):
"""
Return alternate version package object
"""
if not version:
return self
pkg = None
# Determine path (by absolute or local name)
pythondir = os.path.normpath(version)
prefix = os.path.normpath(self.get_dir("exec_prefix"))
if self.get_dir("pkgpythondir").find(prefix) > -1:
postfix = self.get_dir("pkgpythondir")[len(prefix)+1:]
if not os.path.isabs(pythondir):
prefix = os.path.split(prefix)[0]
else:
prefix = version
pythondir = os.path.normpath(os.path.join(prefix,
version,
postfix))
# load alternate package
if os.path.isdir(pythondir):
import sys
sys.path.insert(0, pythondir)
if sys.version < '3.4':
from code_saturne import cs_config
reload(cs_config)
import cs_package
reload(cs_package)
pkg = cs_package.package(name=self.name)
else:
import importlib
importlib.invalidate_caches()
try:
package = importlib.import_module('cs_package',
package='code_saturne')
pkg = package.package(reload_config=True,
name=self.name)
except Exception:
import traceback
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.print_exception(exc_type, exc_value, exc_traceback,
limit=2, file=sys.stderr)
pkg = self
sys.path.pop(0)
if pkg.config.features['relocatable'] != "no":
pkg.dirs['cs_root_dir'] = os.path.normpath(os.path.join(pythondir,
'..', '..', '..', '..'))
else:
raise ImportError("Alternative version '" + pythondir + "' not found.")
return pkg
def get_cross_compile(self):
"""
Return cross-conpilation info
"""
return self.config.features['build_os']
#-------------------------------------------------------------------------------
|