Skip to content

Commit

Permalink
Merge branch 'release/v0.2.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Dec 26, 2019
2 parents 1dd3f44 + fab0381 commit d0d164a
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 88 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
# compiled files
*.py[cod]

# shared libraries
*.dll
*.dylib
*.so

# build artifacts
build/
cvode-*/
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.2.16 (2019-12-26)

- `FIXED` pre-compiled SUNDIALS libraries re-added

## v0.2.15 (2019-12-18)

- `FIXED` validation of structured variable names with apostrophes
Expand Down
2 changes: 1 addition & 1 deletion fmpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ctypes import *
import _ctypes

__version__ = '0.2.15'
__version__ = '0.2.16'


# determine the platform
Expand Down
10 changes: 5 additions & 5 deletions fmpy/sundials/libraries.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from ctypes import cdll
import os
from fmpy import sharedLibraryExtension
from fmpy import sharedLibraryExtension, platform_tuple

library_dir, _ = os.path.split(__file__)

# load SUNDIALS shared libraries
sundials_nvecserial = cdll.LoadLibrary(os.path.join(library_dir, 'sundials_nvecserial' + sharedLibraryExtension))
sundials_sunmatrixdense = cdll.LoadLibrary(os.path.join(library_dir, 'sundials_sunmatrixdense' + sharedLibraryExtension))
sundials_sunlinsoldense = cdll.LoadLibrary(os.path.join(library_dir, 'sundials_sunlinsoldense' + sharedLibraryExtension))
sundials_cvode = cdll.LoadLibrary(os.path.join(library_dir, 'sundials_cvode' + sharedLibraryExtension))
sundials_nvecserial = cdll.LoadLibrary(os.path.join(library_dir, platform_tuple, 'sundials_nvecserial' + sharedLibraryExtension))
sundials_sunmatrixdense = cdll.LoadLibrary(os.path.join(library_dir, platform_tuple, 'sundials_sunmatrixdense' + sharedLibraryExtension))
sundials_sunlinsoldense = cdll.LoadLibrary(os.path.join(library_dir, platform_tuple, 'sundials_sunlinsoldense' + sharedLibraryExtension))
sundials_cvode = cdll.LoadLibrary(os.path.join(library_dir, platform_tuple, 'sundials_cvode' + sharedLibraryExtension))
Binary file added fmpy/sundials/x86_64-darwin/sundials_cvode.dylib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added fmpy/sundials/x86_64-linux/sundials_cvode.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added fmpy/sundials/x86_64-windows/sundials_cvode.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
81 changes: 4 additions & 77 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,6 @@
except Exception as e:
print("Failed to compile Qt UI and resources. %s" % e)

# build CVode shared libraries
try:
import tarfile
import shutil
from subprocess import check_call
from fmpy import sharedLibraryExtension
from fmpy.util import download_file, visual_c_versions

url = 'https://computing.llnl.gov/projects/sundials/download/cvode-5.0.0.tar.gz'
checksum = '909ae7b696ec5e10a1b13c38708adf27e9a6f9e216a64dc67924263c86add7af'

download_file(url, checksum)

filename = os.path.basename(url)

print("Extracting %s" % filename)
with tarfile.open(filename, 'r:gz') as tar:
tar.extractall()

print("Building CVode")
cmake_args = [
'cmake',
'-B', 'cvode-5.0.0/build',
'-D', 'EXAMPLES_ENABLE_C=OFF',
'-D', 'BUILD_STATIC_LIBS=OFF',
'-D', 'EXAMPLES_INSTALL=OFF',
'-D', 'CMAKE_INSTALL_PREFIX=cvode-5.0.0/dist',
]

vc_versions = visual_c_versions()

if os.name == 'nt':

# set a 64-bit generator
if 160 in vc_versions:
cmake_args += ['-G', 'Visual Studio 16 2019', '-A', 'x64']
elif 150 in vc_versions:
cmake_args += ['-G', 'Visual Studio 15 2017 Win64']
elif 140 in vc_versions:
cmake_args += ['-G', 'Visual Studio 14 2015 Win64']
elif 120 in vc_versions:
cmake_args += ['-G', 'Visual Studio 12 2013 Win64']
elif 110 in vc_versions:
cmake_args += ['-G', 'Visual Studio 11 2012 Win64']

# link statically against the VC runtime
cmake_args += ['-D', 'CMAKE_USER_MAKE_RULES_OVERRIDE:STRING=../OverrideMSVCFlags.cmake']

cmake_args += ['cvode-5.0.0']

check_call(args=cmake_args)
check_call(args=['cmake', '--build', 'cvode-5.0.0/build', '--target', 'install', '--config', 'Release'])

library_prefix = '' if os.name == 'nt' else 'lib'

for shared_library in ['sundials_cvode', 'sundials_nvecserial', 'sundials_sunlinsoldense',
'sundials_sunmatrixdense']:
shutil.copyfile(
os.path.join('cvode-5.0.0', 'dist', 'lib', library_prefix + shared_library + sharedLibraryExtension),
os.path.join('fmpy', 'sundials', shared_library + sharedLibraryExtension))
except Exception as e:
print("Failed to compile CVode shared libraries. %s" % e)

long_description = """
FMPy
====
Expand All @@ -94,9 +31,9 @@
'schema/fmi1/*.xsd',
'schema/fmi2/*.xsd',
'schema/fmi3/*.xsd',
'sundials/sundials_*.dylib',
'sundials/sundials_*.so',
'sundials/sundials_*.dll'],
'sundials/x86_64-darwin/sundials_*.dylib',
'sundials/x86_64-linux/sundials_*.so',
'sundials/x86_64-windows/sundials_*.dll'],
'fmpy.gui': ['icons/app_icon.ico'],
'fmpy.ssp': ['schema/*.xsd'],
}
Expand All @@ -112,7 +49,7 @@
extras_require['complete'] = sorted(set(sum(extras_require.values(), [])))

setup(name='FMPy',
version='0.2.15',
version='0.2.16',
description="Simulate Functional Mock-up Units (FMUs) in Python",
long_description=long_description,
author="Torsten Sommer",
Expand All @@ -124,13 +61,3 @@
install_requires=install_requires,
extras_require=extras_require,
entry_points={'console_scripts': ['fmpy=fmpy.command_line:main']})

# see https://www.python.org/dev/peps/pep-0425/#python-tag
platform_tag = distutils.util.get_platform().replace('-', '_').replace('.', '_')

# add the platform tag to the wheel
for dirpath, _, filenames in os.walk('dist'):
for filename in filenames:
if filename.endswith('-any.whl'):
shutil.move(os.path.join(dirpath, filename),
os.path.join(dirpath, filename).replace('-any.whl', '-' + platform_tag + '.whl'))

0 comments on commit d0d164a

Please sign in to comment.