Skip to content

Commit

Permalink
Merge branch 'release/v0.2.21'
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Jun 29, 2020
2 parents 3841175 + 9ef5ff6 commit e38ac31
Show file tree
Hide file tree
Showing 59 changed files with 1,941 additions and 299 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@
*.csv
*.html

# binaries
*.a
*.dll
*.dylib
*.exe
*.lib
*.so

# source archives
*.tar.gz
*.zip

# Affinity Designer documents
*.afdesign
Expand All @@ -18,6 +27,7 @@ build/
cvode-*/
dist/
MANIFEST
rpclib-*/
*.egg-info

# test artifacts
Expand Down
11 changes: 9 additions & 2 deletions OverrideMSVCFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ if (MSVC)
# link statically against the Visual C runtime
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING INTERNAL FORCE)

set(CMAKE_C_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1")
message("Updated CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")

set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG")
message("Updated CMAKE_C_FLAGS_RELEASE:")
message("${CMAKE_C_FLAGS_RELEASE}")
message("Updated CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
endif ()

if (UNIX AND NOT APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
endif ()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Several options are available:

- Install with conda: `conda install -c conda-forge fmpy`
- Install with from PyPI: `python -m pip install fmpy[complete]`
- Install the latest development version directly from GitHub: `python -m pip install https://github.com/CATIA-Systems/FMPy/archive/develop.zip`
- [Install a development build](docs/faq.md)

If you don't have Python on your machine you can install [Anaconda Python](https://www.anaconda.com/download/).

Expand Down
70 changes: 66 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jobs:

- job:
- job: linux
displayName: 'Ubuntu 16.04'
strategy:
matrix:
Expand All @@ -24,6 +24,11 @@ jobs:
conda install --yes --quiet --name myEnvironment -c conda-forge python=$PYTHON_VERSION cmake dask lark-parser lxml matplotlib numpy pyqt pyqtgraph pytest-cov requests $PYTHON_LIBRARIES
displayName: Install Anaconda packages
- bash: |
source activate myEnvironment
python build_cvode.py
displayName: Build CVode binaries
- bash: |
source activate myEnvironment
python setup.py bdist_wheel --universal
Expand Down Expand Up @@ -52,7 +57,7 @@ jobs:
path: dist
artifact: 'linux-python-$(python.version)'

- job:
- job: macosx
displayName: 'macOS 10.15'
strategy:
matrix:
Expand Down Expand Up @@ -83,6 +88,11 @@ jobs:
conda install --yes --quiet --name myEnvironment -c conda-forge python=$PYTHON_VERSION dask lark-parser lxml matplotlib numpy pyqt pyqtgraph pytest-cov requests $PYTHON_LIBRARIES
displayName: Install Anaconda packages
- bash: |
source activate myEnvironment
python build_cvode.py
displayName: Build CVode binaries
- bash: |
source activate myEnvironment
python setup.py bdist_wheel --universal
Expand Down Expand Up @@ -111,7 +121,7 @@ jobs:
path: dist
artifact: 'macosx-python-$(python.version)'

- job:
- job: windows
displayName: 'Windows 2016'
strategy:
matrix:
Expand All @@ -130,12 +140,22 @@ jobs:

- script: conda create --yes --quiet --name myEnvironment
displayName: Create Anaconda environment

- script: |
call activate myEnvironment
conda install --yes --quiet --name myEnvironment -c conda-forge python=%PYTHON_VERSION% cmake dask lark-parser lxml matplotlib numpy pyqt pyqtgraph pytest-cov pywin32 requests
displayName: Install Anaconda packages
- script: |
call activate myEnvironment
python build_cvode.py
displayName: Build CVode binaries
- script: |
call activate myEnvironment
python build_remoting.py
displayName: Build Remoting binaries
- script: |
call activate myEnvironment
python setup.py bdist_wheel --universal
Expand Down Expand Up @@ -166,3 +186,45 @@ jobs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'

- job: merge
dependsOn:
- linux
- macosx
- windows
displayName: 'Merge Python Wheels'
pool:
vmImage: 'ubuntu-16.04'

steps:

- bash: mkdir temp
displayName: Merge Python Wheels

- task: DownloadPipelineArtifact@2
inputs:
artifact: linux-python-3.6
downloadPath: linux

- task: DownloadPipelineArtifact@2
inputs:
artifact: macosx-python-3.6
downloadPath: macosx

- task: DownloadPipelineArtifact@2
inputs:
artifact: windows-python-3.6
downloadPath: windows

- bash: |
unzip -o linux/*.whl -d merged
unzip -o macosx/*.whl -d merged
unzip -o windows/*.whl -d merged
cd merged
zip -r FMPy-x.x.x-py2.py3-none-any.whl .
displayName: Merge FMUs
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: merged/FMPy-x.x.x-py2.py3-none-any.whl
artifactName: merged
102 changes: 102 additions & 0 deletions build_cvode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from fmpy import platform_tuple, sharedLibraryExtension
from fmpy.util import download_file
import tarfile
import os
import shutil
from subprocess import check_call


if os.name == 'nt':
generator = 'Visual Studio 15 2017 Win64'
sl_prefix = ''
sl_suffix = sharedLibraryExtension
else:
generator = 'Unix Makefiles'
sl_prefix = 'lib'
sl_suffix = sharedLibraryExtension

sundials_binary_dir = os.path.join('fmpy', 'sundials', platform_tuple)

# clean up
for build_dir in ['cswrapper/build', 'cvode-5.3.0', sundials_binary_dir, 'fmpy/logging/build']:
if os.path.isdir(build_dir):
shutil.rmtree(build_dir)

url = 'https://computing.llnl.gov/projects/sundials/download/cvode-5.3.0.tar.gz'
checksum = 'd7ff8e77bb2a59cf8143de30f05a2651c2b4d29b586f8003f9187bf9e5a7da6e'

filename = os.path.basename(url)

download_file(url, checksum)

# response = requests.get(url)
#
# with open(filename, 'wb') as f:
# f.write(response.content)

with tarfile.open(filename, "r:gz") as tar:
tar.extractall()

os.mkdir('cvode-5.3.0/static')

# build CVode as static library
check_call([
'cmake',
'-DEXAMPLES_ENABLE_C=OFF',
'-DBUILD_SHARED_LIBS=OFF',
'-DCMAKE_INSTALL_PREFIX=cvode-5.3.0/static/install',
'-DCMAKE_USER_MAKE_RULES_OVERRIDE=../OverrideMSVCFlags.cmake',
'-G', generator,
'-S', 'cvode-5.3.0',
'-B', 'cvode-5.3.0/static'
])

check_call(['cmake', '--build', 'cvode-5.3.0/static', '--target', 'install', '--config', 'Release'])

# build CVode as dynamic library
check_call([
'cmake',
'-DEXAMPLES_ENABLE_C=OFF',
'-DBUILD_STATIC_LIBS=OFF',
'-DCMAKE_INSTALL_PREFIX=cvode-5.3.0/dynamic/install',
'-DCMAKE_USER_MAKE_RULES_OVERRIDE=../OverrideMSVCFlags.cmake',
'-G', generator,
'-S', 'cvode-5.3.0',
'-B', 'cvode-5.3.0/dynamic'
])

check_call(['cmake', '--build', 'cvode-5.3.0/dynamic', '--target', 'install', '--config', 'Release'])

os.mkdir(sundials_binary_dir)

os.path.join('cvode-5.3.0', 'dynamic', 'install', 'sundials_cvode' + sharedLibraryExtension)

for name in ['sundials_cvode', 'sundials_nvecserial', 'sundials_sunlinsoldense', 'sundials_sunmatrixdense']:
src = os.path.join('cvode-5.3.0', 'dynamic', 'install', 'lib', sl_prefix + name + sl_suffix)
dst = os.path.join(sundials_binary_dir, name + sl_suffix)
shutil.copy(src, dst)

# build cswrapper
os.mkdir('cswrapper/build')

check_call([
'cmake',
'-DCVODE_INSTALL_DIR=../cvode-5.3.0/static/install',
'-G', generator,
'-S', 'cswrapper',
'-B', 'cswrapper/build'
])

check_call(['cmake', '--build', 'cswrapper/build', '--config', 'Release'])

# build logging callback
os.mkdir('fmpy/logging/build')

check_call([
'cmake',
'-G', generator,
'-S', 'fmpy/logging',
'-B', 'fmpy/logging/build'
])

check_call(['cmake', '--build', 'fmpy/logging/build', '--config', 'Release'])
79 changes: 79 additions & 0 deletions build_remoting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from fmpy import sharedLibraryExtension, extract
from fmpy.util import download_file
import os
import shutil
from subprocess import check_call


# clean up
for p in ['rpclib-2.2.1', 'remoting/client/build', 'remoting/server/build']:
if os.path.exists(p):
shutil.rmtree(p)

for f in ['fmpy/remoting/client.dll', 'fmpy/remoting/server.exe']:
if os.path.exists(f):
os.remove(f)

rpclib_url = 'https://github.com/rpclib/rpclib/archive/v2.2.1.zip'
rpclib_checksum = '70f10b59f0eb303ccee4a9dda32e6ed898783be9a539d32b43e6fcb4430dce0c'
rpclib_filename = os.path.basename(rpclib_url)

download_file(rpclib_url, rpclib_checksum)

extract(rpclib_filename, '.')

# root = os.path.dirname(__file__)

# build RPCLIB for win32
check_call([
'cmake',
'-DCMAKE_INSTALL_PREFIX=rpclib-2.2.1/win32/install',
'-DRPCLIB_MSVC_STATIC_RUNTIME=ON',
'-G', 'Visual Studio 15 2017',
'-S', 'rpclib-2.2.1',
'-B', 'rpclib-2.2.1/win32'
])

check_call(['cmake', '--build', 'rpclib-2.2.1/win32', '--target', 'install', '--config', 'Release'])

# build RPCLIB for win64
check_call([
'cmake',
'-DCMAKE_INSTALL_PREFIX=rpclib-2.2.1/win64/install',
'-DRPCLIB_MSVC_STATIC_RUNTIME=ON',
'-G', 'Visual Studio 15 2017 Win64',
'-S', 'rpclib-2.2.1',
'-B', 'rpclib-2.2.1/win64'
])

check_call(['cmake', '--build', 'rpclib-2.2.1/win64', '--target', 'install', '--config', 'Release'])

print('####' + str([
'cmake',
'-DRPCLIB=' + os.path.abspath('rpclib-2.2.1/win32/install').replace('\\', '/'),
'-G', 'Visual Studio 15 2017',
'-S', 'remoting/server',
'-B', 'remoting/server/build'
]))

# build server.exe
check_call([
'cmake',
'-DRPCLIB=' + os.path.abspath('rpclib-2.2.1/win32/install').replace('\\', '/'),
'-G', 'Visual Studio 15 2017',
'-S', 'remoting/server',
'-B', 'remoting/server/build'
])

check_call(['cmake', '--build', 'remoting/server/build', '--config', 'Release'])

# build client.exe
check_call([
'cmake',
'-DRPCLIB=' + os.path.abspath('rpclib-2.2.1/win64/install').replace('\\', '/'),
'-G', 'Visual Studio 15 2017 Win64',
'-S', 'remoting/client',
'-B', 'remoting/client/build'
])

check_call(['cmake', '--build', 'remoting/client/build', '--config', 'Release'])
Loading

0 comments on commit e38ac31

Please sign in to comment.