Skip to content

Commit 1cc1000

Browse files
committed
Copilot fixes
1 parent 378f45b commit 1cc1000

File tree

4 files changed

+94
-87
lines changed

4 files changed

+94
-87
lines changed

.github/workflows/pypi.yml

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,27 @@ jobs:
6161
exit 0
6262
fi
6363
64-
PYPI_URL="https://pypi.org/pypi/dsf-mobility/${VERSION}/json"
6564
PYPI_NAME="PyPI"
66-
67-
echo "Checking if dsf-mobility version ${VERSION} exists on ${PYPI_NAME}..."
68-
69-
# Check PyPI/TestPyPI API for the specific version
70-
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${PYPI_URL}")
71-
72-
if [ "$HTTP_STATUS" = "200" ]; then
73-
echo "Version ${VERSION} already exists on ${PYPI_NAME}"
74-
echo "Version already published; skipping build and publish jobs."
75-
echo "should_build=false" >> "$GITHUB_OUTPUT"
76-
exit 0
77-
else
78-
echo "Version ${VERSION} does not exist on ${PYPI_NAME} (HTTP ${HTTP_STATUS})"
79-
echo "should_build=true" >> "$GITHUB_OUTPUT"
80-
fi
65+
PACKAGES=("dsf-mobility" "dsf-mobility-hpc")
66+
67+
for PACKAGE in "${PACKAGES[@]}"; do
68+
PYPI_URL="https://pypi.org/pypi/${PACKAGE}/${VERSION}/json"
69+
echo "Checking if ${PACKAGE} version ${VERSION} exists on ${PYPI_NAME}..."
70+
71+
# Check PyPI API for the specific version
72+
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${PYPI_URL}")
73+
74+
if [ "$HTTP_STATUS" = "200" ]; then
75+
echo "Version ${VERSION} already exists for ${PACKAGE} on ${PYPI_NAME}."
76+
echo "Version already published for at least one package; skipping build and publish jobs."
77+
echo "should_build=false" >> "$GITHUB_OUTPUT"
78+
exit 0
79+
fi
80+
81+
echo "Version ${VERSION} does not exist for ${PACKAGE} on ${PYPI_NAME} (HTTP ${HTTP_STATUS})"
82+
done
83+
84+
echo "should_build=true" >> "$GITHUB_OUTPUT"
8185
8286
uv-validate:
8387
name: Validate uv workflows
@@ -156,31 +160,40 @@ jobs:
156160
python -m pip install --upgrade pip
157161
python -m pip install build wheel setuptools pybind11-stubgen auditwheel
158162
163+
- name: Switch package name for HPC distribution
164+
if: matrix.build_variant == 'hpc'
165+
run: |
166+
python - <<'PY'
167+
from pathlib import Path
168+
169+
pyproject_path = Path("pyproject.toml")
170+
content = pyproject_path.read_text(encoding="utf-8")
171+
old = 'name = "dsf-mobility"'
172+
new = 'name = "dsf-mobility-hpc"'
173+
if old not in content:
174+
raise RuntimeError("Unable to locate project name in pyproject.toml")
175+
pyproject_path.write_text(content.replace(old, new, 1), encoding="utf-8")
176+
print("Switched project name to dsf-mobility-hpc for HPC build")
177+
PY
178+
179+
- name: Clean previous build artifacts
180+
run: |
181+
rm -rf dist wheelhouse
182+
rm -rf build/temp.* build/lib.*
183+
159184
- name: Build wheel
160185
env:
161186
CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF"
162187
DSF_PACKAGE_VERSION: ${{ needs.check-version.outputs.publish_version }}
163188
DSF_HPC_BUILD: ${{ matrix.build_variant == 'hpc' && '1' || '0' }}
164189
run: |
165-
rm -rf dist wheelhouse
166190
python -m build --wheel
167191
168192
- name: Repair wheel (auditwheel)
169193
run: |
170194
mkdir -p wheelhouse
171195
auditwheel repair dist/*.whl -w wheelhouse
172196
173-
- name: Rename HPC wheels with _hpc suffix
174-
if: matrix.build_variant == 'hpc'
175-
run: |
176-
cd wheelhouse
177-
for whl in *.whl; do
178-
# Insert _hpc before .whl suffix
179-
new_name="${whl%.whl}_hpc.whl"
180-
mv "$whl" "$new_name"
181-
done
182-
ls -la
183-
184197
- name: Test wheel installation
185198
run: |
186199
python -m pip install wheelhouse/*.whl
@@ -193,14 +206,13 @@ jobs:
193206
path: wheelhouse/*.whl
194207

195208
build-wheels-macos:
196-
name: Build wheels on macOS (Python ${{ matrix.python-version }} - ${{ matrix.build_variant }})
209+
name: Build wheels on macOS (Python ${{ matrix.python-version }})
197210
needs: [check-version, uv-validate]
198211
runs-on: macos-latest
199212
if: needs.check-version.outputs.should_build == 'true'
200213
strategy:
201214
matrix:
202215
python-version: ['3.10', '3.12']
203-
build_variant: ['standard', 'hpc']
204216

205217
steps:
206218
- name: Checkout repository
@@ -225,44 +237,37 @@ jobs:
225237
echo "ARCHFLAGS=-arch $(uname -m)" >> $GITHUB_ENV
226238
echo "_PYTHON_HOST_PLATFORM=macosx-$(sw_vers -productVersion | cut -d. -f1)-$(uname -m)" >> $GITHUB_ENV
227239
240+
- name: Clean previous build artifacts
241+
run: |
242+
rm -rf dist wheelhouse
243+
rm -rf build/temp.* build/lib.*
244+
228245
- name: Build wheel
229246
env:
230247
CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF"
231248
DSF_PACKAGE_VERSION: ${{ needs.check-version.outputs.publish_version }}
232-
DSF_HPC_BUILD: ${{ matrix.build_variant == 'hpc' && '1' || '0' }}
249+
DSF_HPC_BUILD: "0"
233250
run: python -m build --wheel
234251

235252
- name: Repair wheel (bundle libraries)
236253
run: |
237254
mkdir -p wheelhouse
238255
delocate-wheel -w wheelhouse -v --require-archs $(uname -m) dist/*.whl
239256
240-
- name: Rename HPC wheels with _hpc suffix
241-
if: matrix.build_variant == 'hpc'
242-
run: |
243-
cd wheelhouse
244-
for whl in *.whl; do
245-
# Insert _hpc before .whl suffix
246-
new_name="${whl%.whl}_hpc.whl"
247-
mv "$whl" "$new_name"
248-
done
249-
ls -la
250-
251257
- name: Upload wheels as artifacts
252258
uses: actions/upload-artifact@v6
253259
with:
254-
name: wheel-macos-${{ matrix.python-version }}-${{ matrix.build_variant }}
260+
name: wheel-macos-${{ matrix.python-version }}
255261
path: wheelhouse/*.whl
256262

257263
build-wheels-windows:
258-
name: Build wheels on Windows (Python ${{ matrix.python-version }} - ${{ matrix.build_variant }})
264+
name: Build wheels on Windows (Python ${{ matrix.python-version }})
259265
needs: [check-version, uv-validate]
260266
runs-on: windows-latest
261267
if: needs.check-version.outputs.should_build == 'true'
262268
strategy:
263269
matrix:
264270
python-version: ['3.10', '3.12']
265-
build_variant: ['standard', 'hpc']
266271

267272
steps:
268273
- name: Checkout repository
@@ -289,29 +294,23 @@ jobs:
289294
python -m pip install --upgrade pip
290295
python -m pip install build wheel setuptools pybind11-stubgen
291296
297+
- name: Clean previous build artifacts
298+
shell: bash
299+
run: |
300+
rm -rf dist wheelhouse
301+
rm -rf build/temp.* build/lib.*
302+
292303
- name: Build wheel
293304
env:
294305
CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF"
295306
DSF_PACKAGE_VERSION: ${{ needs.check-version.outputs.publish_version }}
296-
DSF_HPC_BUILD: ${{ matrix.build_variant == 'hpc' && '1' || '0' }}
307+
DSF_HPC_BUILD: "0"
297308
run: python -m build --wheel
298309

299-
- name: Rename HPC wheels with _hpc suffix
300-
if: matrix.build_variant == 'hpc'
301-
shell: bash
302-
run: |
303-
cd dist
304-
for whl in *.whl; do
305-
# Insert _hpc before .whl suffix
306-
new_name="${whl%.whl}_hpc.whl"
307-
mv "$whl" "$new_name"
308-
done
309-
ls -la
310-
311310
- name: Upload wheels as artifacts
312311
uses: actions/upload-artifact@v6
313312
with:
314-
name: wheel-windows-${{ matrix.python-version }}-${{ matrix.build_variant }}
313+
name: wheel-windows-${{ matrix.python-version }}
315314
path: dist/*.whl
316315

317316
build-sdist:

CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ if(CMAKE_BUILD_TYPE MATCHES "Release")
6363
endif()
6464
endif()
6565
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
66-
if(DSF_HPC_BUILD)
67-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2")
68-
else()
69-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2")
70-
endif()
66+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2")
7167
endif()
7268
elseif(CMAKE_BUILD_TYPE MATCHES "Profile")
7369
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,33 +104,36 @@ For high-performance computing (HPC) clusters and environments where binary port
104104

105105
### Installation on HPC Systems
106106

107-
The HPC variant wheels are distributed alongside standard wheels on PyPI with an `_hpc` suffix. You can install the HPC variant manually by downloading directly from PyPI:
107+
The HPC build is published as a separate PyPI distribution named `dsf-mobility-hpc` (PEP-compliant), with Linux wheels intended for cluster portability. Install it directly with:
108108

109109
```shell
110-
# Visit https://pypi.org/project/dsf-mobility/ and download the wheel for your Python version and platform
111-
# For example, for Python 3.12 on Linux x86_64:
112-
pip install dsf_mobility-X.Y.Z-cp312-cp312-linux_x86_64_hpc.whl
110+
pip install dsf-mobility-hpc
113111
```
114112

115-
Alternatively, you can use `pip download` to select the correct variant:
113+
Or with `uv`:
116114

117115
```shell
118-
# Download HPC variants only
119-
pip download --only-binary :all: dsf-mobility --python-version 312 --python-tag cp312 --platform linux_x86_64
120-
121-
# Then install from the downloaded wheel
122-
pip install dsf_mobility-X.Y.Z-cp312-cp312-linux_x86_64_hpc.whl
116+
uv pip install dsf-mobility-hpc
123117
```
124118

125-
Or if using `uv` package manager:
119+
If you need to download a wheel explicitly, use:
126120

127121
```shell
128-
# Create a virtual environment
129-
uv venv
122+
pip download --only-binary :all: dsf-mobility-hpc
123+
```
124+
125+
### Wheel Filename Pattern on PyPI
126+
127+
HPC wheel filenames are standard and parseable by pip, for example:
128+
129+
```text
130+
dsf_mobility_hpc-<version>-cp<pyver>-cp<pyver>-<platform_tag>.whl
131+
```
132+
133+
Typical Linux example:
130134

131-
# Download and install the HPC variant
132-
uv pip install --only-binary :all: dsf-mobility
133-
# Then manually select the _hpc wheel, or use a direct URL
135+
```text
136+
dsf_mobility_hpc-5.3.1-cp312-cp312-manylinux_2_17_x86_64.whl
134137
```
135138

136139
### Building HPC Variant Locally
@@ -156,7 +159,7 @@ cmake --build build -j$(nproc)
156159
| **Use Case** | Single-system deployments, development | HPC clusters, portable deployments |
157160
| **Performance** | Highest on optimized hardware | Portable across architectures |
158161
| **Portability** | Variable (CPU-specific) | Maximum (all x86_64 CPUs) |
159-
| **Wheel Suffix** | None (`*-linux_x86_64.whl`) | `_hpc` (`*-linux_x86_64_hpc.whl`) |
162+
| **PyPI Package** | `dsf-mobility` | `dsf-mobility-hpc` |
160163

161164
## Testing
162165
This project uses [Doctest](https://github.com/doctest/doctest) for testing.

setup.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88

99
import os
10+
from distutils import log
1011
from pathlib import Path
1112
import platform
1213
import re
@@ -96,10 +97,13 @@ def build_extension(self, ext: CMakeExtension):
9697
]
9798

9899
# Pass DSF_HPC_BUILD environment variable to CMake for HPC-compatible builds
99-
hpc_build = os.environ.get("DSF_HPC_BUILD", "0")
100-
if hpc_build in ("1", "true", "TRUE", "on", "ON"):
100+
hpc_build = os.environ.get("DSF_HPC_BUILD", "0").strip().lower()
101+
if hpc_build in {"1", "true", "on", "yes"}:
101102
cmake_args.append("-DDSF_HPC_BUILD=ON")
102-
print("HPC Build Mode enabled: using conservative -O3 optimization")
103+
self.announce(
104+
"HPC Build Mode enabled: using conservative -O3 optimization",
105+
level=log.INFO,
106+
)
103107

104108
if platform.system() == "Windows":
105109
cmake_args += [f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}"]
@@ -124,11 +128,16 @@ def build_extension(self, ext: CMakeExtension):
124128

125129
cmake_prefix_path = f"{fmt_prefix};{spdlog_prefix}"
126130
cmake_args.append(f"-DCMAKE_PREFIX_PATH={cmake_prefix_path}")
127-
print(f"Added macOS Homebrew prefix paths: {cmake_prefix_path}")
131+
self.announce(
132+
f"Added macOS Homebrew prefix paths: {cmake_prefix_path}",
133+
level=log.INFO,
134+
)
128135

129136
except (subprocess.CalledProcessError, FileNotFoundError):
130-
print(
131-
"Warning: Could not determine Homebrew prefix paths. Make sure Homebrew is installed and dependencies are available."
137+
self.announce(
138+
"Warning: Could not determine Homebrew prefix paths. "
139+
"Make sure Homebrew is installed and dependencies are available.",
140+
level=log.WARN,
132141
)
133142
# Fallback to common Homebrew paths
134143
cmake_args.append("-DCMAKE_PREFIX_PATH=/opt/homebrew;/usr/local")

0 commit comments

Comments
 (0)