Skip to content

Commit 5de71ec

Browse files
Remove some missed stuff from the build (#4751)
* Remove some missed stuff from the build * style: pre-commit fixes * Simplify deployment * Fix style issue * Review changes * More review comments * nitpick * Fix schema error --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3d0c10a commit 5de71ec

File tree

5 files changed

+13
-258
lines changed

5 files changed

+13
-258
lines changed

.github/release_workflow.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ GitHub, PyPI, and conda-forge by the maintainers.
1313
- `docs/conf.py`
1414
- `CITATION.cff`
1515
- `pyproject.toml`
16-
- `vcpkg.json`
1716
- `CHANGELOG.md`
1817

1918
These changes will be automatically pushed to a new branch `vYY.MM`
@@ -42,7 +41,6 @@ If a new release is required after the release of `vYY.MM.{x-1}` -
4241
- `docs/conf.py`
4342
- `CITATION.cff`
4443
- `pyproject.toml`
45-
- `vcpkg.json`
4644
- `CHANGELOG.md`
4745

4846
Commit the changes to your release branch.

.github/wheel_failure.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/publish_pypi.yml

Lines changed: 13 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -2,178 +2,9 @@ name: Build and publish package to PyPI
22
on:
33
release:
44
types: [published]
5-
schedule:
6-
# Run at 10 am UTC on day-of-month 1 and 15.
7-
- cron: "0 10 1,15 * *"
8-
workflow_dispatch:
9-
inputs:
10-
target:
11-
description: 'Deployment target. Can be "pypi" or "testpypi"'
12-
default: "testpypi"
13-
debug_enabled:
14-
type: boolean
15-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
16-
required: false
17-
default: false
18-
19-
# Set options available for all jobs that use cibuildwheel
20-
env:
21-
PYBAMM_DISABLE_TELEMETRY: "true"
22-
# Increase pip debugging output, equivalent to `pip -vv`
23-
CIBW_BUILD_VERBOSITY: 2
24-
# Disable build isolation to allow pre-installing build-time dependencies.
25-
# Note: CIBW_BEFORE_BUILD must be present in all jobs using cibuildwheel.
26-
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"
27-
# Skip PyPy and MUSL builds in any and all jobs
28-
CIBW_SKIP: "pp* *musllinux*"
29-
FORCE_COLOR: 3
305

316
jobs:
32-
build_windows_wheels:
33-
name: Wheels (windows-latest)
34-
runs-on: windows-latest
35-
steps:
36-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37-
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
38-
with:
39-
python-version: 3.11
40-
41-
- name: Get number of cores on Windows
42-
id: get_num_cores
43-
shell: python
44-
run: |
45-
from os import environ, cpu_count
46-
num_cpus = cpu_count()
47-
output_file = environ['GITHUB_OUTPUT']
48-
with open(output_file, "a", encoding="utf-8") as output_stream:
49-
output_stream.write(f"count={num_cpus}\n")
50-
51-
- name: Cache packages installed through vcpkg on Windows
52-
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
53-
env:
54-
cache-name: vckpg_binary_cache
55-
with:
56-
path: C:\Users\runneradmin\AppData\Local\vcpkg\archives
57-
key: ${{ runner.os }}-build-VS2022-${{ env.cache-name }}-${{ hashFiles('vcpkg*.json') }}
58-
59-
# Enable tmate debugging of manually-triggered workflows if the input option was provided
60-
- name: Setup tmate session
61-
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48 # v3.19
62-
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
63-
64-
- name: Build 64-bit wheels on Windows
65-
run: pipx run cibuildwheel --output-dir wheelhouse
66-
env:
67-
CIBW_ENVIRONMENT: >
68-
PYBAMM_DISABLE_TELEMETRY="true"
69-
PYBAMM_USE_VCPKG=ON
70-
VCPKG_ROOT_DIR=C:\vcpkg
71-
VCPKG_DEFAULT_TRIPLET=x64-windows-static-md
72-
VCPKG_FEATURE_FLAGS=manifests,registries
73-
CMAKE_GENERATOR="Visual Studio 17 2022"
74-
CMAKE_GENERATOR_PLATFORM=x64
75-
CMAKE_BUILD_PARALLEL_LEVEL=${{ steps.get_num_cores.outputs.count }}
76-
CIBW_ARCHS: AMD64
77-
CIBW_BEFORE_BUILD: python -m pip install setuptools delvewheel # skip CasADi and CMake
78-
# Fix access violation because GHA runners have modified PATH that picks wrong
79-
# msvcp140.dll, see https://github.com/adang1345/delvewheel/issues/54
80-
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair --add-path C:/Windows/System32 -w {dest_dir} {wheel}
81-
CIBW_TEST_EXTRAS: "all,dev,jax"
82-
CIBW_TEST_COMMAND: |
83-
python -m pytest -m cibw {project}/tests/unit
84-
- name: Upload Windows wheels
85-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
86-
with:
87-
name: wheels_windows
88-
path: ./wheelhouse/*.whl
89-
if-no-files-found: error
90-
91-
build_manylinux_wheels:
92-
name: Wheels (linux-amd64)
93-
runs-on: ubuntu-latest
94-
steps:
95-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96-
name: Check out PyBaMM repository
97-
98-
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
99-
name: Set up Python
100-
with:
101-
python-version: 3.11
102-
103-
- name: Build wheels on Linux
104-
run: pipx run cibuildwheel --output-dir wheelhouse
105-
env:
106-
CIBW_ENVIRONMENT: >
107-
PYBAMM_DISABLE_TELEMETRY="true"
108-
CIBW_ARCHS_LINUX: x86_64
109-
CIBW_BEFORE_BUILD_LINUX: python -m pip install setuptools
110-
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
111-
CIBW_TEST_EXTRAS: "all,dev,jax"
112-
CIBW_TEST_COMMAND: |
113-
set -e -x
114-
python -m pytest -m cibw {project}/tests/unit
115-
116-
- name: Upload wheels for Linux
117-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
118-
with:
119-
name: wheels_manylinux
120-
path: ./wheelhouse/*.whl
121-
if-no-files-found: error
122-
123-
build_macos_wheels:
124-
name: Wheels (${{ matrix.os }})
125-
runs-on: ${{ matrix.os }}
126-
strategy:
127-
matrix:
128-
os: [macos-13, macos-14]
129-
fail-fast: false
130-
steps:
131-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
132-
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
133-
with:
134-
python-version: '3.11'
135-
136-
- name: Install cibuildwheel
137-
run: python -m pip install cibuildwheel
138-
139-
- name: Build wheels on macOS
140-
shell: bash
141-
run: |
142-
set -e -x
143-
144-
# cibuildwheel not recognising its environment variable, so set manually
145-
export CIBUILDWHEEL="1"
146-
147-
python -m cibuildwheel --output-dir wheelhouse
148-
env:
149-
CIBW_ENVIRONMENT: >
150-
PYBAMM_DISABLE_TELEMETRY="true"
151-
# 10.13 for Intel (macos-13), 11.0 for Apple Silicon (macos-14 and macos-latest)
152-
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-14' && '11.0' || '10.13' }}
153-
CIBW_ARCHS_MACOS: auto
154-
CIBW_BEFORE_BUILD: python -m pip install setuptools delocate
155-
CIBW_REPAIR_WHEEL_COMMAND: |
156-
if [[ $(uname -m) == "x86_64" ]]; then
157-
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
158-
elif [[ $(uname -m) == "arm64" ]]; then
159-
# Use higher macOS target for now since casadi/libc++.1.0.dylib is still not fixed
160-
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} --require-target-macos-version 11.1
161-
for file in {dest_dir}/*.whl; do mv "$file" "${file//macosx_11_1/macosx_11_0}"; done
162-
fi
163-
CIBW_TEST_EXTRAS: "all,dev,jax"
164-
CIBW_TEST_COMMAND: |
165-
set -e -x
166-
python -m pytest -m cibw {project}/tests/unit
167-
168-
- name: Upload wheels for macOS (amd64, arm64)
169-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
170-
with:
171-
name: wheels_${{ matrix.os }}
172-
path: ./wheelhouse/*.whl
173-
if-no-files-found: error
174-
175-
build_sdist:
176-
name: Build SDist
7+
build:
1778
runs-on: ubuntu-latest
1789

17910
steps:
@@ -182,71 +13,31 @@ jobs:
18213
with:
18314
python-version: 3.12
18415

185-
- name: Build SDist
186-
run: pipx run build --sdist
16+
- name: Build wheel
17+
run: pipx run build --outdir deploy
18718

188-
- name: Upload SDist
19+
- name: Upload package
18920
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
19021
with:
191-
name: sdist
192-
path: ./dist/*.tar.gz
22+
name: distributions
23+
path: deploy/
19324
if-no-files-found: error
19425

195-
publish_pypi:
196-
# This job is only of value to PyBaMM and would always be skipped in forks
197-
if: github.event_name != 'schedule' && github.repository == 'pybamm-team/PyBaMM'
198-
name: Upload package to PyPI
199-
needs: [
200-
build_manylinux_wheels,
201-
build_macos_wheels,
202-
build_windows_wheels,
203-
build_sdist
204-
]
26+
publish:
27+
needs: build
20528
runs-on: ubuntu-latest
206-
environment:
207-
name: pypi
208-
url: https://pypi.org/p/pybamm
29+
environment: pypi
20930
permissions:
21031
id-token: write
21132

21233
steps:
213-
- name: Download all artifacts
34+
- name: Download artifacts
21435
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
21536
with:
216-
path: artifacts
37+
path: deploy
21738
merge-multiple: true
21839

219-
- name: Sanity check downloaded artifacts
220-
run: ls -lA artifacts/
221-
222-
- name: Publish to PyPI
223-
if: github.event.inputs.target == 'pypi' || github.event_name == 'release'
40+
- name: Publish on PyPI
22441
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
22542
with:
226-
packages-dir: artifacts/
227-
228-
- name: Publish to TestPyPI
229-
if: github.event.inputs.target == 'testpypi'
230-
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
231-
with:
232-
packages-dir: artifacts/
233-
repository-url: https://test.pypi.org/legacy/
234-
235-
open_failure_issue:
236-
needs: [
237-
build_windows_wheels,
238-
build_manylinux_wheels,
239-
build_macos_wheels,
240-
build_sdist
241-
]
242-
name: Open an issue if build fails
243-
if: ${{ always() && contains(needs.*.result, 'failure') && github.repository_owner == 'pybamm-team'}}
244-
runs-on: ubuntu-latest
245-
steps:
246-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
247-
- uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2
248-
env:
249-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250-
LOGS: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
251-
with:
252-
filename: .github/wheel_failure.md
43+
packages-dir: deploy/

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ test.json
110110
# nox
111111
.nox/
112112

113-
# vcpkg
114-
vcpkg_installed/
115-
116113
# benchmarks
117114
html/
118115
results/

scripts/update_version.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Automatically update the version number
33
"""
44

5-
import json
65
import os
76
import re
87
from datetime import date
@@ -46,30 +45,6 @@ def update_version():
4645
file.seek(0)
4746
file.write(replace_version)
4847

49-
# vcpkg.json
50-
with open(os.path.join(pybamm.root_dir(), "vcpkg.json"), "r+") as file:
51-
output = file.read()
52-
json_version_string = json.loads(output)["version-string"]
53-
replace_version = output.replace(json_version_string, release_version)
54-
file.truncate(0)
55-
file.seek(0)
56-
file.write(replace_version)
57-
58-
# Get latest commit id from pybamm-team/sundials-vcpkg-registry
59-
cmd = "git ls-remote https://github.com/pybamm-team/sundials-vcpkg-registry | grep refs/heads/main | cut -f 1 | tr -d '\n'"
60-
latest_commit_id = os.popen(cmd).read()
61-
62-
# vcpkg-configuration.json
63-
with open(
64-
os.path.join(pybamm.root_dir(), "vcpkg-configuration.json"), "r+"
65-
) as file:
66-
output = file.read()
67-
json_commit_id = json.loads(output)["registries"][0]["baseline"]
68-
replace_commit_id = output.replace(json_commit_id, latest_commit_id)
69-
file.truncate(0)
70-
file.seek(0)
71-
file.write(replace_commit_id)
72-
7348
changelog_line1 = "# [Unreleased](https://github.com/pybamm-team/PyBaMM/)\n"
7449
changelog_line2 = f"# [v{release_version}](https://github.com/pybamm-team/PyBaMM/tree/v{release_version}) - {release_date}\n\n"
7550

0 commit comments

Comments
 (0)