Skip to content

Building Binary Wheels

Lucian Smith edited this page Dec 11, 2020 · 7 revisions

Building Binary Wheels: Overall process

When releasing a new version of tellurium, the following needs to be done:

  • Create a wheel file for tellurium.
  • Create wheel files for tellurium's dependencies that don't have one (roadrunner in particular).
  • Create wheel files for anything packaged with Spyder/Tellurium that doesn't have one.
  • Upload the wheel files to test.pypi.org for testing.
  • Upload the wheel files to pypi.org once they're confirmed to work.
  • Create a new Windows installer for Spyder/Tellurium.

You'll need different wheel files, depending on the package/platform:

  • Anything that is pure python needs only one wheel file (like Tellurium itself). It will have the name:
    • tellurium-##.##.##-py3-none-any.whl
  • Anything that uses ctypes for the Python bindings (Antimony and the rrplugins, for now) needs one wheel file for every platform (win, mac, linux):
    • antimony-##.##.##-py3-none-win_amd64.whl
    • antimony-##.##.##-py3-none-manylinux2010_x86_64.whl
    • antimony-##.##.##-py3-none-macosx_10_9_x86_64.whl
  • Anything that uses Swig for the Python bindings (everything but Antimony and rrplugins) needs one wheel file for every platform and every version of Python. Since we are supporting the latest four versions of python (3.6, 3.7, 3.8, and 3.9 in 2021), that means a total of twelve (!) wheel files:
    • libroadrunner-2.0.1-cp36-cp36m-win_amd64.whl
    • libroadrunner-2.0.1-cp37-cp37m-win_amd64.whl
    • libroadrunner-2.0.1-cp38-cp38-win_amd64.whl
    • libroadrunner-2.0.1-cp39-cp39-win_amd64.whl
    • libroadrunner-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl
    • libroadrunner-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl
    • libroadrunner-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl
    • libroadrunner-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl
    • libroadrunner-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl
    • libroadrunner-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl
    • libroadrunner-2.0.1-cp38-cp38-manylinux2010_x86_64.whl
    • libroadrunner-2.0.1-cp39-cp39-manylinux2010_x86_64.whl
  • Pay particular attention to new versions of Python. Many of the dependencies will not have been updated since the last release, but if there's a new version of Python available, you'll need new wheel files for anything using Swig.

Special instructions for the Mac

On a mac, you'll need to compile all the dependencies on an old version of MacOS. Ideally, you'll use the earliest version that numpy uses, which in 2020 is MacOS 10.9 (Mavericks). See https://pypi.org/project/numpy/#files to check if this has changed. One of the lab laptops has 10.9 on it, and can be used to build all the dependencies.

However, tellurium and rrplugins depend on matplotlib, which in turn depends on pillow, whose oldest MacOS version available is 10.10. This means that to test your builds, you'll need to use something more recent. The other lab mac laptop has the most recent MacOS (10.13 in 2020), so use that to test.

Also, unlike other platforms, you need to turn on PYTHON_USE_DYNAMIC_LOOKUP in CMake for tecombine, tenuml, tesbml, and tesedml.

Special instructions for Linux

We have been creating wheel files using a Docker image for manylinux2010 or manylinux2014. The 2014 and 2010 version have the yum package manager, which means that you don't have to build things like bzip individually. However, manylinux 2014 turned out to be WAY to modern for nanohub (where we were running a workshop), so had to go back to 2010. Hopefully you-in-the-future reading this will be able to use the later version.

For convenience, we have created a bunch of automated scripts for building under docker, which hopefully reduces some of the headache in the building process. See https://github.com/evilnose/rr_docker.

Special instructions for Windows

I have had no problems using the latest version of Visual Studio (2019) to build everything, and have been using cygwin to run Python and create and test the wheel files. The one issue I had was when I tried to use the VS developer's console: somehow, this made it insist that Python was 32-bit instead of 64-bit, and made installing wheel files impossible. Other than that, everything was fairly straightforward.

Obtaining Python

For anything with Swig, you'll need separate versions of Python for each version you want to support.

  • On Linux, this probably just means you 'apt-get python3.6', then again for 3.7, 3.8, and 3.9.
  • On Windows or Mac, visit https://www.python.org/downloads/windows/ or https://www.python.org/downloads/mac-osx/, and find the latest version with a downloadable installer for each version of Python. For example, for Python 3.6, the last version with downloadable files was 3.6.8, so just get that (even though 3.6.12 is technically available). The same will presumably eventually be true of Python 3.7, etc.
  • For each version of Python you now have, install twine and wheel:
    • python3x -m pip install twine wheel

