Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 2 additions & 41 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,8 @@ runs:
requirements_doc.txt
requirements.txt

- name: Install Linux System Deps.
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y build-essential python3-setuptools python3-tk libgtk2.0

- name: SWIG Install (Linux)
if: runner.os == 'Linux'
uses: mmomtchev/setup-swig@v4
with:
version: v4.2.1

- name: SWIG Install (macOS)
if: runner.os == 'macOS'
shell: bash
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_UPGRADE: 1
HOMEBREW_NO_ANALYTICS: 1
run: brew install swig || true

- name: SWIG Install (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$swigDir = "C:\Program Files\SWIG"
if (!(Test-Path $swigDir)) {New-Item -ItemType Directory -Path $swigDir | Out-Null}
$swigZip = "$swigDir\swigwin-4.2.1.zip"
$swigUrl = "https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.2.1/swigwin-4.2.1.zip/download"
Start-Process -NoNewWindow -Wait -FilePath "curl.exe" -ArgumentList "-L -o `"$swigZip`" `"$swigUrl`""
if (!(Test-Path $swigZip) -or ((Get-Item $swigZip).Length -lt 500KB)) { Write-Host "Download failed or file is corrupted." }
Expand-Archive -Path $swigZip -DestinationPath $swigDir -Force

- name: "Add Basilisk and SWIG paths"
if: runner.os == 'Windows'
shell: pwsh
run: |
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
$newPath = “C:\Program Files\SWIG\swigwin-4.2.1;$oldpath;${{ env.GITHUB_WORKSPACE }}\dist3\Basilisk”
echo "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup system dependencies
uses: ./.github/actions/setup

- name: Install requirements
shell: bash
Expand Down
48 changes: 48 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: setup
description: >
Sets up the required system dependencies to perform a Basilisk build

runs:
using: "composite"
steps:
- name: Install Linux System Deps.
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y build-essential python3-setuptools python3-tk libgtk2.0

- name: SWIG Install (Linux)
if: runner.os == 'Linux'
uses: mmomtchev/setup-swig@v4
with:
version: v4.2.1

- name: SWIG Install (macOS)
if: runner.os == 'macOS'
shell: bash
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_UPGRADE: 1
HOMEBREW_NO_ANALYTICS: 1
run: brew install swig || true

- name: SWIG Install (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$swigDir = "C:\Program Files\SWIG"
if (!(Test-Path $swigDir)) {New-Item -ItemType Directory -Path $swigDir | Out-Null}
$swigZip = "$swigDir\swigwin-4.2.1.zip"
$swigUrl = "https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.2.1/swigwin-4.2.1.zip/download"
Start-Process -NoNewWindow -Wait -FilePath "curl.exe" -ArgumentList "-L -o `"$swigZip`" `"$swigUrl`""
if (!(Test-Path $swigZip) -or ((Get-Item $swigZip).Length -lt 500KB)) { Write-Host "Download failed or file is corrupted." }
Expand-Archive -Path $swigZip -DestinationPath $swigDir -Force

- name: "Add Basilisk and SWIG paths"
if: runner.os == 'Windows'
shell: pwsh
run: |
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
$newPath = “C:\Program Files\SWIG\swigwin-4.2.1;$oldpath;${{ env.GITHUB_WORKSPACE }}\dist3\Basilisk”
echo "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
34 changes: 6 additions & 28 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
token: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Bump version
id: bump
run: ./.github/workflows/version-bumper.sh ./docs/source/bskVersion.txt

- name: Commit and push
Expand All @@ -35,35 +36,12 @@ jobs:
git commit -a -m "[AUTO] Bump version number" || echo "No changes"
git push || true

build-ubuntu-latest-wheels:
name: Build ubuntu-latest wheels
needs: bump_version
# Allow for manual runs to generate new wheels
if: ${{ always() }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v4

# The 'Build wheel' step will perform the actual build. However, we want
# all pre build setup to still be performed
- uses: ./.github/actions/build
with:
python-version: ${{ matrix.python-version }}
extra-apt: "cmake"
skip-build: true

- name: Build wheel
- name: Create tag
if: ${{ steps.bump.outputs.updated_version != '' }}
run: |
python -m pip wheel . -v --wheel-dir /tmp/wheelhouse

- uses: actions/upload-artifact@v4
with:
name: basilisk-wheels_ubuntu-22.04_python${{ matrix['python-version'] }}
path: /tmp/wheelhouse/**/*asilisk*.whl
git tag -a "v${{ steps.bump.outputs.updated_version }}" \
-m "Release v${{ steps.bump.outputs.updated_version }}"
git push --tags

build_documentation:
name: macOS Docs Deployment
Expand Down
144 changes: 144 additions & 0 deletions .github/workflows/publish-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Publish Wheels

on:
push:
tags:
- "v[0-9]*"
- "test*"

jobs:
build-wheels:
name: Build Basilisk Wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-13 # x86_64
- macos-latest # ARM64
- ubuntu-latest # x86_64
- ubuntu-22.04-arm # ARM64
- windows-latest # x86_64

steps:
- name: Checkout Code
uses: actions/checkout@v5
with:
ref: ${{ github.ref }}
# Workaround for macos-13 (Intel). Ensures the conan build uses the right
# SSL cert.
- name: Set CA bundle (macos-13 only)
if: ${{ matrix.os == 'macos-13' }}
shell: bash
run: |
python -m pip install -U certifi
CA="$(python -c 'import certifi; print(certifi.where())')"
{
echo "REQUESTS_CA_BUNDLE=$CA" # Python requests / Conan
echo "PIP_CERT=$CA" # pip
echo "SSL_CERT_FILE=$CA" # OpenSSL consumers
echo "CURL_CA_BUNDLE=$CA" # curl / CMake file(DOWNLOAD)
echo "CMAKE_TLS_CAINFO=$CA" # CMake
} >> "$GITHUB_ENV"
echo "Using CA: $CA"

- name: Setup system dependencies
uses: ./.github/actions/setup

- name: Build wheels
uses: pypa/[email protected]
env:
CONAN_ARGS: "--opNav True --mujoco True --mujocoReplay True --recorderPropertyRollback True"
CIBW_TEST_REQUIRES_WINDOWS: "numpy>=2.1"

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.ref }}

- uses: actions/setup-python@v5
with:
python-version: 3.13

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

publish:
name: Publish to PyPI
needs: [build-wheels, make_sdist]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout tagged source
uses: actions/checkout@v5
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Download wheels
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-*
merge-multiple: true
path: dist

- name: Download sdist
uses: actions/download-artifact@v4
with:
name: cibw-sdist
path: dist

- name: Verify versions match tag
shell: bash
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG="${GITHUB_REF##*/}"
VER="${TAG#v}"
echo "Tag: $TAG Version: $VER"
shopt -s nullglob
[[ -e dist/*"$VER"*.whl ]] || { echo "No wheel with $VER"; exit 1; }
[[ -e dist/*"$VER"*.tar.gz ]] || { echo "No sdist with $VER"; exit 1; }
echo "OK — artifacts match $VER"

- name: Show release info
shell: bash
run: |
echo "Release Info:"
TAG="${GITHUB_REF##*/}"
VER="${TAG#v}"
echo "Release tag: $TAG"
echo "Release ver: $VER"
echo
echo "Artifacts in dist/:"
ls -lh dist || true

- name: Publish to TestPyPI (test tags)
if: startsWith(github.ref, 'refs/tags/test')
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist
skip-existing: true
verbose: true

- name: Publish to PyPI (real releases)
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
10 changes: 9 additions & 1 deletion .github/workflows/version-bumper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ while IFS= read -r version || [[ -n "$version" ]]; do
fi
done < $1

echo "$updated_version" > $1
echo "$updated_version" > $1

# Expose the update versions to GitHub Actions
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
{
echo "version=$version"
echo "updated_version=$updated_version"
} >> "$GITHUB_OUTPUT"
fi
13 changes: 13 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
prune examples
prune docs
prune src/tests
prune **/_UnitTest
prune **/_Documentation

global-exclude *.pdf *.png *.jpg *.jpeg *.gif *.JPG *.svg *.psd
global-exclude *.ipynb *.bib *.tex
global-exclude *.mex* *.o *.a *.so *.dylib *.dll
global-exclude build/** CMakeFiles/** .git/** .github/** .venv/**

# This file is used by SWIG
include src/fswAlgorithms/effectorInterfaces/thrForceMapping/_UnitTest/Support/Results_thrForceMapping.py
46 changes: 46 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
from datetime import datetime
from typing import Optional, Callable
from glob import glob

import importlib.metadata
from packaging.requirements import Requirement
Expand Down Expand Up @@ -252,6 +253,14 @@ def layout(self):
self.folders.build = str(self.options.get_safe("buildFolder"))

def generate(self):
if self.settings.os == "Windows":
# Ensure dependent DLLs are copied into the Basilisk package
# directory inside the build folder so they can be discovered by
# packaging tools (delvewheel) and included in wheels.
basilisk_dst = os.path.join(self.build_folder, "Basilisk")
for dep in self.dependencies.values():
for bindir in dep.cpp_info.bindirs:
copy(self, "*.dll", bindir, basilisk_dst)
if self.settings.os == "Windows":
for dep in self.dependencies.values():
for libdir in dep.cpp_info.bindirs:
Expand Down Expand Up @@ -309,6 +318,8 @@ def generate(self):
# Set the minimum buildable MacOS version.
# tc.cache_variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = "10.13"
tc.parallel = True
if self.options.get_safe("pyLimitedAPI"):
tc.cache_variables["PY_LIMITED_API"] = str(self.options.pyLimitedAPI)

# Generate!
tc.generate()
Expand All @@ -329,6 +340,41 @@ def build(self):
cmake.build()
print("Total Build Time: " + str(datetime.now() - start))
print(f"{statusColor}The Basilisk build is successful and the scripts are ready to run{endColor}")
# On Windows, copy project-built DLLs next to the Python extension modules
# so they are bundled in the wheel and resolvable at runtime without PATH tweaks.
if self.settings.os == "Windows":
basilisk_dst_root = os.path.join(self.build_folder, "Basilisk")
common_srcs = [
os.path.join(self.build_folder, "bin"),
os.path.join(self.build_folder, "Release"),
os.path.join(self.build_folder, "Debug"),
]
for src in common_srcs:
if os.path.isdir(src):
try:
copy(self, "*.dll", src, basilisk_dst_root)
except Exception as e:
self.output.warning(f"Failed to copy DLLs from {src}: {e}")

# As a fallback, scan the build tree for any remaining DLLs.
for root, _dirs, files in os.walk(self.build_folder):
# Skip the destination to avoid self-copy
if os.path.commonpath([root, basilisk_dst_root]) == basilisk_dst_root:
continue
if any(f.lower().endswith(".dll") for f in files):
try:
copy(self, "*.dll", root, basilisk_dst_root)
except Exception as e:
self.output.warning(f"Failed to copy DLLs from {root}: {e}")

# Rename DLLs to lowercase
for path in glob(os.path.join(basilisk_dst_root, "*.dll")):
base = os.path.basename(path)
lower = base.lower()
if base != lower:
tmp = os.path.join(basilisk_dst_root, f".{lower}.tmp")
os.replace(path, tmp)
os.replace(tmp, os.path.join(basilisk_dst_root, lower))
else:
print(f"{statusColor}Finished configuring the Basilisk project.{endColor}")
if self.settings.os != "Linux":
Expand Down
Loading