Skip to content

Commit

Permalink
Finish method of using pre-built binaries for HELICS apps wheel build
Browse files Browse the repository at this point in the history
  • Loading branch information
nightlark committed Feb 3, 2024
1 parent 84dc5b4 commit 4875b20
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
build: ""
artifact_suffix: "windows_x86"
use_qemu: false
- os: macos-13
- os: macos-14
arch: "universal2"
build: ""
artifact_suffix: "macos"
Expand Down
68 changes: 36 additions & 32 deletions helics_apps-pip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
cmake_minimum_required(VERSION 3.15...3.26)
project(HELICS LANGUAGES CXX) # Must be "HELICS" due to its CMake files requiring CMAKE_PROJECT_NAME == PROJECT_NAME in order to build app executables
include(FetchContent)

# NOTE: SKBUILD_PROJECT_VERSION strips some of the extra Python version components out, like postN and devM
# The setuptools_scm "no-guess-dev" version_scheme works well, since that leaves it with just the HELICS version

# Note: This will likely not produce valid wheels for musl systems...
if(LINUX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
# Note: Linux requires a hint for whether this wheel should be for manylinux (glibc) or musllinux
# -- The CIBW_ARTIFACT_TYPE environment variable is only expected to be set during official release builds using cibuildwheel on GHA CI systems
if(LINUX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND ENV{CIBW_ARTIFACT_TYPE} STREQUAL "manylinux_x86_64")
set(HELICS_DOWNLOAD_URL https://github.com/GMLC-TDC/HELICS/releases/download/v${SKBUILD_PROJECT_VERSION}/Helics-${SKBUILD_PROJECT_VERSION}-Linux-x86_64.tar.gz)
elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message(STATUS "${CMAKE_SYSTEM_PROCESSOR}")
set(HELICS_DOWNLOAD_URL https://github.com/GMLC-TDC/HELICS/releases/download/${SKBUILD_PROJECT_VERSION}/Helics-${SKBUILD_PROJECT_VERSION}-macOS-universal2.zip)
set(HELICS_DOWNLOAD_URL https://github.com/GMLC-TDC/HELICS/releases/download/v${SKBUILD_PROJECT_VERSION}/Helics-${SKBUILD_PROJECT_VERSION}-macOS-universal2.zip)
elseif(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(HELICS_DOWNLOAD_URL https://github.com/GMLC-TDC/HELICS/releases/download/v${SKBUILD_PROJECT_VERSION}/Helics-${SKBUILD_PROJECT_VERSION}-win64.zip)
Expand All @@ -15,33 +19,44 @@ elseif(WIN32)
endif()
endif()

message(STATUS "CIBW_ARTIFACT_TYPE: $ENV{CIBW_ARTIFACT_TYPE}")
message(STATUS "CIBUILDWHEEL: $ENV{CIBUILDWHEEL}")
message(STATUS "DOWNLOAD URL: ${HELICS_DOWNLOAD_URL}")
# If we are building a binary wheel for an official release (or installing) and CIBUILDWHEEL is set, speed things up with pre-built HELICS binaries
if(DEFINED ENV{CIBUILDWHEEL} AND HELICS_DOWNLOAD_URL AND SKBUILD_STATE STREQUAL "wheel")
message(STATUS "Downloading pre-built HELICS release")
FetchContent_Declare(
helics-bin
URL ${HELICS_DOWNLOAD_URL}
)
FetchContent_MakeAvailable(helics-bin)
if(EXISTS ${helics-bin_SOURCE_DIR}/bin)
install(DIRECTORY ${helics-bin_SOURCE_DIR}/bin DESTINATION . USE_SOURCE_PERMISSIONS)
endif()
if(EXISTS ${helics-bin_SOURCE_DIR}/lib)
install(DIRECTORY ${helics-bin_SOURCE_DIR}/lib DESTINATION . USE_SOURCE_PERMISSIONS)
endif()
if(EXISTS ${helics-bin_SOURCE_DIR}/lib64)
install(DIRECTORY ${helics-bin_SOURCE_DIR}/lib64 DESTINATION . USE_SOURCE_PERMISSIONS)
endif()

return()
message(STATUS ${SKBUILD_PROJECT_NAME})
message(STATUS ${SKBUILD_PROJECT_VERSION})
message(STATUS ${SKBUILD_PROJECT_VERSION_FULL})
message(STATUS ${SKBUILD_STATE})
message(STATUS ${SKBUILD_PLATLIB_DIR})
message(STATUS ${SKBUILD_DATA_DIR})
# If we made a wheel from pre-built HELICS binaries, exit early!
return()
endif()

include(FetchContent)
# No pre-built HELICS binaries being used, warn about limitations of building wheels or installing from an sdist
if(SKBUILD_STATE STREQUAL "wheel")
message(WARNING "Building HELICS from source (some features including ZeroMQ Core, IPC Core, and web server won't be available)")
endif()

# Only fetch source code files if it is building an sdist
# Only fetch source code files if it is building an sdist; this should make builds from a source distribution work without internet connections
if(NOT SKBUILD_STATE STREQUAL "sdist")
set(FETCHCONTENT_FULLY_DISCONNECTED ON)
endif()

# NOTE: SKBUILD_PROJECT_VERSION strips some of the extra Python version components out, like postN and devM
# The setuptools_scm "no-guess-dev" version_scheme works well, since that leaves it with just the HELICS version
set(CMAKE_CXX_STANDARD 17)
set(HELICS_DISABLE_GIT_OPERATIONS ON)
set(HELICS_ZMQ_SUBPROJECT ON)
set(HELICS_ZMQ_FORCE_SUBPROJECT ON)
set(HELICS_ENABLE_ZMQ_CORE OFF)
set(HELICS_DISABLE_BOOST ON) # TODO: headers are just needed to compile, maybe tell users to have it when building from source
set(HELICS_ENABLE_ZMQ_CORE OFF) # TODO: vendor libzmq similar to other 3rd party libraries
set(HELICS_DISABLE_BOOST ON) # TODO: headers are just needed to compile, maybe tell users to have it installed as prereq for building from source?
set(HELICS_BUILD_APP_LIBRARY ON)
set(HELICS_BUILD_APP_EXECUTABLES ON)
FetchContent_Declare(
Expand All @@ -54,19 +69,8 @@ FetchContent_Declare(
if(SKBUILD_STATE STREQUAL "sdist")
if(NOT helics_POPULATED)
FetchContent_Populate(HELICS)
message(STATUS "Populated HELICS")
endif()
elseif(SKBUILD_STATE STREQUAL "wheel")
add_library(helicsCpp98_ide INTERFACE)
FetchContent_MakeAvailable(helics)
endif()
message(STATUS ${helics_POPULATED})
message(STATUS ${helics_SOURCE_DIR})
message(STATUS ${helics_BINARY_DIR})


# HELICS_SOURCE = os.path.join(setup_py_dir, "./_source")
# HELICS_VERSION = versioneer.get_version()
# HELICS_VERSION = re.findall(r"(?:(\d+\.(?:\d+\.)*\d+))", HELICS_VERSION)[0]
# HELICS_INSTALL = os.path.join(setup_py_dir, "./helics_apps/data")
# DOWNLOAD_URL = "https://github.com/GMLC-TDC/HELICS/releases/download/v{version}/Helics-v{version}-source.tar.gz".format(version=HELICS_VERSION)
endif()
12 changes: 10 additions & 2 deletions helics_apps-pip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ After upgrading pip, running `python -m pip install helics-apps` should fetch a
This package provides pre-compiled binary wheels for the following operating systems

* Linux 64-bit (manylinux2010 compatible -- glibc 2.12+, most popular distributions released since May 2010)
* macOS (10.9+) 64-bit
* macOS Universal2 -- compatible with 10.9+ for Intel macs and 11+ for Apple Silicon macs
* Windows 32/64-bit

### Source distributions
An attempt has been made at providing a source distribution that will compiled HELICS from source. Although minimal
An attempt has been made at providing a source distribution that will compile HELICS from source. Although minimal
support can be provided (e.g. you will need to troubleshoot issues yourself), PRs fixing issues are welcome.

Certain features may not be available when building from source, including the ZeroMQ core and any features that
rely on Boost (such as the interprocess core or web server).

If for some reason using a binary wheel is not an option but a source wheel is and you want to replicate the way the
supported binary wheels are built, set the `CIBUILDWHEEL` environment variable to tell the binary wheel build to
create a wheel from a pre-built HELICS release. Note that you *must* have an internet connection when installing
for this to work, and that it will *only work on glibc x86_64 Linux, 32/64-bit Windows, and macOS systems.

## Release
HELICS is distributed under the terms of the BSD-3 clause license. All new
contributions must be made under this license. [LICENSE](LICENSE)
Expand Down
2 changes: 1 addition & 1 deletion helics_apps-pip/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ sdist.include = ["helics_apps/_version.py"]
sdist.cmake = true

[tool.setuptools_scm] # Section required
version_scheme = "no-guess-dev" # Works well with SKBUILD version having postN and devM tags dropped
version_scheme = "no-guess-dev" # Works well with SKBUILD version having postN and devM tags dropped, good for getting current HELICS version to download
root = ".."
version_file = "helics_apps/_version.py"

0 comments on commit 4875b20

Please sign in to comment.