Building with CMake

All Tellurium dependencies can be compiled with CMake, though some of them have slightly different ways of using it. I have found that the following works reasonably efficiently:

  • Tell CMake to make the Python bindings (WITH_PYTHON to true, for most projects).
  • Set CMAKE_INSTALL_PREFIX to ../install-release-py36
  • Set PYTHON_EXECUTABLE, PYTHON_INCLUDE_DIR, and PYTHON_LIBRARY to the appropriate files/directories for Python 3.6
  • Run CMake and create the makefiles/VS files/whatever.
  • Create and install the dependency.
  • Go back and, in the same directory, set CMAKE_INSTALL_PREFIX to ../install-release-py37, and the three PYTHON_ variables to now point at Python 3.7
  • Re-run cmake and re-install. This shouldn't have to recompile the whole library, just the python bindings.
  • Do the same for Python 3.8 I usually use cmake-gui for this, and after filling in CMAKE_INSTALL_PREFIX, fill in the 'search' box with 'py', which nicely highlights the four variables I need to change for each. (Note that you don't need to do this for Antimony, since it doesn't use Swig.)

Creating setup.py and init.py files

Some of tellurium's dependencies come with these files and others do not. Lucian is working to get these files included in future releases, but in the meantime, you'll want a setup.py file at install/bindings/python/setup.py (individual ones are below), and an init.py file at install/bindings/python/LIBRARY/init.py:

from .LIBRARY import *

__version__ = 'VERSION'

where LIBRARY is the name of the library (libsbml, libnuml, etc.) and VERSION is the version string of that library.

