From e4f75329a85ab88e871a9f4c0096810a46cde47a Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Mon, 9 Dec 2024 15:58:49 -0600 Subject: [PATCH 01/10] Update release.yaml to work with new upload/download actions/upload-artifact and actions/download-artifact both were updated with breaking changes which caused release.yaml not to run anymore. This attempts to fix the release mechanism to working order again. Key change is that upload-artifact must now use unique names and dowload-artifact must be changed to merge all files into a single directory for twine to pick up. --- .github/workflows/release.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 09c283805..c78ea7ea8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -113,6 +113,7 @@ jobs: - uses: actions/upload-artifact@v4 with: + name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }} path: ./dist/* release: @@ -122,6 +123,9 @@ jobs: steps: - name: download files uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: artifact - name: set up Python 3.10 uses: actions/setup-python@v4 From d76bb7663172afaf266ddf83b9aca2ba42c88719 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Mon, 9 Dec 2024 16:48:25 -0600 Subject: [PATCH 02/10] Update the python used to build --- .github/workflows/release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c78ea7ea8..9fdaa0f9e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -54,7 +54,8 @@ jobs: - name: set up python uses: actions/setup-python@v4 with: - python-version: "3.10" + # NOTE: future versions of cibuildwheel need python 3.11+ + python-version: "3.11" - name: install Python dependencies run: pip install -U setuptools wheel twine cibuildwheel pytest From 7f98fa4c88ce7f54abb67a11a14ae0304b3deeff Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Mon, 9 Dec 2024 16:57:39 -0600 Subject: [PATCH 03/10] Ensure the latest pip is installed Apple silicon builds have a requirement for a recent pip. --- .github/workflows/release.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9fdaa0f9e..0b356b562 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -57,6 +57,9 @@ jobs: # NOTE: future versions of cibuildwheel need python 3.11+ python-version: "3.11" + - name: Upgrade to latest pip + run: python -m pip install --upgrade pip + - name: install Python dependencies run: pip install -U setuptools wheel twine cibuildwheel pytest From 53a78398af44a1d0dd495a2756d6779d781d468b Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 11 Dec 2024 14:37:17 -0700 Subject: [PATCH 04/10] Update release.yml Attempt to use separate intel and apple silicon builds vs trying to use the universal build for wheels. This is faciliated by using macos-13 (Intel) and macos-14 (Apple Silicon). --- .github/workflows/release.yaml | 79 ++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0b356b562..19574b9c6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,6 +5,8 @@ on: types: [published] workflow_dispatch: +# NOTE: parts inspired by https://cibuildwheel.pypa.io/en/stable/setup/ + jobs: build: name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} @@ -12,28 +14,29 @@ jobs: fail-fast: true matrix: os: - - ubuntu - - macos - - windows + - ubuntu-latest + - macos-13 # Intel runner + - macos-14 # Apple Silicon runner + - windows-latest python-version: - "8" - "9" - "10" include: - - os: ubuntu + - os: ubuntu-latest platform: linux - - os: windows + - os: windows-latest ls: dir env: FASTSIM_DISABLE_NETWORK_TESTS: 1 - runs-on: ${{ format('{0}-latest', matrix.os) }} + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: set up rust - if: matrix.os != 'ubuntu' + if: matrix.os != 'ubuntu-latest' uses: actions-rs/toolchain@v1 with: profile: minimal @@ -41,7 +44,7 @@ jobs: override: true - run: rustup target add aarch64-apple-darwin - if: matrix.os == 'macos' + if: matrix.os == 'macos-14' - name: run cargo tests uses: actions-rs/toolchain@v1 @@ -55,7 +58,7 @@ jobs: uses: actions/setup-python@v4 with: # NOTE: future versions of cibuildwheel need python 3.11+ - python-version: "3.11" + python-version: "3.10" - name: Upgrade to latest pip run: python -m pip install --upgrade pip @@ -64,21 +67,21 @@ jobs: run: pip install -U setuptools wheel twine cibuildwheel pytest - name: build source distribution - if: matrix.os == 'ubuntu' && matrix.python-version == '10' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '10' run: | pip install -U setuptools-rust python -c "import setuptools; setuptools.setup()" sdist - name: build ${{ matrix.platform || matrix.os }} binaries - run: cibuildwheel --output-dir dist + uses: pypa/cibuildwheel@2.22.0 env: CIBW_BUILD: "cp3${{ matrix.python-version }}-*" CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64" - CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} + # CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} # TODO: why doesn't pytest work with cibuildwheel? # CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests" CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests" - CIBW_ARCHS_MACOS: "universal2" + # CIBW_ARCHS_MACOS: "universal2" # see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2 CIBW_TEST_SKIP: "*_universal2:arm64" CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' @@ -96,34 +99,38 @@ jobs: rustup show CIBW_BEFORE_BUILD_MACOS: > rustup target add x86_64-apple-darwin - # - name: build windows 32bit binaries - # if: matrix.os == 'windows' - # run: cibuildwheel --output-dir dist - # env: - # CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' - # CIBW_PLATFORM: windows - # CIBW_TEST_REQUIRES: 'pytest' - # CIBW_TEST_COMMAND: 'pytest {project}/tests -s' - # CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' - # CIBW_BEFORE_BUILD: > - # pip install -U setuptools-rust && - # rustup toolchain install nightly-i686-pc-windows-msvc && - # rustup default nightly-i686-pc-windows-msvc && - # rustup override set nightly-i686-pc-windows-msvc && - # rustup show - - - name: list dist files - run: ${{ matrix.ls || 'ls -lh' }} dist/ + # - name: build windows 32bit binaries + # if: matrix.os == 'windows' + # run: cibuildwheel --output-dir dist + # env: + # CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' + # CIBW_PLATFORM: windows + # CIBW_TEST_REQUIRES: 'pytest' + # CIBW_TEST_COMMAND: 'pytest {project}/tests -s' + # CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' + # CIBW_BEFORE_BUILD: > + # pip install -U setuptools-rust && + # rustup toolchain install nightly-i686-pc-windows-msvc && + # rustup default nightly-i686-pc-windows-msvc && + # rustup override set nightly-i686-pc-windows-msvc && + # rustup show + + - name: list wheelhouse files + run: ${{ matrix.ls || 'ls -lh' }} ./wheelhouse/ - uses: actions/upload-artifact@v4 with: - name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }} - path: ./dist/* + name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl release: needs: build name: release files to PyPI runs-on: ubuntu-latest + # Protection Strategies -- use ONE of the following two lines: + if: false + # if: github.event_name == 'release' && github.event.action == 'published' # publish on via explicit publish + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # publish on tag starting w/ 'v' steps: - name: download files uses: actions/download-artifact@v4 @@ -131,10 +138,10 @@ jobs: merge-multiple: true path: artifact - - name: set up Python 3.10 + - name: set up Python 3.11 uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - run: pip install twine From 319c9f6ae70c411cd0173353948e32a1824a4ebc Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 11 Dec 2024 14:52:33 -0700 Subject: [PATCH 05/10] Correct typo in version specifier for cibuildwheel --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 19574b9c6..6565c0f67 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -73,7 +73,7 @@ jobs: python -c "import setuptools; setuptools.setup()" sdist - name: build ${{ matrix.platform || matrix.os }} binaries - uses: pypa/cibuildwheel@2.22.0 + uses: pypa/cibuildwheel@v2.22.0 env: CIBW_BUILD: "cp3${{ matrix.python-version }}-*" CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64" From 1501d31205ff60d49997819a5ae0462a81f4a8b7 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 11 Dec 2024 15:59:44 -0700 Subject: [PATCH 06/10] Add environment variable for building on intel mac The variable 'MACOSX_DEPLOYMENT_TARGET=10.12' is needed to updated minimum supported macOS for this wheel. --- .github/workflows/release.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6565c0f67..c5c57ea98 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -72,6 +72,10 @@ jobs: pip install -U setuptools-rust python -c "import setuptools; setuptools.setup()" sdist + - name: Update minimum supported MacOS for Wheels for MacOS 13 (Intel Mac) + run: echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV + if: matrix.os == 'macos-13' + - name: build ${{ matrix.platform || matrix.os }} binaries uses: pypa/cibuildwheel@v2.22.0 env: From 0c94bfb0974a25cfeea8e9d9c9e4a4ac1f71c1de Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 11 Dec 2024 16:47:04 -0700 Subject: [PATCH 07/10] Update to macos-latest from macos-14 --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c5c57ea98..cd61f4d7c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -16,7 +16,7 @@ jobs: os: - ubuntu-latest - macos-13 # Intel runner - - macos-14 # Apple Silicon runner + - macos-latest # Apple Silicon runner - windows-latest python-version: - "8" @@ -44,7 +44,7 @@ jobs: override: true - run: rustup target add aarch64-apple-darwin - if: matrix.os == 'macos-14' + if: matrix.os == 'macos-latest' - name: run cargo tests uses: actions-rs/toolchain@v1 From fdda5ab25be7cf7b417b831e6065307f52030090 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 11 Dec 2024 17:07:17 -0700 Subject: [PATCH 08/10] Remove protection on release --- .github/workflows/release.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cd61f4d7c..4bc895af5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -132,7 +132,6 @@ jobs: name: release files to PyPI runs-on: ubuntu-latest # Protection Strategies -- use ONE of the following two lines: - if: false # if: github.event_name == 'release' && github.event.action == 'published' # publish on via explicit publish # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # publish on tag starting w/ 'v' steps: From f5dddade3b12944fe8b18004b115c7d9a0100753 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Fri, 13 Dec 2024 06:56:22 -0700 Subject: [PATCH 09/10] Add explicit if statement to release only on publish --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4bc895af5..6b3a900d5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -132,7 +132,7 @@ jobs: name: release files to PyPI runs-on: ubuntu-latest # Protection Strategies -- use ONE of the following two lines: - # if: github.event_name == 'release' && github.event.action == 'published' # publish on via explicit publish + if: github.event_name == 'release' && github.event.action == 'published' # publish on via explicit publish # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # publish on tag starting w/ 'v' steps: - name: download files From 1906b2aab6a74dec0fc71c73a5a0fd792b2448a1 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Thu, 2 Jan 2025 08:38:47 -0700 Subject: [PATCH 10/10] Fix issue with .github\workflows\wheels.yml The `wheels.yml` file did not receive the required updates and changes needed for building with Mac OS for Apple Silicon AND Apple Intel. These changes have now been copied over such that the `wheels.yml` file is essentially the same as the first part of the `release.yml` file. We may be able to eliminate the `wheels.yml` workflow in the future although it is helpful as a check to confirm that the `release.yml` file (at least, the "build" section) will run without issue. --- .github/workflows/wheels.yaml | 83 +++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index bbc27ea9b..63c475f3c 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -7,6 +7,8 @@ on: - "v[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: +# NOTE: parts inspired by https://cibuildwheel.pypa.io/en/stable/setup/ + jobs: build: name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} @@ -14,25 +16,29 @@ jobs: fail-fast: true matrix: os: - - ubuntu - - macos - - windows + - ubuntu-latest + - macos-13 # Intel runner + - macos-latest # Apple Silicon runner + - windows-latest python-version: - "8" - "9" - "10" include: - - os: ubuntu + - os: ubuntu-latest platform: linux - - os: windows + - os: windows-latest ls: dir - runs-on: ${{ format('{0}-latest', matrix.os) }} + env: + FASTSIM_DISABLE_NETWORK_TESTS: 1 + + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: set up rust - if: matrix.os != 'ubuntu' + if: matrix.os != 'ubuntu-latest' uses: actions-rs/toolchain@v1 with: profile: minimal @@ -40,7 +46,7 @@ jobs: override: true - run: rustup target add aarch64-apple-darwin - if: matrix.os == 'macos' + if: matrix.os == 'macos-latest' - name: run cargo tests uses: actions-rs/toolchain@v1 @@ -53,27 +59,35 @@ jobs: - name: set up python uses: actions/setup-python@v4 with: + # NOTE: future versions of cibuildwheel need python 3.11+ python-version: "3.10" + - name: Upgrade to latest pip + run: python -m pip install --upgrade pip + - name: install Python dependencies run: pip install -U setuptools wheel twine cibuildwheel pytest - name: build source distribution - if: matrix.os == 'ubuntu' && matrix.python-version == '10' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '10' run: | pip install -U setuptools-rust python -c "import setuptools; setuptools.setup()" sdist + - name: Update minimum supported MacOS for Wheels for MacOS 13 (Intel Mac) + run: echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV + if: matrix.os == 'macos-13' + - name: build ${{ matrix.platform || matrix.os }} binaries - run: cibuildwheel --output-dir dist + uses: pypa/cibuildwheel@v2.22.0 env: CIBW_BUILD: "cp3${{ matrix.python-version }}-*" CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64" - CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} + # CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} # TODO: why doesn't pytest work with cibuildwheel? # CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests" CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests" - CIBW_ARCHS_MACOS: "universal2" + # CIBW_ARCHS_MACOS: "universal2" # see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2 CIBW_TEST_SKIP: "*_universal2:arm64" CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' @@ -91,25 +105,26 @@ jobs: rustup show CIBW_BEFORE_BUILD_MACOS: > rustup target add x86_64-apple-darwin - # - name: build windows 32bit binaries - # if: matrix.os == 'windows' - # run: cibuildwheel --output-dir dist - # env: - # CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' - # CIBW_PLATFORM: windows - # CIBW_TEST_REQUIRES: 'pytest' - # CIBW_TEST_COMMAND: 'pytest {project}/tests -s' - # CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' - # CIBW_BEFORE_BUILD: > - # pip install -U setuptools-rust && - # rustup toolchain install nightly-i686-pc-windows-msvc && - # rustup default nightly-i686-pc-windows-msvc && - # rustup override set nightly-i686-pc-windows-msvc && - # rustup show - - - name: list dist files - run: ${{ matrix.ls || 'ls -lh' }} dist/ - - - uses: actions/upload-artifact@v3 + # - name: build windows 32bit binaries + # if: matrix.os == 'windows' + # run: cibuildwheel --output-dir dist + # env: + # CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' + # CIBW_PLATFORM: windows + # CIBW_TEST_REQUIRES: 'pytest' + # CIBW_TEST_COMMAND: 'pytest {project}/tests -s' + # CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' + # CIBW_BEFORE_BUILD: > + # pip install -U setuptools-rust && + # rustup toolchain install nightly-i686-pc-windows-msvc && + # rustup default nightly-i686-pc-windows-msvc && + # rustup override set nightly-i686-pc-windows-msvc && + # rustup show + + - name: list wheelhouse files + run: ${{ matrix.ls || 'ls -lh' }} ./wheelhouse/ + + - uses: actions/upload-artifact@v4 with: - path: ./dist/* + name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl