Skip to content

Commit

Permalink
Merge pull request #73 from OpenWaterAnalytics/hotfix-interim
Browse files Browse the repository at this point in the history
Hotfix interim
  • Loading branch information
michaeltryby committed Jun 8, 2021
2 parents bbc10c9 + d13424f commit 1d8e9a6
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 115 deletions.
83 changes: 58 additions & 25 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,57 @@ name: Build Wheels

on: [push, pull_request]

env:
DOCKER_IMAGE: dockcross/manylinux2014-x64


jobs:
build_wheels:
build_linux_wheels:
name: Build wheels on linux
runs-on: ubuntu-18.04

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: true

- name: Install
run: |
docker pull $DOCKER_IMAGE
docker run --rm $DOCKER_IMAGE > ./dockcross
chmod +x ./dockcross
- name: Script
run: ./dockcross swmm-toolkit/tools/build-wheels.sh

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
path: ./dist/*.manylinux2014_x86_64.whl



build_win-mac_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./swmm-toolkit

strategy:
fail-fast: false
matrix:
os: [windows-2016, ubuntu-16.04, macos-10.15]
py: [3.6, 3.7, 3.8]
fail-fast: false
matrix:
os: [windows-2016, macos-10.15]
py: [3.6, 3.7, 3.8, 3.9]
include:
- os: windows-2016
sys_pkgs: choco install swig
activate: ./build-env/Scripts/activate

- os: macos-10.15
sys_pkgs: brew install swig ninja
activate: source ./build-env/bin/activate

steps:
- name: Checkout repo
Expand All @@ -23,33 +65,24 @@ jobs:
with:
python-version: ${{ matrix.py }}

- name: Install build requirements
if: ${{ contains(matrix.os, 'windows') }}
run: choco install swig

- if: ${{ contains(matrix.os, 'ubuntu') }}
run: sudo apt-get install swig

- if: ${{ contains(matrix.os, 'macos') }}
run: brew install libomp swig

- name: Build wheel
run: pip wheel --wheel-dir=./dist ./swmm-toolkit
- name: Install required system packages
run: ${{matrix.sys_pkgs}}

- name: Repair wheel
if: ${{ contains(matrix.os, 'ubuntu') }}
- name: Build wheel in virtual env
run: |
pip install auditwheel
auditwheel repair ./dist/*-linux_x86_64.whl --plat "manylinux2014_x86_64" -w ./dist
rm -rf ./dist/*-linux_x86_64.whl
python -m venv --clear ./build-env
${{matrix.activate}}
python -m pip install -r build-requirements.txt
python setup.py bdist_wheel
deactivate
- name: Test wheel
run: |
pip install pytest numpy
pip install --no-index --find-links=./dist swmm-toolkit
pip install -r test-requirements.txt
pip install --no-index --find-links=./dist swmm_toolkit
pytest
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
path: ./dist/swmm_toolkit*.whl
path: swmm-toolkit/dist/*.whl
48 changes: 28 additions & 20 deletions swmm-toolkit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,53 @@
# CMakeLists.txt - CMake configuration file for swmm-toolkit python package
#
# Created: Feb 6, 2020
# Modified Jan 12, 2021
# Modified Jun 7, 2021
#
# Author: See AUTHORS
# Author: See AUTHORS
#

################################################################################
################## CMAKELISTS FOR SWMM-TOOLKIT PROJECT ###################
################################################################################

cmake_minimum_required (VERSION 3.17)

project(swmm-toolkit
VERSION
0.8.1
0.8.2
)


set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
set(Python_LIBRARY ${PYTHON_LIBRARY})
find_package (Python ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development)
# Trick here is to perform build in a python virtual environment
set(Python_FIND_VIRTUALENV FIRST)
#set(CMAKE_FIND_DEBUG_MODE TRUE)
if(NOT MSVC)
find_package (Python3 ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development.Module REQUIRED)
else()
find_package (Python3 ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development REQUIRED)
endif()
#set(CMAKE_FIND_DEBUG_MODE FALSE)


# SWIG is a build requirement so needs to be installed first
find_package(SWIG REQUIRED)
cmake_policy(SET CMP0078 NEW)
cmake_policy(SET CMP0086 NEW)
include(${SWIG_USE_FILE})


add_subdirectory(swmm-solver)

# If wheel build on Apple fetch and build OpenMP Library
if (APPLE)
include(./extern/openmp.cmake)
else()
find_package(OpenMP
OPTIONAL_COMPONENTS
C
)
endif()

add_subdirectory(src/swmm/toolkit)

# Add project subdirectories
add_subdirectory(swmm-solver)

# Relocate external libs into install package
if(APPLE)
install(CODE "execute_process(
COMMAND
${PROJECT_SOURCE_DIR}/tools/relocate.zsh ${EXTERN_LIB_PATH}
WORKING_DIRECTORY
${CMAKE_INSTALL_PREFIX}
)"
)
endif()
add_subdirectory(src/swmm/toolkit)
7 changes: 7 additions & 0 deletions swmm-toolkit/build-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@



setuptools==41.4.0
wheel==0.33.6
scikit-build==0.11.1
cmake==3.18.4
48 changes: 48 additions & 0 deletions swmm-toolkit/extern/openmp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# CMakeLists.txt - CMake configuration file for OpenMP Library on Darwin
#
# Created: Mar 17, 2021
# Updated: May 19, 2021
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
#
# Note:
# Need to build libomp for binary compatibility with Python.
#
# OpenMP library build fails for Xcode generator. Use Ninja or Unix Makefiles
# instead.
#

################################################################################
##################### CMAKELISTS FOR OPENMP LIBRARY ######################
################################################################################

include(FetchContent)


FetchContent_Declare(OpenMP
URL
https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/openmp-11.1.0.src.tar.xz
URL_HASH
SHA256=d187483b75b39acb3ff8ea1b7d98524d95322e3cb148842957e9b0fbb866052e
)

set(OPENMP_STANDALONE_BUILD TRUE)
set(LIBOMP_INSTALL_ALIASES OFF)

FetchContent_MakeAvailable(OpenMP)
set(OpenMP_AVAILABLE TRUE)


target_link_directories(omp
PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/_deps/openmp-build/runtime/src>
$<INSTALL_INTERFACE:${LIBRARY_DIST}>
)

install(TARGETS omp
LIBRARY
DESTINATION
"${LIBRARY_DIST}"
)
6 changes: 0 additions & 6 deletions swmm-toolkit/pyproject.toml

This file was deleted.

24 changes: 15 additions & 9 deletions swmm-toolkit/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# setup.py - Setup script for swmm-toolkit python package
#
# Created: Jul 2, 2018
# Updated: May 7, 2020
# Updated: Jun 7, 2021
#
# Author: See AUTHORS
#
Expand Down Expand Up @@ -56,12 +56,19 @@ def run(self):
p.wait()


# Set up location of wheel libraries depending on build platform
if platform_system == "Windows":
package_dir = {"swmm_toolkit":"bin", "swmm.toolkit": "src/swmm/toolkit"}
else:
package_dir = {"swmm_toolkit":"lib", "swmm.toolkit": "src/swmm/toolkit"}


# Set Platform specific cmake args here
if platform_system == "Windows":
cmake_args = ["-GVisual Studio 15 2017 Win64"]

elif platform_system == "Darwin":
cmake_args = ["-GXcode","-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.10"]
cmake_args = ["-GNinja","-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9"]

else:
cmake_args = ["-GUnix Makefiles"]
Expand All @@ -74,32 +81,30 @@ def exclude_files(cmake_manifest):
return list(filter(lambda name: not (name.endswith(exclude_pats)), cmake_manifest))



# Get the long description from the README file
here = pathlib.Path(__file__).parent.resolve()
long_description = (here / 'README.md').read_text(encoding='utf-8')


setup(
name = "swmm-toolkit",
version = "0.8.1",
version = "0.8.2",

packages = ["swmm.toolkit"],
package_dir = {"": "src"},
packages = ["swmm_toolkit", "swmm.toolkit"],
package_dir = package_dir,

zip_safe = False,
install_requires = ["aenum"],
install_requires = ["aenum==2.2.6"],

cmdclass = {"clean": CleanCommand},
cmake_args = cmake_args,
cmake_process_manifest_hook = exclude_files,


description='OWA SWMM Python Toolkit',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/OpenWaterAnalytics/swmm-python',

author='See AUTHORS',
maintainer_email='tryby.michael@epa.gov',
license='CC0',
Expand All @@ -114,6 +119,7 @@ def exclude_files(cmake_manifest):
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: C",
"Development Status :: 4 - Beta",
]
Expand Down

0 comments on commit 1d8e9a6

Please sign in to comment.