Creating wheel files

  • Create a setup.py file as described below if one does not already exist. Copy it into all three install directories (often install/bindings/python/)
  • Create an init.py file if one does not already exist. Copy it into all three install directories (often install/bindings/python/LIBNAME/)
  • Run the following commands three times, once for each version of Python, from the corresponding install directory:
    • python3x setup.py sdist bdist_wheel
    • mv dist/*whl /PATH/TO/COMMON/WHEEL/DIRECTORY
  • Then, do the same for the other packages.

NOTE: The setup.py files described will create system-dependent and python-version-dependent wheel files. For everything but Antimony and rrplugins, this is fine. For Antimony, you'll need to rename the wheel file, something like:

  • mv antimony-1.12.0-cp36-cp36m-win_amd64.whl antimony-1.12.0-py3-none-win_amd64.whl

i.e. rename cp36-cp36m to py3-none.

rrplugins

The rrplugins package comes with the roadrunner source, and also comes with its own setup file: setup_rrplugins.py Because it uses ctypes, you will only need to create one wheel file per operating system. After you've created the roadrunner wheel and saved it elsewhere, for any version of Python, do the following:

  • cd [install_dir]
  • rm -r -f dist\ build' [This is to remove the roadrunner files, just in case.]
  • python3x setup_rrplugins.py sdist bdist_wheel
  • Rename the wheel file to have py3-none in it instead of the particular python version (i.e. cp36-cp36m)
  • mv dist/*whl /PATH/TO/COMMON/WHEEL/DIRECTORY

Testing

To test a newly-created wheel file, install it using

  • python -m pip install FILENAME.whl

After doing that, run python, make sure you can import the package, run any tests (if they exist), and check to see if the bindings are there. As an example, for roadrunner, you can check the following:

  • import roadrunner as rr
  • rr.__version__
  • rr.runTests()
  • rr.[TAB]

The last will (in many environments) display a list of all the functions/member variables for roadrunner.

Uploading wheel files to pypi

First, sign up for an account at pypi.org and test.pypi.org. Have one of the existing maintainers add you to the tellurium packages.

Then, run the following command from the directory you've been saving your .whl files:

/path/to/any/python -m twine upload --repository testpypi *.whl

(uploading a wheel file can be done with any version of Python.)

If this command is successful, your package should show up when you browse test.pypi.org. To install your test.pypi.org package:

/path/to/python  -m pip install --upgrade --index-url https://test.pypi.org/simple PACKAGENAME

After testing (preferentially on more than one machine/by multiple people) you can then upload the wheel files to pypi itself:

/path/to/any/python -m twine upload *.whl

Instructions for building particular dependencies

Building libsbml / tesbml

The main difference between building libsbml and the other packages in this list is that you need to turn on PYTHON_INSTALL_WITH_SETUP.

Build libsbml by following the official libsbml instructions. When it comes time to select which packages need to be built, use the following:

cmake -G"Visual Studio XX" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/libsbml -DLIBBZ_LIBRARY="BZLIP2-LIBRARY" -DLIBBZ_INCLUDE_DIR="/path/to/bzip2" -DLIBXML_LIBRARY="LIBXML2-LIBRARY" -DLIBXML_INCLUDE_DIR="/path/to/include/libxml2" -DLIBZ_LIBRARY="ZLIB-LIBRARY" -DLIBZ_INCLUDE_DIR="/path/to/include/zlib" -DENABLE_ARRAYS=ON -DENABLE_COMP=ON -DENABLE_DISTRIB=ON -DENABLE_DYN=ON -DENABLE_FBC=ON -DENABLE_GROUPS=ON -DENABLE_LAYOUT=ON -DENABLE_MULTI=OFF -DENABLE_QUAL=ON -DENABLE_RENDER=ON -DENABLE_REQUIREDELEMENTS=ON -DENABLE_SPATIAL=OFF -DWITH_CPP_NAMESPACE=OFF -DWITH_PYTHON=ON -DPYTHON_EXECUTABLE=/path/to/python -DPYTHON_INCLUDE_DIR=/path/to/python/include -DPYTHON_INSTALL_WITH_SETUP=ON -DPYTHON_INSTALL_WITH_SETUP=ON -DPYTHON_USE_DYNAMIC_LOOKUP=ON (except Windows) -DSWIG_EXECUTABLE=/path/to/swig /path/to/src/libsbml

libSBML does not come with its own setup.py or 'init.py' files, so you can create them manually. Create the init file as above, and copy the following into /path/to/install/libsbml/bindings/python/setup.py:

## @file    setup.py
## @brief   Python distutils code for libSBML Python module
## @author  Michael Hucka
## @author  Ben Bornstein
## @author  Ben Kovitz
## @author  Frank Bergmann ([email protected])
## @author  J Kyle Medley
## @author  Lucian Smith
##
##<!---------------------------------------------------------------------------
## This file is part of libSBML.  Please visit http://sbml.org for more
## information about SBML, and the latest version of libSBML.
##
## Copyright (C) 2013-2016 jointly by the following organizations:
##     1. California Institute of Technology, Pasadena, CA, USA
##     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
##     3. University of Heidelberg, Heidelberg, Germany
##
## Copyright 2005-2010 California Institute of Technology.
## Copyright 2002-2005 California Institute of Technology and
##                     Japan Science and Technology Corporation.
##
## This library is free software; you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation.  A copy of the license agreement is provided
## in the file named "LICENSE.txt" included with this software distribution
## and also available online as http://sbml.org/software/libsbml/license.html
##----------------------------------------------------------------------- -->*/

from setuptools import setup, Distribution

class BinaryDistribution(Distribution):
    """Distribution which always forces a binary package with platform name"""
    def has_ext_modules(foo):
        return True

setup(name             = "tesbml",
      version          = "5.18.1",
      description      = "LibSBML Python API",
      long_description = ("LibSBML is a library for reading, writing and "+
                          "manipulating the Systems Biology Markup Language "+
                          "(SBML).  It is written in ISO C and C++, supports "+
                          "SBML Levels 1, 2 and 3, and runs on Linux, Microsoft "+
                          "Windows, and Apple MacOS X.  For more information "+
                          "about SBML, please see http://sbml.org."),
      classifiers=[
          'Intended Audience :: Science/Research',
          'Operating System :: MacOS :: MacOS X',
          'Operating System :: Microsoft :: Windows',
          'Operating System :: POSIX',
          'Programming Language :: C++',
          ],
      license          = "LGPL",
      author           = "SBML Team",
      author_email     = "[email protected]",
      url              = "http://sbml.org",
      packages         = ["tesbml"],
      package_dir      = {'tesbml': 'libsbml'},
      package_data     = {'tesbml': ['*.so*', '*.dll', '*.dylib*', '*.pyd']},
      distclass=BinaryDistribution,
)

Building Antimony

First, clone the Antimony repository. Change to your source code directory and execute the following command:

git clone https://github.com/sys-bio/antimony.git

