Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
113 lines (81 loc) · 3.23 KB
/
Copy pathsetup.py
File metadata and controls
113 lines (81 loc) · 3.23 KB
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
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
__author__="Jean-Christophe Fabre"
__email__="jean-christophe.fabre@inra.fr"
__license__="see LICENSE file"
importos
importsys
importplatform
importsubprocess
fromsetuptoolsimportsetup, Extension, find_packages
fromsetuptools.command.build_extimportbuild_ext
##############################################################################
##############################################################################
name='PyOpenFLUID'
patchVersion='20250310'
cmakeBuildType='Release'
##############################################################################
##############################################################################
defdetectOpenFLUIDVersion():
try:
Env=os.environ.copy()
VersionStr=subprocess.check_output(["openfluid", "--version"],env=Env)
VersionStr=VersionStr.decode("utf-8").strip(' \t\n\r').split('~')[0]
return(VersionStr)
exceptOSErrorase:
ife.errno==os.errno.ENOENT:
print("OpenFLUID command line not found")
sys.exit(127)
else:
print("OpenFLUID command line error")
sys.exit(126)
##############################################################################
##############################################################################
classCMakeExtension(Extension):
def__init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
self.sourcedir=os.path.abspath(sourcedir)
##############################################################################
classCMakeBuild(build_ext):
defrun(self):
try:
Out=subprocess.check_output(['cmake', '--version'])
exceptOSError:
raiseRuntimeError("CMake must be installed to build the PyOpenFLUID package")
ifplatform.system() !="Linux":
raiseRuntimeError("PyOpenFLUID package is available on Linux systems only")
forExtinself.extensions:
self.build_extension(Ext)
defbuild_extension(self, ext):
ExtDir=os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
CMakeSrcDir=os.path.join(ext.sourcedir,"PyOpenFLUID")
CMakeConfigArgs= ["-DCMAKE_BUILD_TYPE="+cmakeBuildType,
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}".format(ExtDir)]
CMakeBuildDir=self.build_temp
ifnotos.path.exists(self.build_temp):
os.makedirs(self.build_temp)
Env=os.environ.copy()
subprocess.check_call(['cmake', CMakeSrcDir ] +CMakeConfigArgs,cwd=self.build_temp, env=Env)
subprocess.check_call(['cmake', '--build', '.'],cwd=self.build_temp)
##############################################################################
##############################################################################
version=detectOpenFLUIDVersion()
release=version+'-'+patchVersion
setup(
name=name,
version=version,
author='Jean-Christophe Fabre',
author_email='jean-christophe.fabre@inra.fr',
maintainer='Armel Thöni',
maintainer_email='armel.thoni@inrae.fr',
description='Python package for OpenFLUID',
long_description='',
url='https://www.openfluid-project.org/',
packages=['PyOpenFLUID'],
ext_modules=[CMakeExtension('PyOpenFLUID')],
cmdclass={
'build_ext' : CMakeBuild
},
test_suite='tests',
zip_safe=False
)