cyhighs 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cyhighs-0.2.0/.github/workflows/docs.yml +51 -0
- cyhighs-0.2.0/.github/workflows/tests.yml +47 -0
- cyhighs-0.2.0/.github/workflows/wheels.yml +147 -0
- cyhighs-0.2.0/.gitignore +35 -0
- cyhighs-0.2.0/CMakeLists.txt +198 -0
- cyhighs-0.2.0/LICENSE +202 -0
- cyhighs-0.2.0/PKG-INFO +249 -0
- cyhighs-0.2.0/README.md +24 -0
- cyhighs-0.2.0/docs/guide/array-interface.md +143 -0
- cyhighs-0.2.0/docs/guide/bundling.md +70 -0
- cyhighs-0.2.0/docs/guide/installation.md +69 -0
- cyhighs-0.2.0/docs/guide/linprog-interface.md +111 -0
- cyhighs-0.2.0/docs/guide/sparse-interface.md +88 -0
- cyhighs-0.2.0/docs/guide/what-is-cyhighs.md +56 -0
- cyhighs-0.2.0/docs/index.md +49 -0
- cyhighs-0.2.0/docs/reference/index.md +38 -0
- cyhighs-0.2.0/pyproject.toml +99 -0
- cyhighs-0.2.0/src/cyhighs/__init__.py +42 -0
- cyhighs-0.2.0/src/cyhighs/_core.pyi +152 -0
- cyhighs-0.2.0/src/cyhighs/_core.pyx +385 -0
- cyhighs-0.2.0/src/cyhighs/_highs_c_api.pxd +118 -0
- cyhighs-0.2.0/src/cyhighs/_highs_c_api.pyi +5 -0
- cyhighs-0.2.0/src/cyhighs/enumerations.py +117 -0
- cyhighs-0.2.0/src/cyhighs/linprog_interface.py +215 -0
- cyhighs-0.2.0/src/cyhighs/options.py +478 -0
- cyhighs-0.2.0/src/cyhighs/result.py +45 -0
- cyhighs-0.2.0/src/cyhighs/sparse_interface.py +200 -0
- cyhighs-0.2.0/src/cyhighs/validation.py +292 -0
- cyhighs-0.2.0/tests/test_core_solving.py +219 -0
- cyhighs-0.2.0/tests/test_enumerations.py +34 -0
- cyhighs-0.2.0/tests/test_linprog_interface.py +110 -0
- cyhighs-0.2.0/tests/test_options.py +66 -0
- cyhighs-0.2.0/tests/test_sparse_interface.py +111 -0
- cyhighs-0.2.0/tests/test_validation.py +126 -0
- cyhighs-0.2.0/uv.lock +970 -0
- cyhighs-0.2.0/zensical.toml +124 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
|
|
3
|
+
# Build the Zensical documentation site and publish it to GitHub Pages on every
|
|
4
|
+
# push to the main branch. The build also runs from the Actions tab on demand.
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
# Allow the workflow to publish to GitHub Pages using the OIDC token.
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
pages: write
|
|
14
|
+
id-token: write
|
|
15
|
+
|
|
16
|
+
# Let a running deployment finish rather than cancelling it, so a published site
|
|
17
|
+
# is never left half updated.
|
|
18
|
+
concurrency:
|
|
19
|
+
group: pages
|
|
20
|
+
cancel-in-progress: false
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
build:
|
|
24
|
+
name: Build site
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- name: Install uv
|
|
29
|
+
uses: astral-sh/setup-uv@v5
|
|
30
|
+
- name: Sync environment and build the extension
|
|
31
|
+
# Building the extension makes the compiled cyhighs importable, so
|
|
32
|
+
# mkdocstrings can resolve every symbol in the API reference.
|
|
33
|
+
run: uv sync
|
|
34
|
+
- name: Build the documentation
|
|
35
|
+
run: uv run zensical build --clean
|
|
36
|
+
- name: Upload the site artifact
|
|
37
|
+
uses: actions/upload-pages-artifact@v3
|
|
38
|
+
with:
|
|
39
|
+
path: site
|
|
40
|
+
|
|
41
|
+
deploy:
|
|
42
|
+
name: Deploy to GitHub Pages
|
|
43
|
+
needs: build
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
environment:
|
|
46
|
+
name: github-pages
|
|
47
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
48
|
+
steps:
|
|
49
|
+
- name: Deploy the site artifact
|
|
50
|
+
id: deployment
|
|
51
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
# Run the linting checks and the test suite on every push and pull request.
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: tests-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
lint:
|
|
15
|
+
name: Lint and type check
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
- name: Sync environment
|
|
22
|
+
run: uv sync
|
|
23
|
+
- name: Ruff lint
|
|
24
|
+
run: uv run ruff check
|
|
25
|
+
- name: Ruff format check
|
|
26
|
+
run: uv run ruff format --check
|
|
27
|
+
- name: Type check
|
|
28
|
+
run: uv run ty check
|
|
29
|
+
|
|
30
|
+
test:
|
|
31
|
+
name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }}
|
|
32
|
+
runs-on: ${{ matrix.os }}
|
|
33
|
+
strategy:
|
|
34
|
+
fail-fast: false
|
|
35
|
+
matrix:
|
|
36
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
37
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- name: Install uv
|
|
41
|
+
uses: astral-sh/setup-uv@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: ${{ matrix.python-version }}
|
|
44
|
+
- name: Sync environment and build the extension
|
|
45
|
+
run: uv sync
|
|
46
|
+
- name: Run tests
|
|
47
|
+
run: uv run pytest
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
name: Build wheels
|
|
2
|
+
|
|
3
|
+
# Build a matrix of binary wheels and a source distribution. Runs on tags, on
|
|
4
|
+
# manual dispatch, when the build configuration changes on a pull request, and
|
|
5
|
+
# when a GitHub release is published, which also triggers the PyPI publish.
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
pull_request:
|
|
11
|
+
paths:
|
|
12
|
+
- "pyproject.toml"
|
|
13
|
+
- "CMakeLists.txt"
|
|
14
|
+
- ".github/workflows/wheels.yml"
|
|
15
|
+
release:
|
|
16
|
+
types: [published]
|
|
17
|
+
|
|
18
|
+
concurrency:
|
|
19
|
+
group: wheels-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
# Linux wheels embed the prebuilt HiGHS static-apache archive, which is built
|
|
24
|
+
# against a recent glibc and needs glibc >= 2.38 to link. No manylinux
|
|
25
|
+
# container image provides that for x86_64, so Linux wheels are built directly
|
|
26
|
+
# on the native runners (Ubuntu 24.04 ships glibc 2.39) and repaired with
|
|
27
|
+
# auditwheel, which tags them manylinux_2_38+.
|
|
28
|
+
build_linux:
|
|
29
|
+
name: Linux ${{ matrix.os }} cp${{ matrix.python }}
|
|
30
|
+
runs-on: ${{ matrix.os }}
|
|
31
|
+
strategy:
|
|
32
|
+
fail-fast: false
|
|
33
|
+
matrix:
|
|
34
|
+
os:
|
|
35
|
+
- ubuntu-24.04 # Linux x86_64
|
|
36
|
+
- ubuntu-24.04-arm # Linux aarch64
|
|
37
|
+
python: ["3.11", "3.12", "3.13", "3.14"]
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
|
|
41
|
+
- name: Set up Python ${{ matrix.python }}
|
|
42
|
+
uses: actions/setup-python@v5
|
|
43
|
+
with:
|
|
44
|
+
python-version: ${{ matrix.python }}
|
|
45
|
+
|
|
46
|
+
- name: Build and repair wheel
|
|
47
|
+
run: |
|
|
48
|
+
set -euxo pipefail
|
|
49
|
+
python -m pip install --upgrade pip build auditwheel patchelf
|
|
50
|
+
python -m build --wheel --outdir dist
|
|
51
|
+
# auditwheel bundles the external libraries (libstdc++, libgcc_s,
|
|
52
|
+
# libz) into the wheel and applies the highest compatible manylinux
|
|
53
|
+
# tag for the referenced glibc symbols.
|
|
54
|
+
auditwheel repair dist/*.whl --wheel-dir wheelhouse
|
|
55
|
+
|
|
56
|
+
- name: Test the repaired wheel
|
|
57
|
+
run: |
|
|
58
|
+
set -euxo pipefail
|
|
59
|
+
python -m pip install wheelhouse/*.whl
|
|
60
|
+
python -m pip install pytest scipy pytest-markdown-docs
|
|
61
|
+
pytest "${GITHUB_WORKSPACE}/tests" "${GITHUB_WORKSPACE}/docs"
|
|
62
|
+
|
|
63
|
+
- name: Upload wheel artifacts
|
|
64
|
+
uses: actions/upload-artifact@v4
|
|
65
|
+
with:
|
|
66
|
+
name: wheels-linux-${{ matrix.os }}-cp${{ matrix.python }}
|
|
67
|
+
path: ./wheelhouse/*.whl
|
|
68
|
+
|
|
69
|
+
# macOS and Windows wheels are built with cibuildwheel, which handles the
|
|
70
|
+
# per-Python builds and the delocate/delvewheel repair. glibc is not a concern
|
|
71
|
+
# on these platforms, so the prebuilt archives build in the standard images.
|
|
72
|
+
build_wheels:
|
|
73
|
+
name: Wheels on ${{ matrix.os }}
|
|
74
|
+
runs-on: ${{ matrix.os }}
|
|
75
|
+
strategy:
|
|
76
|
+
fail-fast: false
|
|
77
|
+
matrix:
|
|
78
|
+
os:
|
|
79
|
+
- macos-latest # macOS arm64
|
|
80
|
+
- windows-latest # Windows AMD64
|
|
81
|
+
steps:
|
|
82
|
+
- uses: actions/checkout@v4
|
|
83
|
+
|
|
84
|
+
- name: Build wheels
|
|
85
|
+
uses: pypa/cibuildwheel@v3.2.0
|
|
86
|
+
env:
|
|
87
|
+
# Build CPython 3.11 through 3.14. The free threaded builds are left
|
|
88
|
+
# out for now while Cython support for them is still settling.
|
|
89
|
+
CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*"
|
|
90
|
+
# Skip 32-bit targets. HiGHS is not viable on 32-bit and there are no
|
|
91
|
+
# 32-bit SciPy wheels for the test step.
|
|
92
|
+
CIBW_SKIP: "*_i686 *-win32"
|
|
93
|
+
# HiGHS is C++17. macOS arm64 requires a deployment target of at least
|
|
94
|
+
# 11.0 for the C++17 standard library features HiGHS relies on.
|
|
95
|
+
MACOSX_DEPLOYMENT_TARGET: "11.0"
|
|
96
|
+
# Verify each freshly built wheel by running the test suite against it.
|
|
97
|
+
# pytest-markdown-docs is required because the project addopts enable it,
|
|
98
|
+
# and it lets the documentation examples run against the built wheel too.
|
|
99
|
+
CIBW_TEST_REQUIRES: "pytest scipy pytest-markdown-docs"
|
|
100
|
+
CIBW_TEST_COMMAND: "pytest {project}/tests {project}/docs"
|
|
101
|
+
|
|
102
|
+
- name: Upload wheel artifacts
|
|
103
|
+
uses: actions/upload-artifact@v4
|
|
104
|
+
with:
|
|
105
|
+
name: wheels-${{ matrix.os }}
|
|
106
|
+
path: ./wheelhouse/*.whl
|
|
107
|
+
|
|
108
|
+
build_sdist:
|
|
109
|
+
name: Source distribution
|
|
110
|
+
runs-on: ubuntu-latest
|
|
111
|
+
steps:
|
|
112
|
+
- uses: actions/checkout@v4
|
|
113
|
+
- name: Install uv
|
|
114
|
+
uses: astral-sh/setup-uv@v5
|
|
115
|
+
- name: Build sdist
|
|
116
|
+
run: uv build --sdist
|
|
117
|
+
- name: Upload sdist artifact
|
|
118
|
+
uses: actions/upload-artifact@v4
|
|
119
|
+
with:
|
|
120
|
+
name: sdist
|
|
121
|
+
path: ./dist/*.tar.gz
|
|
122
|
+
|
|
123
|
+
publish:
|
|
124
|
+
name: Publish to PyPI
|
|
125
|
+
needs: [build_linux, build_wheels, build_sdist]
|
|
126
|
+
if: github.event_name == 'release'
|
|
127
|
+
runs-on: ubuntu-latest
|
|
128
|
+
environment:
|
|
129
|
+
name: pypi
|
|
130
|
+
url: https://pypi.org/project/cyhighs/
|
|
131
|
+
permissions:
|
|
132
|
+
id-token: write
|
|
133
|
+
steps:
|
|
134
|
+
- name: Download wheel artifacts
|
|
135
|
+
uses: actions/download-artifact@v4
|
|
136
|
+
with:
|
|
137
|
+
pattern: wheels-*
|
|
138
|
+
path: dist
|
|
139
|
+
merge-multiple: true
|
|
140
|
+
- name: Download sdist artifact
|
|
141
|
+
uses: actions/download-artifact@v4
|
|
142
|
+
with:
|
|
143
|
+
name: sdist
|
|
144
|
+
path: dist
|
|
145
|
+
merge-multiple: true
|
|
146
|
+
- name: Publish to PyPI
|
|
147
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
cyhighs-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Build output
|
|
2
|
+
/build/
|
|
3
|
+
/dist/
|
|
4
|
+
/wheelhouse/
|
|
5
|
+
*.egg-info/
|
|
6
|
+
_skbuild/
|
|
7
|
+
|
|
8
|
+
# Zensical documentation build output
|
|
9
|
+
/site/
|
|
10
|
+
|
|
11
|
+
# Compiled artifacts
|
|
12
|
+
*.so
|
|
13
|
+
*.pyd
|
|
14
|
+
*.dll
|
|
15
|
+
*.dylib
|
|
16
|
+
*.o
|
|
17
|
+
*.obj
|
|
18
|
+
|
|
19
|
+
# Cython generated C sources
|
|
20
|
+
src/cyhighs/_core.c
|
|
21
|
+
|
|
22
|
+
# Virtual environments
|
|
23
|
+
.venv/
|
|
24
|
+
|
|
25
|
+
# Caches
|
|
26
|
+
__pycache__/
|
|
27
|
+
*.py[cod]
|
|
28
|
+
.pytest_cache/
|
|
29
|
+
.ruff_cache/
|
|
30
|
+
.ty_cache/
|
|
31
|
+
|
|
32
|
+
# Editor and OS
|
|
33
|
+
.vscode/
|
|
34
|
+
.idea/
|
|
35
|
+
.DS_Store
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# CMake build for the cyhighs Cython extension.
|
|
2
|
+
#
|
|
3
|
+
# This file downloads a prebuilt HiGHS "static-apache" release archive for the
|
|
4
|
+
# target platform, extracts it, and links the static libraries it ships
|
|
5
|
+
# (libhighs, libhighs_extras and the bundled OpenBLAS) into a single self
|
|
6
|
+
# contained extension module. HiGHS is no longer compiled from source.
|
|
7
|
+
cmake_minimum_required(VERSION 3.24)
|
|
8
|
+
|
|
9
|
+
project(cyhighs LANGUAGES C CXX)
|
|
10
|
+
|
|
11
|
+
# HiGHS is written in C++17. Enforce it here so that our extension agrees with
|
|
12
|
+
# the standard the prebuilt libraries were compiled against.
|
|
13
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
14
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
15
|
+
|
|
16
|
+
# Position independent code is required to link the static HiGHS libraries into
|
|
17
|
+
# the shared extension module. The release archives are already built PIC.
|
|
18
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
19
|
+
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
# Locate Python and the Cython compiler through scikit-build-core.
|
|
22
|
+
# ---------------------------------------------------------------------------
|
|
23
|
+
find_package(
|
|
24
|
+
Python
|
|
25
|
+
COMPONENTS Interpreter Development.Module
|
|
26
|
+
REQUIRED)
|
|
27
|
+
|
|
28
|
+
# ---------------------------------------------------------------------------
|
|
29
|
+
# Acquire the prebuilt HiGHS static-apache archive.
|
|
30
|
+
#
|
|
31
|
+
# The static-apache variant bundles the HiPO interior point solver together
|
|
32
|
+
# with its numerical dependencies (AMD, BLAS via OpenBLAS, METIS, RCM), ships
|
|
33
|
+
# headers and a CMake package config, and is distributed under Apache 2.0.
|
|
34
|
+
# ---------------------------------------------------------------------------
|
|
35
|
+
set(HIGHS_VERSION 1.15.1)
|
|
36
|
+
|
|
37
|
+
# Normalise the architecture name to match the release asset naming.
|
|
38
|
+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _highs_arch)
|
|
39
|
+
if(_highs_arch MATCHES "amd64|x86_64|x64")
|
|
40
|
+
set(_highs_arch "x86_64")
|
|
41
|
+
elseif(_highs_arch MATCHES "aarch64|arm64")
|
|
42
|
+
set(_highs_arch "aarch64")
|
|
43
|
+
endif()
|
|
44
|
+
|
|
45
|
+
# Select the release asset and its pinned SHA256 for the target platform. Only
|
|
46
|
+
# the platforms with a published static-apache archive are supported; anything
|
|
47
|
+
# else (musllinux, Intel macOS, 32 bit) must build against a system HiGHS.
|
|
48
|
+
set(_highs_sha "")
|
|
49
|
+
if(APPLE)
|
|
50
|
+
if(NOT _highs_arch STREQUAL "aarch64")
|
|
51
|
+
message(FATAL_ERROR
|
|
52
|
+
"No prebuilt HiGHS static-apache binary is published for Intel macOS. "
|
|
53
|
+
"Only Apple Silicon (arm64) is supported.")
|
|
54
|
+
endif()
|
|
55
|
+
set(_highs_asset "highs-${HIGHS_VERSION}-arm-apple-static-apache.tar.gz")
|
|
56
|
+
# TODO: pin the SHA256 of the arm-apple archive.
|
|
57
|
+
elseif(WIN32)
|
|
58
|
+
if(NOT _highs_arch STREQUAL "x86_64")
|
|
59
|
+
message(FATAL_ERROR "No prebuilt HiGHS static-apache binary for Windows ${_highs_arch}.")
|
|
60
|
+
endif()
|
|
61
|
+
set(_highs_asset "highs-${HIGHS_VERSION}-x86_64-windows-static-apache.zip")
|
|
62
|
+
# TODO: pin the SHA256 of the x86_64-windows archive.
|
|
63
|
+
elseif(UNIX)
|
|
64
|
+
set(_highs_asset "highs-${HIGHS_VERSION}-${_highs_arch}-linux-gnu-static-apache.tar.gz")
|
|
65
|
+
if(_highs_arch STREQUAL "x86_64")
|
|
66
|
+
set(_highs_sha "b5c5d25cfbb66d438a3b40b6919c50c3c82341f74062f5f44371a52e65d6bd2c")
|
|
67
|
+
endif()
|
|
68
|
+
# TODO: pin the SHA256 of the aarch64-linux archive.
|
|
69
|
+
else()
|
|
70
|
+
message(FATAL_ERROR "Unsupported platform for prebuilt HiGHS: ${CMAKE_SYSTEM_NAME}/${_highs_arch}.")
|
|
71
|
+
endif()
|
|
72
|
+
|
|
73
|
+
# The extracted tree lands here. HIGHS_ARCHIVE lets a caller point at a local
|
|
74
|
+
# copy of the archive (air gapped builds, CI caches, offline development) so
|
|
75
|
+
# that no download happens.
|
|
76
|
+
set(HIGHS_ARCHIVE "" CACHE FILEPATH "Local HiGHS static-apache archive to use instead of downloading")
|
|
77
|
+
set(_highs_root "${CMAKE_BINARY_DIR}/highs-prebuilt")
|
|
78
|
+
|
|
79
|
+
if(NOT EXISTS "${_highs_root}/lib")
|
|
80
|
+
if(HIGHS_ARCHIVE AND EXISTS "${HIGHS_ARCHIVE}")
|
|
81
|
+
set(_highs_local "${HIGHS_ARCHIVE}")
|
|
82
|
+
message(STATUS "Using local HiGHS archive: ${_highs_local}")
|
|
83
|
+
else()
|
|
84
|
+
set(_highs_local "${CMAKE_BINARY_DIR}/${_highs_asset}")
|
|
85
|
+
set(_highs_url
|
|
86
|
+
"https://github.com/ERGO-Code/HiGHS/releases/download/v${HIGHS_VERSION}/${_highs_asset}")
|
|
87
|
+
message(STATUS "Downloading HiGHS: ${_highs_url}")
|
|
88
|
+
if(_highs_sha STREQUAL "")
|
|
89
|
+
message(WARNING
|
|
90
|
+
"No pinned SHA256 for ${_highs_asset}; downloading without an integrity check.")
|
|
91
|
+
file(DOWNLOAD "${_highs_url}" "${_highs_local}" TLS_VERIFY ON STATUS _highs_dl)
|
|
92
|
+
else()
|
|
93
|
+
file(DOWNLOAD "${_highs_url}" "${_highs_local}"
|
|
94
|
+
EXPECTED_HASH SHA256=${_highs_sha} TLS_VERIFY ON STATUS _highs_dl)
|
|
95
|
+
endif()
|
|
96
|
+
list(GET _highs_dl 0 _highs_dl_code)
|
|
97
|
+
if(NOT _highs_dl_code EQUAL 0)
|
|
98
|
+
list(GET _highs_dl 1 _highs_dl_msg)
|
|
99
|
+
message(FATAL_ERROR "Failed to download ${_highs_url}: ${_highs_dl_msg}")
|
|
100
|
+
endif()
|
|
101
|
+
endif()
|
|
102
|
+
file(MAKE_DIRECTORY "${_highs_root}")
|
|
103
|
+
file(ARCHIVE_EXTRACT INPUT "${_highs_local}" DESTINATION "${_highs_root}")
|
|
104
|
+
endif()
|
|
105
|
+
|
|
106
|
+
# Collect the static libraries in link order: highs depends on highs_extras,
|
|
107
|
+
# which depends on OpenBLAS. Match both the Unix (lib*.a) and Windows (*.lib)
|
|
108
|
+
# naming so the same logic works everywhere.
|
|
109
|
+
set(_highs_libraries "")
|
|
110
|
+
foreach(_name highs highs_extras)
|
|
111
|
+
file(GLOB _found
|
|
112
|
+
"${_highs_root}/lib/lib${_name}.a"
|
|
113
|
+
"${_highs_root}/lib/${_name}.lib"
|
|
114
|
+
"${_highs_root}/lib/lib${_name}.lib")
|
|
115
|
+
if(NOT _found)
|
|
116
|
+
message(FATAL_ERROR "Prebuilt HiGHS library '${_name}' not found in ${_highs_root}/lib")
|
|
117
|
+
endif()
|
|
118
|
+
list(GET _found 0 _lib)
|
|
119
|
+
list(APPEND _highs_libraries "${_lib}")
|
|
120
|
+
endforeach()
|
|
121
|
+
|
|
122
|
+
# HiPO needs a BLAS. The Linux and Windows archives bundle OpenBLAS as a static
|
|
123
|
+
# library (its name may carry a target or version suffix, so match with a
|
|
124
|
+
# wildcard). The macOS archive ships no OpenBLAS and instead relies on the system
|
|
125
|
+
# Accelerate framework, so fall back to that there.
|
|
126
|
+
file(GLOB _openblas_found
|
|
127
|
+
"${_highs_root}/lib/libopenblas.a"
|
|
128
|
+
"${_highs_root}/lib/libopenblas*.a"
|
|
129
|
+
"${_highs_root}/lib/openblas.lib"
|
|
130
|
+
"${_highs_root}/lib/openblas*.lib"
|
|
131
|
+
"${_highs_root}/lib/libopenblas*.lib")
|
|
132
|
+
if(_openblas_found)
|
|
133
|
+
list(GET _openblas_found 0 _lib)
|
|
134
|
+
list(APPEND _highs_libraries "${_lib}")
|
|
135
|
+
elseif(APPLE)
|
|
136
|
+
find_library(_accelerate Accelerate REQUIRED)
|
|
137
|
+
list(APPEND _highs_libraries "${_accelerate}")
|
|
138
|
+
else()
|
|
139
|
+
file(GLOB _lib_contents "${_highs_root}/lib/*")
|
|
140
|
+
message(FATAL_ERROR
|
|
141
|
+
"No BLAS library found in ${_highs_root}/lib. Contents: ${_lib_contents}")
|
|
142
|
+
endif()
|
|
143
|
+
|
|
144
|
+
# ---------------------------------------------------------------------------
|
|
145
|
+
# Transpile the Cython source to C.
|
|
146
|
+
# ---------------------------------------------------------------------------
|
|
147
|
+
set(cython_source "${CMAKE_CURRENT_SOURCE_DIR}/src/cyhighs/_core.pyx")
|
|
148
|
+
set(generated_c "${CMAKE_CURRENT_BINARY_DIR}/_core.c")
|
|
149
|
+
|
|
150
|
+
add_custom_command(
|
|
151
|
+
OUTPUT "${generated_c}"
|
|
152
|
+
COMMAND
|
|
153
|
+
"${Python_EXECUTABLE}" -m cython --3str -o "${generated_c}"
|
|
154
|
+
"${cython_source}"
|
|
155
|
+
DEPENDS "${cython_source}"
|
|
156
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/cyhighs/_highs_c_api.pxd"
|
|
157
|
+
VERBATIM)
|
|
158
|
+
|
|
159
|
+
# ---------------------------------------------------------------------------
|
|
160
|
+
# Build the extension module.
|
|
161
|
+
# ---------------------------------------------------------------------------
|
|
162
|
+
python_add_library(_core MODULE "${generated_c}" WITH_SOABI)
|
|
163
|
+
|
|
164
|
+
# The C API header lives at include/highs/interfaces/highs_c_api.h in the
|
|
165
|
+
# archive, so include/highs is the directory to add.
|
|
166
|
+
target_include_directories(_core PRIVATE "${_highs_root}/include/highs")
|
|
167
|
+
|
|
168
|
+
# The prebuilt libraries reference the system zlib (the archives are built with
|
|
169
|
+
# ZLIB on) and pthreads. On Windows the Windows archive may bundle zlib, so it
|
|
170
|
+
# is looked up but not required there.
|
|
171
|
+
find_package(Threads REQUIRED)
|
|
172
|
+
if(WIN32)
|
|
173
|
+
find_package(ZLIB)
|
|
174
|
+
else()
|
|
175
|
+
find_package(ZLIB REQUIRED)
|
|
176
|
+
endif()
|
|
177
|
+
|
|
178
|
+
target_link_libraries(_core PRIVATE ${_highs_libraries} Threads::Threads)
|
|
179
|
+
if(ZLIB_FOUND)
|
|
180
|
+
target_link_libraries(_core PRIVATE ZLIB::ZLIB)
|
|
181
|
+
endif()
|
|
182
|
+
if(CMAKE_DL_LIBS)
|
|
183
|
+
target_link_libraries(_core PRIVATE ${CMAKE_DL_LIBS})
|
|
184
|
+
endif()
|
|
185
|
+
|
|
186
|
+
# The Cython source compiles as C, but the HiGHS libraries are C++. Linking with
|
|
187
|
+
# the C++ driver pulls in the C++ runtime (libstdc++ / libc++).
|
|
188
|
+
set_target_properties(_core PROPERTIES LINKER_LANGUAGE CXX)
|
|
189
|
+
|
|
190
|
+
# Install the compiled module next to the Python sources inside the package.
|
|
191
|
+
install(TARGETS _core DESTINATION cyhighs)
|
|
192
|
+
|
|
193
|
+
# Bundle the upstream HiGHS license into the package for attribution, since the
|
|
194
|
+
# solver is statically linked into the extension. The file ships in the archive.
|
|
195
|
+
if(EXISTS "${_highs_root}/share/doc/HIGHS/LICENSE.txt")
|
|
196
|
+
install(FILES "${_highs_root}/share/doc/HIGHS/LICENSE.txt"
|
|
197
|
+
DESTINATION cyhighs RENAME HiGHS-LICENSE.txt)
|
|
198
|
+
endif()
|
cyhighs-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Nardi Lam
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|