Next, build Antimony with CMake using the following flags. You will need to specify the path to libSBML, which you built above, as well as the paths to libsbml's dependencies:

cmake -G"Your Generator" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/antimony -DWITH_SBML=ON -DWITH_STATIC_SBML=ON -DWITH_LIBSBML_LIBXML=ON -DWITH_PYTHON=ON -DLIBSBML_INSTALL_DIR="/path/to/libsbml" -DWITH_LIBSBML_COMPRESSION=ON -DPYTHON_EXECUTABLE="/path/to/python" -DPYTHON_INCLUDE_DIR="/path/to/python/include" -DPYTHON_LIBRARY="/path/to/python-lib" (Windows only) -DWITH_QTANTIMONY=OFF -DWITH_CELLML=OFF -DPYTHON_LOCAL_INSTALL=ON -DPYTHON_SYSTEM_INSTALL=OFF -DWITH_CONDA_BUILDER=OFF -DBZIP_LIBRARY="/path/to/bzip2" -DICONV_LIBRARY="/path/to/iconv" (Windows only) -DLIBXML_LIBRARY="/path/to/libxml2" -DZDLL_LIBRARY="/path/to/zlib" -DSWIG_EXECUTABLE=/path/to/swig /path/to/src/antimony

When you install antimony, it will come with a setup.py file in installdir/bindings/python/, which you can use to create the wheel file, as above. Don't forget to rename the file to have 'py3-none' in it, instead of 'cp36-cp36m' or whatever.

Building libnuml

libnuml requires that libsbml be built with namespaces enabled. You can build a separate copy of libsbml with -DWITH_CPP_NAMESPACE=ON and link libnuml against this separate copy. Obtain the libnuml sources from https://github.com/NuML/NuML.

cmake -G"Your Generator" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/libnuml -DLIBSBML_LIBRARY=/path/to/libsbml-static.? -DLIBSBML_INCLUDE_DIR=/path/to/libsbml/include -DLIBSBML_STATIC=ON -DEXTRA_LIBS="xml2;bz2;z" -DWITH_CPP_NAMESPACE=ON -DWITH_PYTHON=ON -DPYTHON_EXECUTABLE=/path/to/python -DPYTHON_INCLUDE_DIR=/path/to/python/include -DPYTHON_USE_DYNAMIC_LOOKUP=ON -DSWIG_EXECUTABLE=/path/to/swig /path/to/src/NuML/libnuml

libnuml requires an init.py file to be created (as above) as well as a setup.py script. You can use the following as a template (be sure to adjust the version number and list of authors):

#! /usr/bin/env python

from setuptools import setup, Distribution

class BinaryDistribution(Distribution):
    """Distribution which always forces a binary package with platform name"""
    def has_ext_modules(foo):
        return True

setup(name='tenuml',
      version='1.1.1.2',
      description='Library for reading/writing data in COMBINE archives',
      classifiers=[
          'Intended Audience :: Science/Research',
          'Operating System :: MacOS :: MacOS X',
          'Operating System :: Microsoft :: Windows',
          'Operating System :: POSIX',
          'Programming Language :: C++',
          ],
      author='Frank Bergmann, Kyle Medley (packaging)',
      url='https://github.com/NuML/NuML',
      packages=['tenuml'],
      package_dir= {'tenuml': 'libnuml'},
      package_data={'tenuml': ['*.so*','*.dylib*','*.pyd','lib*','*.dll']},
      distclass=BinaryDistribution,
)

Building libsedml

As with libnuml, libsbml namespaces must be enabled. Obtain the libsedml sources from https://github.com/fbergmann/libSEDML.

cmake -G"Your Generator" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/libsedml -DLIBSBML_LIBRARY=/path/to/libsbml/libsbml-static.? -DLIBSBML_INCLUDE_DIR=/path/to/libsbml/include -DLIBSBML_STATIC=ON -DEXTRA_LIBS="xml2;bz2;z" -DWITH_CPP_NAMESPACE=ON -DWITH_PYTHON=ON -DPYTHON_EXECUTABLE=/path/to/python -DPYTHON_INCLUDE_DIR=/path/to/python/include -DPYTHON_USE_DYNAMIC_LOOKUP=ON (except Windows) -DLIBNUML_LIBRARY=/path/to/libnuml-static.? -DLIBNUML_INCLUDE_DIR=/path/to/libnuml/include -DPYTHON_LIBRARY="/path/to/python-lib" (Windows only) -DSWIG_EXECUTABLE=/path/to/swig /path/to/src/libsedml

