diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78aaee0..1ca1389 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,14 +2,6 @@ name: Build on: workflow_dispatch: - inputs: - branch: - description: 'Branch to build' - required: true - type: choice - options: - - master - - refs/remotes/** push: branches: - develop/* @@ -19,18 +11,47 @@ on: release: types: [ published ] +env: + PYTHON_VERSIONS: "3.10,3.11,3.12,3.13,3.14" + +concurrency: + cancel-in-progress: false + # This creates different concurrency groups depending on the trigger + # For PRs: uses the PR number (e.g., "build-pr-123") + # For branch pushes: uses the branch name (e.g., "build-develop/feature-x") + # For releases: uses the release tag plus a unique run ID so each release runs independently + # For manual dispatches: uses a unique run ID so each dispatch runs independently + group: ${{ github.event_name == 'pull_request' && format('build-pr-{0}', github.event.pull_request.number) || github.event_name == 'push' && format('build-{0}', github.ref) || github.event_name == 'release' && format('build-release-{0}-{1}', github.event.release.tag_name, github.run_id) || format('build-dispatch-{0}', github.run_id) }} + defaults: run: shell: bash jobs: + setup: + runs-on: ubuntu-latest + outputs: + python-versions: ${{ steps.set-matrix.outputs.python-versions }} + cibw-build: ${{ steps.set-matrix.outputs.cibw-build }} + steps: + - id: set-matrix + run: | + # Convert "3.10,3.11,3.12" to ["3.10","3.11","3.12"] + python_array=$(echo '["${{ env.PYTHON_VERSIONS }}"]' | sed 's/,/","/g') + echo "python-versions=$python_array" >> $GITHUB_OUTPUT + + # Convert "3.10,3.11,3.12" to "cp310-* cp311-* cp312-*" + cibw=$(echo "${{ env.PYTHON_VERSIONS }}" | sed 's/\.//g; s/,/ /g; s/\([0-9]*\)/cp\1-*/g') + echo "cibw-build=$cibw" >> $GITHUB_OUTPUT + build_wheels_windows: name: Build wheels on Windows + needs: setup runs-on: windows-latest strategy: fail-fast: False matrix: - python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ] + python-version: ${{ fromJSON(needs.setup.outputs.python-versions) }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -56,11 +77,12 @@ jobs: build_wheels_unix: name: Build wheels on ${{ matrix.os }} + needs: setup runs-on: ${{ matrix.os }} strategy: fail-fast: False matrix: - os: [ ubuntu-latest, macos-latest, macos-13 ] + os: [ ubuntu-latest, macos-latest, macos-14 ] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -74,8 +96,8 @@ jobs: - name: Build wheels env: - # only build CPython-3.9+ and skip 32-bit builds - CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-* + # only build CPython-3.10+ and skip 32-bit builds + CIBW_BUILD: ${{ needs.setup.outputs.cibw-build }} CIBW_SKIP: "*-manylinux_i686 *-musllinux*" # use latest build CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64 @@ -94,12 +116,12 @@ jobs: test-wheels: name: Test wheels - needs: [ build_wheels_windows, build_wheels_unix ] + needs: [ setup, build_wheels_windows, build_wheels_unix ] runs-on: ${{ matrix.os }} strategy: matrix: - os: [ windows-latest, ubuntu-latest, macos-latest, macos-13 ] - python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ] + os: [ windows-latest, ubuntu-latest, macos-latest, macos-14 ] + python-version: ${{ fromJSON(needs.setup.outputs.python-versions) }} steps: - name: Checkout repository @@ -138,6 +160,11 @@ jobs: else chunk="${{matrix.os}}" fi + + echo "Runner OS: ${{ runner.os }}" + echo "os : ${os}" + echo "version : ${version}" + echo "chunk : ${chunk}" # this finds files like # nlopt-2.6.2-cp36-cp36m-win_amd64.whl diff --git a/extensions.py b/extensions.py index feade1b..0c599c5 100644 --- a/extensions.py +++ b/extensions.py @@ -54,49 +54,64 @@ def build_extension(self, ext: Extension): "-DNLOPT_GUILE=OFF", "-DNLOPT_MATLAB=OFF", "-DNLOPT_OCTAVE=OFF", - ext.source_dir.as_posix() + ext.source_dir.as_posix(), ] if platform.system() == "Windows": - cmd.insert(2, f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{self.config.upper()}={_ed}") + cmd.insert( + 2, f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{self.config.upper()}={_ed}" + ) execute_command( cmd=cmd, cwd=build_dir, env={ **os.environ.copy(), - "CXXFLAGS": f'{os.environ.get("CXXFLAGS", "")} -DVERSION_INFO="{self.distribution.get_version()}"' - }) + "CXXFLAGS": f'{os.environ.get("CXXFLAGS", "")} -DVERSION_INFO="{self.distribution.get_version()}"', + }, + ) # build the DLL - execute_command([ - 'cmake', - '--build', - '.', - '--config', - self.config, - "--", - "-m" if platform.system() == "Windows" else "-j2" - ], cwd=build_dir) + execute_command( + [ + "cmake", + "--build", + ".", + "--config", + self.config, + "--", + "-m" if platform.system() == "Windows" else "-j2", + ], + cwd=build_dir, + ) # Copy over the important bits nlopt_py = build_dir / "extern" / "nlopt" / "src" / "swig" / "python" / "nlopt.py" - logging.info(f"Ext Dir - {ext_dir}\n" + '\n'.join(f' - {file.as_posix()}' for file in ext_dir.rglob('*'))) + logging.info( + f"Ext Dir - {ext_dir}\n" + + "\n".join(f" - {file.as_posix()}" for file in ext_dir.rglob("*")) + ) for folder in [ext_dir, nlopt_py.parent]: - logging.info(f'Files in {folder.as_posix()}\n' + '\n'.join(f' - {f.name}' for f in folder.iterdir())) - - logging.info(f"Attempting to copy nlopt.py file from {nlopt_py.parent.as_posix()} to {ext_dir.as_posix()}") + logging.info( + f"Files in {folder.as_posix()}\n" + + "\n".join(f" - {f.name}" for f in folder.iterdir()) + ) + + logging.info( + f"Attempting to copy nlopt.py file from {nlopt_py.parent.as_posix()} to {ext_dir.as_posix()}" + ) if not nlopt_py.exists(): raise RuntimeError("swig python file was not generated") shutil.copy2(nlopt_py, ext_dir / "nlopt.py") - with open(ext_dir / "__init__.py", 'w') as f: - f.write(f""" -from .nlopt import * + with open(ext_dir / "__init__.py", "w") as f: + f.write( + f"""from .nlopt import * __version__ = '{ext.version}' -""".strip() + "\n") +""".lstrip() + ) def create_directory(path: Path): diff --git a/extern/nlopt b/extern/nlopt index 7d04da1..8dea251 160000 --- a/extern/nlopt +++ b/extern/nlopt @@ -1 +1 @@ -Subproject commit 7d04da19236148f9ae9d8dfa470a2264f5d2aa33 +Subproject commit 8dea25183daeb7f601c7469ca2a45e8c580a5688