Skip to content

Commit

Permalink
Add option to extract dSYM symbols, small SBML change (#409)
Browse files Browse the repository at this point in the history
* feature(python) extract dSYM files under darwin when ENABLE_GCOV_COVERAGE is TRUE

* feature(python) implement proper compilation with ENABLE_AMICI_DEBUGGING

* fix(sbml) better defaults for stoichiometry when stoichiometry is not set.

* feature(debug) prepend oso path

* fix(debug) remove unused variable in my_install_lib

* fix(debug) remove oso-prepend-path

* fix(debug) removed unused target_dir
  • Loading branch information
FFroehlich authored Aug 18, 2018
1 parent 1551d4c commit cbf4605
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
4 changes: 3 additions & 1 deletion python/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,10 @@ def processReactions(self):
else:
# dont put the symbol if it wont get replaced by a rule
elements[index]['stoichiometry'] = sp.sympify(element.getStoichiometry())
else:
elif element.isSetStoichiometry():
elements[index]['stoichiometry'] = sp.sympify(element.getStoichiometry())
else:
elements[index]['stoichiometry'] = sp.sympify(1.0)

for index in elements.keys():
if not (elements[index]['species'] in self.constantSpecies
Expand Down
38 changes: 34 additions & 4 deletions python/sdist/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from setuptools import find_packages, setup, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist
from setuptools.command.install_lib import install_lib

import os
import sys
import glob
Expand Down Expand Up @@ -101,9 +103,14 @@

# Enable coverage?
if 'ENABLE_GCOV_COVERAGE' in os.environ and os.environ['ENABLE_GCOV_COVERAGE'] == 'TRUE':
print("ENABLE_GCOV_COVERAGE was set to TRUE. Building AMICI with debug and coverage symbols.")
print("ENABLE_GCOV_COVERAGE was set to TRUE. Building AMICI with coverage symbols.")
cxx_flags.extend(['-g', '-O0', '--coverage'])
amici_module_linker_flags.append('--coverage')
amici_module_linker_flags.extend(['--coverage','-g'])

if 'ENABLE_AMICI_DEBUGGING' in os.environ and os.environ['ENABLE_AMICI_DEBUGGING'] == 'TRUE':
print("ENABLE_AMICI_DEBUGGING was set to TRUE. Building AMICI with debug symbols.")
cxx_flags.extend(['-g', '-O0'])
amici_module_linker_flags.extend(['-g'])

libamici = setup_clibs.getLibAmici(
h5pkgcfg=h5pkgcfg, blaspkgcfg=blaspkgcfg, extra_compiler_flags=cxx_flags)
Expand Down Expand Up @@ -134,6 +141,26 @@
)


class my_install_lib(install_lib):
"""Custom install to allow preserving of debug symbols"""
def run(self):
"""strip debug symbols
Returns:
"""
if 'ENABLE_AMICI_DEBUGGING' in os.environ and os.environ['ENABLE_AMICI_DEBUGGING'] == 'TRUE' and sys.platform == 'darwin':
search_dir = os.path.join(os.getcwd(),self.build_dir,'amici')
for file in os.listdir(search_dir):
if file.endswith('.so'):
subprocess.run(['dsymutil',os.path.join(search_dir,file),
'-o',os.path.join(search_dir,file + '.dSYM')])


# Continue with the actual installation
install_lib.run(self)


class my_build_ext(build_ext):
"""Custom build_ext to allow keeping otherwise temporary static libs"""

Expand All @@ -153,7 +180,8 @@ def run(self):

# Module build directory where we want to copy the generated libs
# to
target_dir = os.path.join(self.build_lib, 'amici/libs')

target_dir = os.path.join(self.build_lib, 'amici','libs')
self.mkpath(target_dir)

# Copy the generated libs
Expand All @@ -162,6 +190,7 @@ def run(self):
(build_clib.build_clib, os.sep, lib))
assert len(
libfilenames) == 1, "Found unexpected number of files: " % libfilenames

copyfile(libfilenames[0],
os.path.join(target_dir, os.path.basename(libfilenames[0])))

Expand Down Expand Up @@ -268,7 +297,8 @@ def main():
name='amici',
cmdclass={
'sdist': my_sdist,
'build_ext': my_build_ext
'build_ext': my_build_ext,
'install_lib': my_install_lib
},
version=getPackageVersion(),
description='Advanced multi-language Interface to CVODES and IDAS (%s)',
Expand Down

0 comments on commit cbf4605

Please sign in to comment.