As with libnuml, libsedml lacks an init.py file and setup.py script. Create the init file as above, and use the following for setup:

## @file    setup.py
## @brief   Python distutils code for libsedml Python module
## @author  Michael Hucka
## @author  Ben Bornstein
## @author  Ben Kovitz
## @author  Frank Bergmann ([email protected])
## @author  J Kyle Medley
##
##<!---------------------------------------------------------------------------
## This file is part of libsedml.  Please visit http://sbml.org for more
## information about SBML, and the latest version of libsedml.
##
## Copyright (C) 2013-2016 jointly by the following organizations:
##     1. California Institute of Technology, Pasadena, CA, USA
##     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
##     3. University of Heidelberg, Heidelberg, Germany
##
## Copyright 2005-2010 California Institute of Technology.
## Copyright 2002-2005 California Institute of Technology and
##                     Japan Science and Technology Corporation.
##
## This library is free software; you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation.  A copy of the license agreement is provided
## in the file named "LICENSE.txt" included with this software distribution
## and also available online as http://sbml.org/software/libsedml/license.html
##----------------------------------------------------------------------- -->*/

from setuptools import setup, Distribution

class BinaryDistribution(Distribution):
    """Distribution which always forces a binary package with platform name"""
    def has_ext_modules(foo):
        return True

setup(name             = "tesedml",
      version          = "0.4.5.0",
      description      = "LibSEDML Python API",
      long_description = ("libSEDML is a library for reading, writing and "+
      "manipulating SEDML. It is written in ISO C and C++, supports SEDML "+
      "Levels 1, Version 1-3, and runs on Linux, Microsoft Windows, and Apple "+
      "MacOS X. For more information about SEDML, please see http://sed-ml.org/."),
      classifiers=[
          'Intended Audience :: Science/Research',
          'Operating System :: MacOS :: MacOS X',
          'Operating System :: Microsoft :: Windows',
          'Operating System :: POSIX',
          'Programming Language :: C++',
          ],
      license          = "LGPL",
      author           = "Frank T. Bergmann, J Kyle Medley (packaging)",
      url              = "http://sed-ml.org/",
      packages         = ["tesedml"],
      package_dir      = {'tesedml': 'libsedml'},
      package_data     = {'tesedml': ['*.so*', '*.pyd', '*.dll', '*.dylib*']},
      distclass=BinaryDistribution,
)

Building phrasedml

After building libsbml, libnuml, and libsedml with namespaces enabled, you can build phrasedml. Please get the source code from SourceForge using SVN and use the following CMake flags to build phrasedml:

cmake -G"Your Generator" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/phrasedml -DPHRASEDML_ENABLE_XPATH_EVAL=ON -DLIBSBML_LIBRARY=/path/to/libsbml/lib/libsbml.static -DLIBSBML_INCLUDE_DIR=/path/to/libsbml/include -DBZIP_LIBRARY=/path/to/libbz2 -DICONV_LIBRARY=/path/to/libiconv (Windows only) -DLIBXML_LIBRARY=/path/to/libxml2/lib/libxml2.static -DZDLL_LIBRARY=/path/to/zlib/libz.static -DEXTRA_LIBS="bz2;z;xml2" (use full paths for Windows) -DLIBNUML_LIBRARY=/path/to/libnuml -DLIBNUML_INCLUDE_DIR=/path/to/libnuml/include -DLIBSEDML_LIBRARY=/path/to/libsedml/lib/libsedml.static -DLIBSEDML_INCLUDE_DIR=/path/to/libsedml/include -DWITH_PYTHON=ON -DPYTHON_EXECUTABLE=/path/to/python -DPYTHON_INCLUDE_DIR=/path/to/python/include -DPYTHON_LOCAL_INSTALL=ON -DPYTHON_SYSTEM_INSTALL=OFF -DSWIG_EXECUTABLE=/path/to/swig /path/to/src/phrasedml

Building libcombine

libcombine requires the zipper library, which can be built using the following CMake flags:

cmake -G"Your Generator" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/zipper -DLIBZ_LIBRARY=/path/to/zlib -DLIBZ_INCLUDE_DIR=/path/to/zlib/include /path/to/src/zipper

libcombine also lacks an init.py and setup.py script. Create the init file as above, and use the following for setup.py:

#! /usr/bin/env python

from setuptools import setup, Distribution

