Skip to content

Commit

Permalink
Initial changes to switch helics_apps PyPI build over to using cibuil…
Browse files Browse the repository at this point in the history
…dwheel
  • Loading branch information
nightlark committed Feb 3, 2024
1 parent e8f33d2 commit 037e14f
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 2,569 deletions.
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
74 changes: 38 additions & 36 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,60 +20,62 @@ on:
jobs:
build-helics_apps:
# No container needed, since the package is version agnostic
name: Build ${{ matrix.build }}${{ matrix.arch }} wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
id: [linux, macos, win32, win64]
include:
- id: linux
os: ubuntu-latest
- id: macos
os: macos-latest
plat_name: macosx_10_9_intel
- id: win32
os: windows-latest
arch: win32
plat_name: win32
- id: win64
os: windows-latest
arch: win64
plat_name: win_amd64
- os: ubuntu-20.04
arch: "x86_64"
build: "manylinux_"
artifact_suffix: "manylinux_x86_64"
use_qemu: false
- os: windows-2019
arch: "AMD64"
build: ""
artifact_suffix: "windows_x86_64"
use_qemu: false
- os: windows-2019
arch: "x86"
build: ""
artifact_suffix: "windows_x86"
use_qemu: false
- os: macos-14
arch: "universal2"
build: ""
artifact_suffix: "macos"
use_qemu: false
steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- uses: actions/setup-python@v4
with:
python-version: '3.x'
architecture: 'x64'
- name: Create wheel
shell: bash
run: |
source ./helics_apps-pip/packaging_scripts/setup-${{ runner.os }}.sh "$(cat HELICS_VERSION)" "${{ matrix.arch }}"
./helics_apps-pip/packaging_scripts/build-${{ runner.os }}.sh "${{ matrix.plat_name }}"
./helics_apps-pip/packaging_scripts/repair-${{ runner.os }}.sh
fetch-depth: 0 # ensure history is present for automatic versioning
# - name: Set up QEMU
# uses: docker/[email protected]
# if: runner.os == 'Linux' && matrix.use_qemu
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: "${{ matrix.arch }}"
CIBW_ARCHS_MACOS: "universal2"
CIBW_BUILD: "cp39-${{ matrix.build }}*"
CIBW_BUILD_VERBOSITY: 3
TEST_ENV_VAR: "A VALUE!!!"
- uses: actions/upload-artifact@v4
with:
name: apps-python-dist
path: upload-wheelhouse
name: apps-python-dist-${{matrix.artifact_suffix}}
path: helics_apps-pip/wheelhouse/*.whl

build-helics_apps-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install -U pip install wheel setuptools cffi
fetch-depth: 0 # for setuptools_scm to find tags

- name: Build sdist
run: |
cd ./helics_apps-pip
python setup.py sdist
pipx run build --sdist
- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand All @@ -92,7 +94,7 @@ jobs:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Get the built packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_STORE
.vscode/

venv/

helics-src/
libzmq-src/
build/
dist/
_version.py
1 change: 0 additions & 1 deletion helics_apps-pip/.gitattributes

This file was deleted.

65 changes: 65 additions & 0 deletions helics_apps-pip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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

message(STATUS "--------------------")
message(STATUS "SYSTEM ${CMAKE_SYSTEM}")
message(STATUS "SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "SYSTEM_VERSION ${CMAKE_SYSTEM_VERSION}")
message(STATUS "SYSTEM_NAME ${CMAKE_SYSTEM_NAME}")
message(STATUS "APPLE ${APPLE}")
message(STATUS "LINUX ${LINUX}")
message(STATUS "UNIX ${UNIX}")
message(STATUS "WIN32 ${WIN32}")
message(STATUS "ENV(TEST_ENV_VAR) $ENV{TEST_ENV_VAR}")

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})

include(FetchContent)

# Only fetch source code files if it is building an sdist
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_BUILD_APP_LIBRARY ON)
set(HELICS_BUILD_APP_EXECUTABLES ON)
FetchContent_Declare(
helics
URL https://github.com/GMLC-TDC/HELICS/releases/download/v${SKBUILD_PROJECT_VERSION}/Helics-v${SKBUILD_PROJECT_VERSION}-source.tar.gz
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/helics-src
)

# For making the sdist, only need to download the source code
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)
4 changes: 0 additions & 4 deletions helics_apps-pip/MANIFEST.in

This file was deleted.

3 changes: 2 additions & 1 deletion helics_apps-pip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ This package provides pre-compiled binary wheels for the following operating sys
* Windows 32/64-bit

### Source distributions
Unfortunately, there is no source distribution for this package at this time since that requires compiling HELICS from source.
An attempt has been made at providing a source distribution that will compiled HELICS from source. Although minimal
support can be provided (e.g. you will need to troubleshoot issues yourself), PRs fixing issues are welcome.

## Release
HELICS is distributed under the terms of the BSD-3 clause license. All new
Expand Down
8 changes: 5 additions & 3 deletions helics_apps-pip/helics_apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import subprocess
import sys

from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
try:
from ._version import __version__, __version_tuple__
except ModuleNotFoundError:
__version__ = ""
__version_tuple__ = ()

DATA = os.path.join(os.path.dirname(__file__), 'data')

Expand Down
Loading

0 comments on commit 037e14f

Please sign in to comment.