class BinaryDistribution(Distribution):
    """Distribution which always forces a binary package with platform name"""
    def has_ext_modules(foo):
        return True

setup(name='tecombine',
      version='0.2.7',
      description='A library for working with COMBINE archives',
      classifiers=[
          'Intended Audience :: Science/Research',
          'Operating System :: MacOS :: MacOS X',
          'Operating System :: Microsoft :: Windows',
          'Operating System :: POSIX',
          'Programming Language :: C++',
          ],
      author='Frank Bergmann, Kyle Medley (packaging)',
      url='https://github.com/sbmlteam/libCombine',
      packages=['tecombine'],
      package_dir={'tecombine': 'libcombine'},
      package_data={'tecombine': ['*.so*','*.dylib*','*.pyd','lib*','*.dll']},
      distclass=BinaryDistribution,
)

You can use the following CMake flags for building libcombine:

cmake -G"Your Generator" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/libcombine -DLIBSBML_LIBRARY=/path/to/libsbml-static -DLIBSBML_INCLUDE_DIR=/path/to/libsbml/include -DEXTRA_LIBS="xml2;bz2;z" -DZIPPER_LIBRARY=/path/to/zipper-library -DZIPPER_INCLUDE_DIR=/path/to/zipper/include -DLIBZ_LIBRARY=/path/to/zlib -DWITH_PYTHON=ON -DPYTHON_EXECUTABLE=/path/to/python -DPYTHON_INCLUDE_DIR=/path/to/python/include -DPYTHON_USE_DYNAMIC_LOOKUP=ON (except Windows) -DPYTHON_LIBRARY=/path/to/python-lib (Windows only) -DSWIG_EXECUTABLE=/path/to/swig -DWITH_CPP_NAMESPACE=ON /path/to/src/libCombine

Building rrplugins

You can use the following CMake flags for building rrplugins:

cmake -G"Your Generator" -DCMAKE_INSTALL_PREFIX=/path/to/install/roadrunner -DCMAKE_BUILD_TYPE=Release -DTLP_DEPENDENCIES_PATH=/path/to/install//roadrunner -DBZ2_LIBRARY=/path/to/bzip2-library -DICONV_LIBRARY=/path/to/libiconv (Windows only) -DZLIB_LIBRARY=/path/to/zlib -DLIBXML2_LIBRARIES=/path/to/libxml2 -DLIBXML2_INCLUDE_DIR=/path/to/libxml2/include /path/to/src/rrplugins

Building sbml2matlab

sbml2matlab is a script to convert SBML models into executable Matlab code for simulating them. The source code can be obtained here. Please use the following CMake flags to build sbml2matlab:

cmake -G"Your Generator" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/sbml2matlab -DLIBSBML_PREFIX=/path/to/libsbml -DLIBSBML_STATIC_LIBRARY=/path/to/libsbml/lib/libsbml.static -DLIBSBML_INCLUDE_DIR=/path/to/libsbml/include -DWITH_LIBSBML_COMPRESSION=ON -DEXTRA_LIBS="bz2;z;xml2" (on Windows use full paths) -DSWIG_EXECUTABLE=/path/to/swig -DICONV_LIBRARY=/path/to/libiconv/lib/libiconv.static -DLIBXML_LIBRARY=/path/to/libxml/lib/libxml2.static -DZDLL_LIBRARY=/path/to/zlib/lib/libz.static -DBZIP_LIBRARY=/path/to/libbz2/lib/libbz2.static -DWITH_PYTHON=ON -DPYTHON_EXECUTABLE=/path/to/python -DPYTHON_INCLUDE_DIR=/path/to/python/include /path/to/src/sbml2matlab

Finally, sbml2matlab does not come with its own init.py or setup.py files. Create the init file as above, and use the following as a template for setup.py:

#!/usr/bin/env python

from setuptools import setup, Distribution

class BinaryDistribution(Distribution):
    """Distribution which always forces a binary package with platform name"""
    def has_ext_modules(foo):
        return True

setup(name='sbml2matlab',
      version='0.9.1',
      description='An SBML to MATLAB translator',
      author='Stanley Gu, Lucian Smith',
      url='https://github.com/sys-bio/sbml2matlab',
      packages=['sbml2matlab'],
      package_data={
          "sbml2matlab": ["_sbml2matlab.pyd", "*.dll", "*.txt",
                          "*.lib", "*.so*", "*.dylib*"]
      },
      distclass=BinaryDistribution,
)