From c295dcf3b9357c8479533bca286e21e16bbc0f9d Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 13:56:17 +0000 Subject: [PATCH 01/45] version down to testpypi --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ff3d15d6a2..583b7a793c 100644 --- a/setup.py +++ b/setup.py @@ -135,7 +135,7 @@ def build_extension(self, ext: CMakeExtension) -> None: # logic and declaration, and simpler if you include description/version in a file. setup( name="highspy", - version="1.7.0.dev3", + version="1.6.6", description = "A thin set of pybind11 wrappers to HiGHS", author="HiGHS developers", author_email="highsopt@gmail.com", From f28979a9018998730a88338117d242ddaf4531dc Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 14:14:46 +0000 Subject: [PATCH 02/45] cleanup and new workflow --- .github/workflows/test-python-package.yml | 64 +++++++++++++++++++++++ pyproject.toml | 32 ------------ 2 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/test-python-package.yml diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml new file mode 100644 index 0000000000..7944645290 --- /dev/null +++ b/.github/workflows/test-python-package.yml @@ -0,0 +1,64 @@ +name: Test python package +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + shell: bash -l {0} + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + test_sdist: + name: test install from source + runs-on: ubuntu-latest + steps: + - name: install sdist + run: | + python3 -m pip install setuptools + python3 -m pip install dist/*.tar.gz + + - name: test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + # build_wheels: + # name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} + # runs-on: ${{ matrix.buildplat[0] }} + # environment: pypi + # strategy: + # # Ensure that a wheel builder finishes even if another fails + # fail-fast: false + # matrix: + # # From NumPy + # # Github Actions doesn't support pairing matrix values together, let's improvise + # # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 + # buildplat: + # - [ubuntu-20.04, manylinux_x86_64] + # - [ubuntu-20.04, musllinux_x86_64] # No OpenBlas, no test + # - [macos-12, macosx_x86_64] + # - [macos-12, macosx_arm64] + # - [windows-2019, win_amd64] + # python: ["cp38", "cp39","cp310", "cp311","cp312"] + + # steps: + # - uses: actions/checkout@v4 + # - name: Build wheels + # uses: pypa/cibuildwheel@v2.12.3 + # env: + # CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} + # - uses: actions/upload-artifact@v3 + # with: + # path: ./wheelhouse/*.whl diff --git a/pyproject.toml b/pyproject.toml index 8f4b9ee4f4..ebb3cda9d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,39 +13,7 @@ requires = [ build-backend = "setuptools.build_meta" -[tool.mypy] -files = "setup.py" -python_version = "3.9" -strict = true -show_error_codes = true -enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] -warn_unreachable = true - -[[tool.mypy.overrides]] -module = ["ninja"] -ignore_missing_imports = true - [tool.cibuildwheel] build = "cp312-*" skip = "cp3{6,7}-*" test-skip = "" - -# [tool.cibuildwheel.linux] -# manylinux-x86_64-image = "manylinux2014" -# manylinux-i686-image = "manylinux2014" -# repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" - -# [tool.cibuildwheel.macos] -# archs = ["x86_64 arm64"] -# environment = { RUNNER_OS="macOS" } - -# repair-wheel-command = """\ -# "delocate-listdeps {wheel}", -# DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel \ -# --require-archs {delocate_archs} -w {dest_dir} -v {wheel}\ -# """ - -# [tool.cibuildwheel.windows] -# # Use delvewheel on windows, and install the project so delvewheel can find it -# before-build = "pip install delvewheel meson ninja && meson setup bbdir && meson install -C bbdir" -# repair-wheel-command = "delvewheel repair --add-path c:/bin;c:/lib;c:/bin/src;c:/lib/src;D:/a/HiGHS/HiGHS/bbdir/src/ -w {dest_dir} {wheel}" From 06436f9bae62463fda602dcb6d806175306bae3a Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 14:32:16 +0000 Subject: [PATCH 03/45] test --- .github/workflows/test-python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 7944645290..7aa00d5ea2 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -27,6 +27,7 @@ jobs: - name: install sdist run: | python3 -m pip install setuptools + ls dist python3 -m pip install dist/*.tar.gz - name: test highspy From a83b9513d9d8d293f539ff95e5a6f2c01625a06c Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 14:36:51 +0000 Subject: [PATCH 04/45] build sdist --- .github/workflows/test-python-package.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 7aa00d5ea2..53455e5820 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -13,24 +13,18 @@ jobs: - uses: actions/checkout@v4 - name: Build sdist - shell: bash -l {0} - run: pipx run build --sdist + # shell: bash -l {0} + run: | + python3 -m pip install setuptools + python3 setup.py sdist - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz - test_sdist: - name: test install from source - runs-on: ubuntu-latest - steps: - - name: install sdist + - name: Install sdist run: | - python3 -m pip install setuptools ls dist python3 -m pip install dist/*.tar.gz - - name: test highspy + - name: Test highspy run: | python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py From f514c63b4e816827ddadbad31f4b6eea4858eceb Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 15:13:35 +0000 Subject: [PATCH 05/45] test wheel install --- .github/workflows/test-python-package.yml | 40 ++++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 53455e5820..2442d31317 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -6,23 +6,47 @@ concurrency: cancel-in-progress: true jobs: - build_sdist: - name: Build source distribution + # build_sdist: + # name: Build source distribution + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + + # - name: Build sdist + # # shell: bash -l {0} + # run: | + # python3 -m pip install setuptools + # python3 setup.py sdist + + + # - name: Install sdist + # run: | + # ls dist + # python3 -m pip install dist/*.tar.gz + + # - name: Test highspy + # run: | + # python3 -m pip install pytest + # python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + # name: Build source distribution + + build_wheels: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Build sdist + - name: Build wheel # shell: bash -l {0} run: | - python3 -m pip install setuptools - python3 setup.py sdist + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --only cp310-manylinux_x86_64 $GITHUB_WORKSPACE - - name: Install sdist + - name: Install wheel run: | - ls dist - python3 -m pip install dist/*.tar.gz + ls wheelhouse + python3 -m pip install wheelhouse/*.whl - name: Test highspy run: | From 1bd4d132dac473429f56e1e0a89b8b2cd2f39190 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 15:49:58 +0000 Subject: [PATCH 06/45] tests added for macos and windows --- .github/workflows/test-python-package.yml | 133 +++++++++++++--------- 1 file changed, 80 insertions(+), 53 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 2442d31317..9e6bfa4028 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -6,42 +6,77 @@ concurrency: cancel-in-progress: true jobs: - # build_sdist: - # name: Build source distribution - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - - # - name: Build sdist - # # shell: bash -l {0} - # run: | - # python3 -m pip install setuptools - # python3 setup.py sdist - - - # - name: Install sdist - # run: | - # ls dist - # python3 -m pip install dist/*.tar.gz - - # - name: Test highspy - # run: | - # python3 -m pip install pytest - # python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest, macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: | + python3 -m pip install setuptools + python3 setup.py sdist + + - name: Install sdist + run: | + ls dist + python3 -m pip install dist/*.tar.gz + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py - # name: Build source distribution + build_sdist_win: + name: Build source distribution + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: | + python -m pip install setuptools + python setup.py sdist - build_wheels: + - name: Install sdist + run: | + ls dist + python -m pip install dist/*.tar.gz + + - name: Test highspy + run: | + python -m pip install pytest + python -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + build_wheel_linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build wheel - # shell: bash -l {0} run: | python3 -m pip install cibuildwheel python3 -m cibuildwheel --only cp310-manylinux_x86_64 $GITHUB_WORKSPACE + - name: Install wheel + run: | + ls wheelhouse + python3 -m pip install wheelhouse/*.whl + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + build_wheel_macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE - name: Install wheel run: | @@ -53,31 +88,23 @@ jobs: python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py - # build_wheels: - # name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} - # runs-on: ${{ matrix.buildplat[0] }} - # environment: pypi - # strategy: - # # Ensure that a wheel builder finishes even if another fails - # fail-fast: false - # matrix: - # # From NumPy - # # Github Actions doesn't support pairing matrix values together, let's improvise - # # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 - # buildplat: - # - [ubuntu-20.04, manylinux_x86_64] - # - [ubuntu-20.04, musllinux_x86_64] # No OpenBlas, no test - # - [macos-12, macosx_x86_64] - # - [macos-12, macosx_arm64] - # - [windows-2019, win_amd64] - # python: ["cp38", "cp39","cp310", "cp311","cp312"] - - # steps: - # - uses: actions/checkout@v4 - # - name: Build wheels - # uses: pypa/cibuildwheel@v2.12.3 - # env: - # CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} - # - uses: actions/upload-artifact@v3 - # with: - # path: ./wheelhouse/*.whl + build_wheel_windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python -m pip install cibuildwheel + python -m cibuildwheel --only cp310-win_x86_64 $GITHUB_WORKSPACE + + - name: Install wheel + run: | + ls wheelhouse + python -m pip install wheelhouse/*.whl + + - name: Test highspy + run: | + python -m pip install pytest + python -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + \ No newline at end of file From 41fc856de990e26a2398e8363549f20a8b9f5a65 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 16:40:56 +0000 Subject: [PATCH 07/45] wip tests --- .github/workflows/test-python-package.yml | 29 +++++++++++++++++++---- LICENSE => LICENSE.txt | 0 setup.py | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) rename LICENSE => LICENSE.txt (100%) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 9e6bfa4028..29727c2e4b 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -1,4 +1,4 @@ -name: Test python package +name: test-python-package on: [push, pull_request] concurrency: @@ -7,8 +7,7 @@ concurrency: jobs: build_sdist: - name: Build source distribution - runs-on: ubuntu-latest, macos-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -27,8 +26,27 @@ jobs: python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + build_sdist_mac: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: | + python3 -m pip install setuptools + python3 setup.py sdist + + - name: Install sdist + run: | + ls dist + python3 -m pip install dist/*.tar.gz + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + build_sdist_win: - name: Build source distribution runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -81,6 +99,7 @@ jobs: - name: Install wheel run: | ls wheelhouse + python3 --version python3 -m pip install wheelhouse/*.whl - name: Test highspy @@ -96,7 +115,7 @@ jobs: - name: Build wheel run: | python -m pip install cibuildwheel - python -m cibuildwheel --only cp310-win_x86_64 $GITHUB_WORKSPACE + python -m cibuildwheel --only cp310-win_amd64 $GITHUB_WORKSPACE - name: Install wheel run: | diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/setup.py b/setup.py index 583b7a793c..08d229972d 100644 --- a/setup.py +++ b/setup.py @@ -141,7 +141,7 @@ def build_extension(self, ext: CMakeExtension) -> None: author_email="highsopt@gmail.com", url='https://github.com/ERGO-Code/HiGHS', long_description="", - license_files = ('LICENSE',), + license = 'MIT License', ext_modules=[CMakeExtension("highspy")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False, From 4b97cdf5b4e842ed475727c3637072ccb6d0979f Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 16:59:48 +0000 Subject: [PATCH 08/45] remove invalid classifier for licence --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 08d229972d..82172145bc 100644 --- a/setup.py +++ b/setup.py @@ -151,7 +151,6 @@ def build_extension(self, ext: CMakeExtension) -> None: ], extras_require={"test": ["pytest>=6.0"]}, classifiers=[ - 'License :: MIT License Copyright (c) 2024 HiGHS', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', From 61b482e4cfb9c4ee33a92bde10645bdcbb059815 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 17:09:02 +0000 Subject: [PATCH 09/45] item.name win sdist --- .github/workflows/test-python-package.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 29727c2e4b..8d37872c2b 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -59,7 +59,8 @@ jobs: - name: Install sdist run: | ls dist - python -m pip install dist/*.tar.gz + $items = Get-ChildItem dist + python -m pip install dist/"$item.name" - name: Test highspy run: | From 1e349f50e36e629bdfc58633b371b0d923bba36b Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 17:24:26 +0000 Subject: [PATCH 10/45] typo --- .github/workflows/test-python-package.yml | 2 +- pyproject.toml | 4 ++-- setup.py | 10 +++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 8d37872c2b..bacc4552af 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -59,7 +59,7 @@ jobs: - name: Install sdist run: | ls dist - $items = Get-ChildItem dist + $item = Get-ChildItem dist python -m pip install dist/"$item.name" - name: Test highspy diff --git a/pyproject.toml b/pyproject.toml index ebb3cda9d0..d8e3fffb03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,8 +7,8 @@ requires = [ "setuptools>=45", "pybind11>=2.4", - "wheel>=0.2", - "numpy>=1.7", + "wheel", + "cmake>=3.12", ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 82172145bc..6a56fc23c5 100644 --- a/setup.py +++ b/setup.py @@ -135,22 +135,18 @@ def build_extension(self, ext: CMakeExtension) -> None: # logic and declaration, and simpler if you include description/version in a file. setup( name="highspy", - version="1.6.6", + version="1.6.6.dev1", description = "A thin set of pybind11 wrappers to HiGHS", author="HiGHS developers", author_email="highsopt@gmail.com", url='https://github.com/ERGO-Code/HiGHS', - long_description="", license = 'MIT License', ext_modules=[CMakeExtension("highspy")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False, python_requires=">=3.9", - install_requires=[ - 'numpy', - ], - extras_require={"test": ["pytest>=6.0"]}, - classifiers=[ + extras_require={"test": ["pytest>=6.0"]}, + classifiers=[ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', From 8dc1a7364212c42db5cf97b1f53bfc3bff096644 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 17:26:35 +0000 Subject: [PATCH 11/45] removed .name --- .github/workflows/test-python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index bacc4552af..e66e637a72 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -60,7 +60,7 @@ jobs: run: | ls dist $item = Get-ChildItem dist - python -m pip install dist/"$item.name" + python -m pip install dist/"$item" - name: Test highspy run: | From 1e7559a8bcf390f9b1a36487355290432585dbc3 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 17:37:31 +0000 Subject: [PATCH 12/45] added many macos and moved numpy to extras require --- .github/workflows/test-python-package.yml | 94 +++++++++++++++++++++-- setup.py | 3 +- 2 files changed, 91 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index e66e637a72..b8fa43cda0 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -1,9 +1,9 @@ name: test-python-package on: [push, pull_request] -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true jobs: build_sdist: @@ -87,8 +87,29 @@ jobs: python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py - build_wheel_macos: - runs-on: macos-latest + build_wheel_macos_12: + runs-on: macos-12 + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE + + - name: Install wheel + run: | + ls wheelhouse + python3 --version + python3 -m pip install wheelhouse/*.whl + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + build_wheel_macos_13: + runs-on: macos-14 steps: - uses: actions/checkout@v4 @@ -107,7 +128,70 @@ jobs: run: | python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + build_wheel_macos_14: + runs-on: macos-14 + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --only cp311-macosx_x86_64 $GITHUB_WORKSPACE + + - name: Install wheel + run: | + ls wheelhouse + python3 --version + python3 -m pip install wheelhouse/*.whl + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + build_wheel_macos_13_arm64: + runs-on: macos-13-arm64 + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --only cp310-macosx_arm64 $GITHUB_WORKSPACE + + - name: Install wheel + run: | + ls wheelhouse + python3 --version + python3 -m pip install wheelhouse/*.whl + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + build_wheel_macos_14_arm64: + runs-on: macos-14-arm64 + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --only cp311-macosx_arm64 $GITHUB_WORKSPACE + + - name: Install wheel + run: | + ls wheelhouse + python3 --version + python3 -m pip install wheelhouse/*.whl + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + build_wheel_windows: runs-on: windows-latest steps: diff --git a/setup.py b/setup.py index 6a56fc23c5..860bce1c89 100644 --- a/setup.py +++ b/setup.py @@ -145,7 +145,8 @@ def build_extension(self, ext: CMakeExtension) -> None: cmdclass={"build_ext": CMakeBuild}, zip_safe=False, python_requires=">=3.9", - extras_require={"test": ["pytest>=6.0"]}, + extras_require={"test": ["pytest>=6.0"], + "numpy":["numpy>=1.7"]}, classifiers=[ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', From b10832d89f2011d17a5429d9f1085ec12d7641f4 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 17:48:52 +0000 Subject: [PATCH 13/45] windows path and macos runners --- .github/workflows/test-python-package.yml | 49 +++-------------------- pyproject.toml | 1 + setup.py | 3 +- 3 files changed, 7 insertions(+), 46 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index b8fa43cda0..1fb2bfb153 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -60,7 +60,7 @@ jobs: run: | ls dist $item = Get-ChildItem dist - python -m pip install dist/"$item" + python -m pip install "$item" - name: Test highspy run: | @@ -87,6 +87,7 @@ jobs: python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + # macos 12 is Intel build_wheel_macos_12: runs-on: macos-12 steps: @@ -108,8 +109,9 @@ jobs: python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + # macos 13 is Intel build_wheel_macos_13: - runs-on: macos-14 + runs-on: macos-13 steps: - uses: actions/checkout@v4 @@ -129,53 +131,12 @@ jobs: python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + # macos 14 is M1 (beta) build_wheel_macos_14: runs-on: macos-14 steps: - uses: actions/checkout@v4 - - name: Build wheel - run: | - python3 -m pip install cibuildwheel - python3 -m cibuildwheel --only cp311-macosx_x86_64 $GITHUB_WORKSPACE - - - name: Install wheel - run: | - ls wheelhouse - python3 --version - python3 -m pip install wheelhouse/*.whl - - - name: Test highspy - run: | - python3 -m pip install pytest - python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py - - build_wheel_macos_13_arm64: - runs-on: macos-13-arm64 - steps: - - uses: actions/checkout@v4 - - - name: Build wheel - run: | - python3 -m pip install cibuildwheel - python3 -m cibuildwheel --only cp310-macosx_arm64 $GITHUB_WORKSPACE - - - name: Install wheel - run: | - ls wheelhouse - python3 --version - python3 -m pip install wheelhouse/*.whl - - - name: Test highspy - run: | - python3 -m pip install pytest - python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py - - build_wheel_macos_14_arm64: - runs-on: macos-14-arm64 - steps: - - uses: actions/checkout@v4 - - name: Build wheel run: | python3 -m pip install cibuildwheel diff --git a/pyproject.toml b/pyproject.toml index d8e3fffb03..f2c2af4cfc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ requires = [ "pybind11>=2.4", "wheel", "cmake>=3.12", + "numpy>=1.7" ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 860bce1c89..80990a1711 100644 --- a/setup.py +++ b/setup.py @@ -145,8 +145,7 @@ def build_extension(self, ext: CMakeExtension) -> None: cmdclass={"build_ext": CMakeBuild}, zip_safe=False, python_requires=">=3.9", - extras_require={"test": ["pytest>=6.0"], - "numpy":["numpy>=1.7"]}, + extras_require={"test": ["pytest>=6.0"]} classifiers=[ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', From f789ca551fe8c188786419e9710335c4360f2754 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 17:50:48 +0000 Subject: [PATCH 14/45] typo --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 80990a1711..6a56fc23c5 100644 --- a/setup.py +++ b/setup.py @@ -145,7 +145,7 @@ def build_extension(self, ext: CMakeExtension) -> None: cmdclass={"build_ext": CMakeBuild}, zip_safe=False, python_requires=">=3.9", - extras_require={"test": ["pytest>=6.0"]} + extras_require={"test": ["pytest>=6.0"]}, classifiers=[ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', From 891297140e7b52d627955630fdc55123b6d4ca11 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:05:37 +0000 Subject: [PATCH 15/45] numpy back to install requirements --- .github/workflows/test-python-package.yml | 5 +++-- setup.py | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 1fb2bfb153..6abe877802 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -65,7 +65,7 @@ jobs: - name: Test highspy run: | python -m pip install pytest - python -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + python -m pytest ./highspy/tests/test_highspy.py build_wheel_linux: runs-on: ubuntu-latest @@ -74,6 +74,7 @@ jobs: - name: Build wheel run: | + python3 --version python3 -m pip install cibuildwheel python3 -m cibuildwheel --only cp310-manylinux_x86_64 $GITHUB_WORKSPACE @@ -106,7 +107,7 @@ jobs: - name: Test highspy run: | - python3 -m pip install pytest + python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py # macos 13 is Intel diff --git a/setup.py b/setup.py index 6a56fc23c5..f3a418f96b 100644 --- a/setup.py +++ b/setup.py @@ -135,18 +135,22 @@ def build_extension(self, ext: CMakeExtension) -> None: # logic and declaration, and simpler if you include description/version in a file. setup( name="highspy", - version="1.6.6.dev1", + version="1.6.6.dev2", description = "A thin set of pybind11 wrappers to HiGHS", author="HiGHS developers", author_email="highsopt@gmail.com", url='https://github.com/ERGO-Code/HiGHS', + long_description="", license = 'MIT License', ext_modules=[CMakeExtension("highspy")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False, python_requires=">=3.9", - extras_require={"test": ["pytest>=6.0"]}, - classifiers=[ + install_requires=[ + 'numpy', + ], + extras_require={"test": ["pytest>=6.0"]}, + classifiers=[ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', From ce11843e2f6da98315d7095be7d02429a1683f5e Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:05:53 +0000 Subject: [PATCH 16/45] numpy back to install --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f2c2af4cfc..d8e3fffb03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,6 @@ requires = [ "pybind11>=2.4", "wheel", "cmake>=3.12", - "numpy>=1.7" ] build-backend = "setuptools.build_meta" From 0744329e9059b28bf42496e64598008e795cfb6c Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:07:42 +0000 Subject: [PATCH 17/45] test windows wheel --- .github/workflows/test-python-package.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 6abe877802..5f6f4b6d96 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -167,10 +167,11 @@ jobs: - name: Install wheel run: | ls wheelhouse - python -m pip install wheelhouse/*.whl + $item = Get-ChildItem wheelhouse + python -m pip install "$item" - name: Test highspy run: | python -m pip install pytest - python -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + python -m pytest .highspy/tests/test_highspy.py \ No newline at end of file From 8922d5a2c2d55d6f8f98ef3dd67ca05e408487e0 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:27:02 +0000 Subject: [PATCH 18/45] win arm64 --- .github/workflows/test-python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 5f6f4b6d96..11ae332910 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -162,7 +162,7 @@ jobs: - name: Build wheel run: | python -m pip install cibuildwheel - python -m cibuildwheel --only cp310-win_amd64 $GITHUB_WORKSPACE + python -m cibuildwheel --only cp310-win_arm64 $GITHUB_WORKSPACE - name: Install wheel run: | From 69713860d2efc914dde3732faba748866345d476 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:28:02 +0000 Subject: [PATCH 19/45] numpy requires --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index d8e3fffb03..f2c2af4cfc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ requires = [ "pybind11>=2.4", "wheel", "cmake>=3.12", + "numpy>=1.7" ] build-backend = "setuptools.build_meta" From d9472d1db4a17ec4df6b017b9d347853827b17e0 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:35:31 +0000 Subject: [PATCH 20/45] cibw build * --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f2c2af4cfc..3b6cf9c26f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,6 @@ requires = [ build-backend = "setuptools.build_meta" [tool.cibuildwheel] -build = "cp312-*" +build = "*" skip = "cp3{6,7}-*" test-skip = "" From 5e7b64edd68e9b47fb1a29a2e7bf4ed8f7016544 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:43:54 +0000 Subject: [PATCH 21/45] wip failing tests --- .../workflows/test-python-package copy.yml | 81 +++++++++++++++++++ .github/workflows/test-python-package.yml | 3 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test-python-package copy.yml diff --git a/.github/workflows/test-python-package copy.yml b/.github/workflows/test-python-package copy.yml new file mode 100644 index 0000000000..c7df3cea9b --- /dev/null +++ b/.github/workflows/test-python-package copy.yml @@ -0,0 +1,81 @@ +name: Test win sdist +on: [push, pull_request] + +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true + +jobs: + + build_sdist_win: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: | + python -m pip install setuptools + python setup.py sdist + + - name: Install sdist + run: | + ls dist + $item = Get-ChildItem dist + python -m pip install "$item" + python -c "import highspy; print(dir(highspy))" + + - name: Test highspy + run: | + python -m pip install pytest + cd highspy/tests/ + python -m pytest test_highspy.py + + + # macos 12 is Intel + build_wheel_macos_12: + runs-on: macos-12 + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE + + - name: Install wheel + run: | + ls wheelhouse + python3 --version + python3 -m pip install wheelhouse/*.whl + python -c "import highspy; print(dir(highspy))" + pwd + + - name: Test highspy + run: | + python3 -m pip install pytest + python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + + + build_wheel_windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + run: | + python -m pip install cibuildwheel + python -m cibuildwheel --only cp310-win_arm64 $GITHUB_WORKSPACE + + - name: Install wheel + run: | + ls wheelhouse + $item = Get-ChildItem wheelhouse + python -m pip install "$item" + python -c "import highspy; print(dir(highspy))" + + - name: Test highspy + run: | + python -m pip install pytest + cd highspy/tests + python -m pytest test_highspy.py + \ No newline at end of file diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 11ae332910..8a354bfc24 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -1,5 +1,6 @@ name: test-python-package -on: [push, pull_request] +# on: [push, pull_request] +on: [] # concurrency: # group: ${{ github.workflow }}-${{ github.ref }} From 0b96f302c078cb93de06a8bf41532f6d1ed2fc78 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 18:49:46 +0000 Subject: [PATCH 22/45] wip --- .../{test-python-package copy.yml => test-python-all.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{test-python-package copy.yml => test-python-all.yml} (100%) diff --git a/.github/workflows/test-python-package copy.yml b/.github/workflows/test-python-all.yml similarity index 100% rename from .github/workflows/test-python-package copy.yml rename to .github/workflows/test-python-all.yml From ef8be047c9d6c25126485fb78ffdfee29b159bba Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 19:23:36 +0000 Subject: [PATCH 23/45] python versions and win working dir --- .github/workflows/test-python-all.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index c7df3cea9b..9ed6ab1bc0 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -1,4 +1,4 @@ -name: Test win sdist +name: all-test-python on: [push, pull_request] # concurrency: @@ -16,6 +16,7 @@ jobs: run: | python -m pip install setuptools python setup.py sdist + python --version - name: Install sdist run: | @@ -47,7 +48,7 @@ jobs: ls wheelhouse python3 --version python3 -m pip install wheelhouse/*.whl - python -c "import highspy; print(dir(highspy))" + python3 -c "import highspy; print(dir(highspy))" pwd - name: Test highspy @@ -64,6 +65,7 @@ jobs: - name: Build wheel run: | python -m pip install cibuildwheel + python --version python -m cibuildwheel --only cp310-win_arm64 $GITHUB_WORKSPACE - name: Install wheel From 03206f8fda92102e10089ded2bb09a3e89839cb4 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 19:36:34 +0000 Subject: [PATCH 24/45] working dir --- .github/workflows/test-python-all.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index 9ed6ab1bc0..da393e6051 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -12,10 +12,16 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Working directory + run: | + cd ${{runner.workspace}} + mkdir dev + - name: Build sdist + working-directory: ${{runner.workspace}}/dev run: | python -m pip install setuptools - python setup.py sdist + python $GITHUB_WORKSPACE/setup.py sdist python --version - name: Install sdist @@ -26,10 +32,10 @@ jobs: python -c "import highspy; print(dir(highspy))" - name: Test highspy + working-directory: ${{runner.workspace}}/dev run: | python -m pip install pytest - cd highspy/tests/ - python -m pytest test_highspy.py + python -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py # macos 12 is Intel @@ -38,12 +44,19 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Working directory + run: | + cd ${{runner.workspace}} + mkdir dev + - name: Build wheel + working-directory: ${{runner.workspace}}/dev run: | python3 -m pip install cibuildwheel python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE - name: Install wheel + working-directory: ${{runner.workspace}}/dev run: | ls wheelhouse python3 --version @@ -52,6 +65,7 @@ jobs: pwd - name: Test highspy + working-directory: ${{runner.workspace}}/dev run: | python3 -m pip install pytest python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py @@ -66,7 +80,7 @@ jobs: run: | python -m pip install cibuildwheel python --version - python -m cibuildwheel --only cp310-win_arm64 $GITHUB_WORKSPACE + python -m cibuildwheel --only cp39-win_arm64 $GITHUB_WORKSPACE - name: Install wheel run: | From 013b1f82780c9af42c1d3307076bb0133fb8be36 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 19:37:57 +0000 Subject: [PATCH 25/45] working dir path --- .github/workflows/test-python-all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index da393e6051..c456285237 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -27,7 +27,7 @@ jobs: - name: Install sdist run: | ls dist - $item = Get-ChildItem dist + $item = Get-ChildItem ${{runner.workspace}}/dev/dist python -m pip install "$item" python -c "import highspy; print(dir(highspy))" From a17d2c4b52484fcbe215bf96eb978c86ba761c52 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 19:39:35 +0000 Subject: [PATCH 26/45] working dir path ls --- .github/workflows/test-python-all.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index c456285237..6cc4077207 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -26,7 +26,6 @@ jobs: - name: Install sdist run: | - ls dist $item = Get-ChildItem ${{runner.workspace}}/dev/dist python -m pip install "$item" python -c "import highspy; print(dir(highspy))" From edc2666447962e1c3a6815b34a910580817e4208 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 21:34:13 +0000 Subject: [PATCH 27/45] path 1 --- .github/workflows/test-python-all.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index 6cc4077207..f6b630c20f 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -16,6 +16,8 @@ jobs: run: | cd ${{runner.workspace}} mkdir dev + cd dev + pwd - name: Build sdist working-directory: ${{runner.workspace}}/dev From fac840e6a19289e4be6da6dedceea710ca2dc0e1 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 21:36:55 +0000 Subject: [PATCH 28/45] path 2 --- .github/workflows/test-python-all.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index f6b630c20f..31c5c2d5eb 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -18,12 +18,13 @@ jobs: mkdir dev cd dev pwd + cd $GITHUB_WORKSPACE/HiGHS/HiGHS - name: Build sdist working-directory: ${{runner.workspace}}/dev run: | python -m pip install setuptools - python $GITHUB_WORKSPACE/setup.py sdist + python $GITHUB_WORKSPACE/HiGHS/HiGHS/setup.py sdist python --version - name: Install sdist From 2482d98a22e18f320fe2ec622d9f6df14a7ab051 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 21:46:43 +0000 Subject: [PATCH 29/45] python versions --- .github/workflows/test-python-all.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index 31c5c2d5eb..be22c9267c 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -12,19 +12,28 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: 3.9 + - name: Working directory run: | + pwd + ls cd ${{runner.workspace}} + pwd + ls mkdir dev cd dev pwd - cd $GITHUB_WORKSPACE/HiGHS/HiGHS + cd $GITHUB_WORKSPACE/HiGHS/ - name: Build sdist working-directory: ${{runner.workspace}}/dev run: | python -m pip install setuptools - python $GITHUB_WORKSPACE/HiGHS/HiGHS/setup.py sdist + python $GITHUB_WORKSPACE/HiGHS/setup.py sdist python --version - name: Install sdist @@ -46,6 +55,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: 3.10 + - name: Working directory run: | cd ${{runner.workspace}} @@ -54,6 +68,8 @@ jobs: - name: Build wheel working-directory: ${{runner.workspace}}/dev run: | + python3 --version + export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.10/bin python3 -m pip install cibuildwheel python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE @@ -61,7 +77,6 @@ jobs: working-directory: ${{runner.workspace}}/dev run: | ls wheelhouse - python3 --version python3 -m pip install wheelhouse/*.whl python3 -c "import highspy; print(dir(highspy))" pwd @@ -78,6 +93,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: 3.9 + - name: Build wheel run: | python -m pip install cibuildwheel From d44d07f2f3690b5af6843a177a71ffa573b23e6a Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 21:50:44 +0000 Subject: [PATCH 30/45] path and python setup --- .github/workflows/test-python-all.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index be22c9267c..c90a671168 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -27,7 +27,8 @@ jobs: mkdir dev cd dev pwd - cd $GITHUB_WORKSPACE/HiGHS/ + cd $GITHUB_WORKSPACE + ls - name: Build sdist working-directory: ${{runner.workspace}}/dev @@ -52,13 +53,16 @@ jobs: # macos 12 is Intel build_wheel_macos_12: runs-on: macos-12 + strategy: + matrix: + python: [3.10] steps: - uses: actions/checkout@v4 - name: Install correct python version uses: actions/setup-python@v5 with: - python-version: 3.10 + python-version: ${{ matrix.python }} - name: Working directory run: | From 331ec00aeba6fd93789a8d00b02414a46f2b3837 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 21:56:13 +0000 Subject: [PATCH 31/45] python versions and architectures --- .github/workflows/test-python-all.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index c90a671168..9df39fefb3 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -20,22 +20,18 @@ jobs: - name: Working directory run: | pwd - ls cd ${{runner.workspace}} pwd - ls mkdir dev cd dev pwd - cd $GITHUB_WORKSPACE - ls + python --version - name: Build sdist working-directory: ${{runner.workspace}}/dev run: | python -m pip install setuptools - python $GITHUB_WORKSPACE/HiGHS/setup.py sdist - python --version + python ${{runner.workspace}}/HiGHS/setup.py sdist - name: Install sdist run: | @@ -55,7 +51,7 @@ jobs: runs-on: macos-12 strategy: matrix: - python: [3.10] + python: [3.11] steps: - uses: actions/checkout@v4 @@ -73,9 +69,8 @@ jobs: working-directory: ${{runner.workspace}}/dev run: | python3 --version - export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.10/bin python3 -m pip install cibuildwheel - python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE + python3 -m cibuildwheel --only cp311-macosx_x86_64 $GITHUB_WORKSPACE - name: Install wheel working-directory: ${{runner.workspace}}/dev @@ -106,7 +101,7 @@ jobs: run: | python -m pip install cibuildwheel python --version - python -m cibuildwheel --only cp39-win_arm64 $GITHUB_WORKSPACE + python -m cibuildwheel --only cp39-win_amd64 $GITHUB_WORKSPACE - name: Install wheel run: | From a0bff81954754849a39adde178ec8f9bb9bf2c3b Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 22:01:57 +0000 Subject: [PATCH 32/45] paths again --- .github/workflows/test-python-all.yml | 29 ++++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml index 9df39fefb3..059ccb2b76 100644 --- a/.github/workflows/test-python-all.yml +++ b/.github/workflows/test-python-all.yml @@ -17,33 +17,34 @@ jobs: with: python-version: 3.9 - - name: Working directory - run: | - pwd - cd ${{runner.workspace}} - pwd - mkdir dev - cd dev - pwd - python --version + # - name: Working directory + # run: | + # pwd + # cd ${{runner.workspace}} + # pwd + # mkdir dev + # cd dev + # pwd + # python --version - name: Build sdist - working-directory: ${{runner.workspace}}/dev + # working-directory: ${{runner.workspace}}/dev run: | python -m pip install setuptools - python ${{runner.workspace}}/HiGHS/setup.py sdist + python setup.py sdist - name: Install sdist run: | - $item = Get-ChildItem ${{runner.workspace}}/dev/dist + $item = Get-ChildItem dist python -m pip install "$item" python -c "import highspy; print(dir(highspy))" - name: Test highspy - working-directory: ${{runner.workspace}}/dev + # working-directory: ${{runner.workspace}}/dev run: | python -m pip install pytest - python -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py + cd ../ + python -m pytest HiGHS/highspy/tests/test_highspy.py # macos 12 is Intel From 96db5c57fbd8aa17414ce3c8bfa85d561950caa8 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 22:17:19 +0000 Subject: [PATCH 33/45] tests to build python packages --- ...n-package.yml => build-python-package.yml} | 60 +++++++-- .github/workflows/build-wheels.yml | 4 +- .github/workflows/test-python-all.yml | 119 ------------------ 3 files changed, 52 insertions(+), 131 deletions(-) rename .github/workflows/{test-python-package.yml => build-python-package.yml} (73%) delete mode 100644 .github/workflows/test-python-all.yml diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/build-python-package.yml similarity index 73% rename from .github/workflows/test-python-package.yml rename to .github/workflows/build-python-package.yml index 8a354bfc24..c27e3da9c8 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/build-python-package.yml @@ -1,10 +1,10 @@ -name: test-python-package -# on: [push, pull_request] -on: [] +name: build-python-package +on: [push, pull_request] +# on: [] -# concurrency: -# group: ${{ github.workflow }}-${{ github.ref }} -# cancel-in-progress: true +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build_sdist: @@ -52,6 +52,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: 3.9 + - name: Build sdist run: | python -m pip install setuptools @@ -59,9 +64,9 @@ jobs: - name: Install sdist run: | - ls dist $item = Get-ChildItem dist python -m pip install "$item" + python -c "import highspy; print(dir(highspy))" - name: Test highspy run: | @@ -92,19 +97,28 @@ jobs: # macos 12 is Intel build_wheel_macos_12: runs-on: macos-12 + strategy: + matrix: + python: [3.11] steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Build wheel run: | python3 -m pip install cibuildwheel - python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE + python3 -m cibuildwheel --only cp311-macosx_x86_64 $GITHUB_WORKSPACE - name: Install wheel run: | ls wheelhouse python3 --version python3 -m pip install wheelhouse/*.whl + python3 -c "import highspy; print(dir(highspy))" - name: Test highspy run: | @@ -114,19 +128,28 @@ jobs: # macos 13 is Intel build_wheel_macos_13: runs-on: macos-13 + strategy: + matrix: + python: [3.11] steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Build wheel run: | python3 -m pip install cibuildwheel - python3 -m cibuildwheel --only cp310-macosx_x86_64 $GITHUB_WORKSPACE + python3 -m cibuildwheel --only cp311-macosx_x86_64 $GITHUB_WORKSPACE - name: Install wheel run: | ls wheelhouse python3 --version python3 -m pip install wheelhouse/*.whl + python3 -c "import highspy; print(dir(highspy))" - name: Test highspy run: | @@ -135,10 +158,18 @@ jobs: # macos 14 is M1 (beta) build_wheel_macos_14: - runs-on: macos-14 + runs-on: macos-14 + strategy: + matrix: + python: [3.11] steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Build wheel run: | python3 -m pip install cibuildwheel @@ -149,6 +180,7 @@ jobs: ls wheelhouse python3 --version python3 -m pip install wheelhouse/*.whl + python3 -c "import highspy; print(dir(highspy))" - name: Test highspy run: | @@ -160,16 +192,22 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install correct python version + uses: actions/setup-python@v5 + with: + python-version: 3.9 + - name: Build wheel run: | python -m pip install cibuildwheel - python -m cibuildwheel --only cp310-win_arm64 $GITHUB_WORKSPACE + python -m cibuildwheel --only cp39-win_amd64 $GITHUB_WORKSPACE - name: Install wheel run: | ls wheelhouse $item = Get-ChildItem wheelhouse python -m pip install "$item" + python -c "import highspy; print(dir(highspy))" - name: Test highspy run: | diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index dd800767f8..7906f8b30d 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -1,6 +1,8 @@ # Python release WIP name: Build wheels -on: [] +on: [push] + +# on: # release: # types: # - published diff --git a/.github/workflows/test-python-all.yml b/.github/workflows/test-python-all.yml deleted file mode 100644 index 059ccb2b76..0000000000 --- a/.github/workflows/test-python-all.yml +++ /dev/null @@ -1,119 +0,0 @@ -name: all-test-python -on: [push, pull_request] - -# concurrency: -# group: ${{ github.workflow }}-${{ github.ref }} -# cancel-in-progress: true - -jobs: - - build_sdist_win: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - - name: Install correct python version - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - # - name: Working directory - # run: | - # pwd - # cd ${{runner.workspace}} - # pwd - # mkdir dev - # cd dev - # pwd - # python --version - - - name: Build sdist - # working-directory: ${{runner.workspace}}/dev - run: | - python -m pip install setuptools - python setup.py sdist - - - name: Install sdist - run: | - $item = Get-ChildItem dist - python -m pip install "$item" - python -c "import highspy; print(dir(highspy))" - - - name: Test highspy - # working-directory: ${{runner.workspace}}/dev - run: | - python -m pip install pytest - cd ../ - python -m pytest HiGHS/highspy/tests/test_highspy.py - - - # macos 12 is Intel - build_wheel_macos_12: - runs-on: macos-12 - strategy: - matrix: - python: [3.11] - steps: - - uses: actions/checkout@v4 - - - name: Install correct python version - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - - name: Working directory - run: | - cd ${{runner.workspace}} - mkdir dev - - - name: Build wheel - working-directory: ${{runner.workspace}}/dev - run: | - python3 --version - python3 -m pip install cibuildwheel - python3 -m cibuildwheel --only cp311-macosx_x86_64 $GITHUB_WORKSPACE - - - name: Install wheel - working-directory: ${{runner.workspace}}/dev - run: | - ls wheelhouse - python3 -m pip install wheelhouse/*.whl - python3 -c "import highspy; print(dir(highspy))" - pwd - - - name: Test highspy - working-directory: ${{runner.workspace}}/dev - run: | - python3 -m pip install pytest - python3 -m pytest $GITHUB_WORKSPACE/highspy/tests/test_highspy.py - - - build_wheel_windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - - name: Install correct python version - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - - name: Build wheel - run: | - python -m pip install cibuildwheel - python --version - python -m cibuildwheel --only cp39-win_amd64 $GITHUB_WORKSPACE - - - name: Install wheel - run: | - ls wheelhouse - $item = Get-ChildItem wheelhouse - python -m pip install "$item" - python -c "import highspy; print(dir(highspy))" - - - name: Test highspy - run: | - python -m pip install pytest - cd highspy/tests - python -m pytest test_highspy.py - \ No newline at end of file From 7faad7a5d0f69c25731e41fec525ccd93d445ac3 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 22:29:08 +0000 Subject: [PATCH 34/45] python requires --- .github/workflows/build-python-package.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-python-package.yml b/.github/workflows/build-python-package.yml index c27e3da9c8..a36784356c 100644 --- a/.github/workflows/build-python-package.yml +++ b/.github/workflows/build-python-package.yml @@ -212,5 +212,5 @@ jobs: - name: Test highspy run: | python -m pip install pytest - python -m pytest .highspy/tests/test_highspy.py + python -m pytest highspy/tests/test_highspy.py \ No newline at end of file diff --git a/setup.py b/setup.py index f3a418f96b..5a3d5ce40f 100644 --- a/setup.py +++ b/setup.py @@ -145,7 +145,7 @@ def build_extension(self, ext: CMakeExtension) -> None: ext_modules=[CMakeExtension("highspy")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False, - python_requires=">=3.9", + python_requires=">=3.8", install_requires=[ 'numpy', ], From 8c866f02a8f73d56e42fc758ea084031c6488382 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 23:38:39 +0000 Subject: [PATCH 35/45] action version and more python examples and tests --- .github/workflows/build-wheels.yml | 4 +- .github/workflows/test-python-macos.yml | 6 +++ .github/workflows/test-python-ubuntu.yml | 6 +++ .github/workflows/test-python-win.yml | 5 +++ README.md | 29 ++++---------- examples/call_highs_from_python.py | 26 ++++++------- examples/call_highs_from_python_highspy.py | 45 ++++++++++++++++++++++ examples/call_highs_from_python_mps.py | 39 +++++++++++++++++++ 8 files changed, 123 insertions(+), 37 deletions(-) create mode 100644 examples/call_highs_from_python_highspy.py create mode 100644 examples/call_highs_from_python_mps.py diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 7906f8b30d..7c7dbc8c65 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -28,13 +28,13 @@ jobs: - [ubuntu-20.04, musllinux_x86_64] # No OpenBlas, no test - [macos-12, macosx_x86_64] - [macos-12, macosx_arm64] - - [windows-2019, win_amd64] + - [windows-2019, win_amd64, win_arm64] python: ["cp38", "cp39","cp310", "cp311","cp312"] steps: - uses: actions/checkout@v4 - name: Build wheels - uses: pypa/cibuildwheel@v2.12.3 + uses: pypa/cibuildwheel@v2.16.5 env: CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} - uses: actions/upload-artifact@v3 diff --git a/.github/workflows/test-python-macos.yml b/.github/workflows/test-python-macos.yml index 456e918f4b..5c0160f92c 100644 --- a/.github/workflows/test-python-macos.yml +++ b/.github/workflows/test-python-macos.yml @@ -24,3 +24,9 @@ jobs: run: | python3 -m pip install . pytest -v ./highspy/tests/ + + - name: Test Python Examples + run: | + python3 ./examples/call_highs_from_python_highspy.py + python3 ./examples/call_highs_from_python_mps.py + python3 ./examples/call_highs_from_python.py diff --git a/.github/workflows/test-python-ubuntu.yml b/.github/workflows/test-python-ubuntu.yml index b5850d7818..44cfeabda1 100644 --- a/.github/workflows/test-python-ubuntu.yml +++ b/.github/workflows/test-python-ubuntu.yml @@ -24,3 +24,9 @@ jobs: run: | python3 -m pip install . pytest -v ./highspy/tests/ + + - name: Test Python Examples + run: | + python3 ./examples/call_highs_from_python_highspy.py + python3 ./examples/call_highs_from_python_mps.py + python3 ./examples/call_highs_from_python.py \ No newline at end of file diff --git a/.github/workflows/test-python-win.yml b/.github/workflows/test-python-win.yml index 81bbf1f655..8919f66b02 100644 --- a/.github/workflows/test-python-win.yml +++ b/.github/workflows/test-python-win.yml @@ -26,3 +26,8 @@ jobs: python -m pip install . pytest -v ./highspy/tests/ + - name: Test Python Examples + run: | + python ./examples/call_highs_from_python_highspy.py + python ./examples/call_highs_from_python_mps.py + python ./examples/call_highs_from_python.py diff --git a/README.md b/README.md index 81c521871e..99fbb663a7 100644 --- a/README.md +++ b/README.md @@ -124,36 +124,21 @@ We are happy to give a reasonable level of support via email sent to highsopt@gm ### Python -There are two ways to install the Python interface. Building directly -from Git assumes that you have already installed the HiGHS library. -Installing from PyPI through your Python package manager of choice (e.g., `pip`) will also install the HiGHS library if not already present. - -#### From PyPi - -HiGHS is available as `highspy` on [PyPi](https://pypi.org/project/highspy/). -This will not only install the Python interface, but also the HiGHS library -itself. - -If `highspy` is not already installed, run: +The python package `highspy` is a thin wrapper around HiGHS and is available on [PyPi](https://pypi.org/project/highspy/). It can be easily installed via `pip` by running ```bash $ pip install highspy ``` -#### Build directly from Git +Alternatively, `highspy` can be built from source. Download the HiGHS source code and run -In order to build the Python interface, build and install the HiGHS -library as described above, ensure the shared library is in the -`LD_LIBRARY_PATH` environment variable, and then run - - pip install ./ - -from the HiGHS directory. +```bash +pip install . +``` -You may also require +from the root directory. -* `pip install pybind11` -* `pip install pyomo` +The HiGHS C++ library no longer needs to be separately installed. The python package `highspy` depends on the `numpy` package and `numpy` will be installed as well, if it is not already present. #### Testing diff --git a/examples/call_highs_from_python.py b/examples/call_highs_from_python.py index e7723fb9af..0f8a327195 100644 --- a/examples/call_highs_from_python.py +++ b/examples/call_highs_from_python.py @@ -6,13 +6,13 @@ # directory of this file (ie highs/examples) or any other subdirectory # of HiGHS import numpy as np -import highspy._highs -import highspy._highs.cb as hscb +import highspy +import highspy.cb as hscb -h = highspy._highs.Highs() -inf = highspy._highs.kHighsInf +h = highspy.Highs() +inf = highspy.kHighsInf alt_inf = h.getInfinity() -print('highspy._highs.kHighsInf = ', inf, '; h.getInfinity() = ', alt_inf) +print('highspy.kHighsInf = ', inf, '; h.getInfinity() = ', alt_inf) # NB The callbacks are not available in # https://pypi.org/project/highspy/ (HiGHS v1.5.3). To use them, @@ -124,10 +124,10 @@ def user_interrupt_callback( # Now define the blending model as a HighsLp instance # -lp = highspy._highs.HighsLp() +lp = highspy.HighsLp() lp.num_col_ = 2 lp.num_row_ = 2 -lp.sense_ = highspy._highs.ObjSense.kMaximize +lp.sense_ = highspy.ObjSense.kMaximize lp.col_cost_ = np.array([8, 10], dtype=np.double) lp.col_lower_ = np.array([0, 0], dtype=np.double) lp.col_upper_ = np.array([inf, inf], dtype=np.double) @@ -163,7 +163,7 @@ def user_interrupt_callback( h.clear() # Now define the test-semi-definite0 model (from TestQpSolver.cpp) as a HighsModel instance # -model = highspy._highs.HighsModel() +model = highspy.HighsModel() model.lp_.model_name_ = "semi-definite" model.lp_.num_col_ = 3 model.lp_.num_row_ = 1 @@ -172,7 +172,7 @@ def user_interrupt_callback( model.lp_.col_upper_ = np.array([inf, inf, inf], dtype=np.double) model.lp_.row_lower_ = np.array([2], dtype=np.double) model.lp_.row_upper_ = np.array([inf], dtype=np.double) -model.lp_.a_matrix_.format_ = highspy._highs.MatrixFormat.kColwise +model.lp_.a_matrix_.format_ = highspy.MatrixFormat.kColwise model.lp_.a_matrix_.start_ = np.array([0, 1, 2, 3]) model.lp_.a_matrix_.index_ = np.array([0, 0, 0]) model.lp_.a_matrix_.value_ = np.array([1.0, 1.0, 1.0], dtype=np.double) @@ -189,19 +189,19 @@ def user_interrupt_callback( h.clear() num_col = 3 num_row = 1 -sense = highspy._highs.ObjSense.kMinimize +sense = highspy.ObjSense.kMinimize offset = 0 col_cost = np.array([1.0, 1.0, 2.0], dtype=np.double) col_lower = np.array([0, 0, 0], dtype=np.double) col_upper = np.array([inf, inf, inf], dtype=np.double) row_lower = np.array([2], dtype=np.double) row_upper = np.array([inf], dtype=np.double) -a_matrix_format = highspy._highs.MatrixFormat.kColwise +a_matrix_format = highspy.MatrixFormat.kColwise a_matrix_start = np.array([0, 1, 2, 3]) a_matrix_index = np.array([0, 0, 0]) a_matrix_value = np.array([1.0, 1.0, 1.0], dtype=np.double) a_matrix_num_nz = a_matrix_start[num_col] -hessian_format = highspy._highs.HessianFormat.kTriangular +hessian_format = highspy.HessianFormat.kTriangular hessian_start = np.array([0, 2, 2, 3]) hessian_index = np.array([0, 2, 2]) hessian_value = np.array([2.0, -1.0, 1.0], dtype=np.double) @@ -243,7 +243,7 @@ def user_interrupt_callback( presolved_lp = h.getPresolvedLp() # Create a HiGHS instance to solve the presolved LP print('\nCreate Highs instance to solve presolved LP') -h1 = highspy._highs.Highs() +h1 = highspy.Highs() h1.passModel(presolved_lp) options = h1.getOptions() options.presolve = "off" diff --git a/examples/call_highs_from_python_highspy.py b/examples/call_highs_from_python_highspy.py new file mode 100644 index 0000000000..30d18f1135 --- /dev/null +++ b/examples/call_highs_from_python_highspy.py @@ -0,0 +1,45 @@ + +import highspy +import numpy as np + +# Highs h +h = highspy.Highs() + +# Set up problem +inf = highspy.kHighsInf +h.addVars(2, np.array([-inf, -inf]), np.array([inf, inf])) +h.changeColsCost(2, np.array([0, 1]), np.array([0, 1], dtype=np.double)) +num_cons = 2 +lower = np.array([2, 0], dtype=np.double) +upper = np.array([inf, inf], dtype=np.double) +num_new_nz = 4 +starts = np.array([0, 2]) +indices = np.array([0, 1, 0, 1]) +values = np.array([-1, 1, 1, 1], dtype=np.double) +h.addRows(num_cons, lower, upper, num_new_nz, starts, indices, values) + +# Access LP +lp = h.getLp() +num_nz = h.getNumNz() +print('LP has ', lp.num_col_, ' columns', + lp.num_row_, ' rows and ', num_nz, ' nonzeros') + +# Solve problem +h.run() + +# Print solution information +solution = h.getSolution() +basis = h.getBasis() +info = h.getInfo() +model_status = h.getModelStatus() +print('Model status = ', h.modelStatusToString(model_status)) +print() +print('Optimal objective = ', info.objective_function_value) +print('Iteration count = ', info.simplex_iteration_count) +print('Primal solution status = ', + h.solutionStatusToString(info.primal_solution_status)) +print('Dual solution status = ', + h.solutionStatusToString(info.dual_solution_status)) +print('Basis validity = ', h.basisValidityToString(info.basis_validity)) + +h.clear() diff --git a/examples/call_highs_from_python_mps.py b/examples/call_highs_from_python_mps.py new file mode 100644 index 0000000000..69a74549b2 --- /dev/null +++ b/examples/call_highs_from_python_mps.py @@ -0,0 +1,39 @@ + +# The path to the MPS file instance assumes that this is run +# from the root directory. + +import highspy +import numpy as np + +# Highs h +h = highspy.Highs() + +# Solve from mps file +# Initialize an instance of Highs +# h = highspy.Highs() +# Here we are re-using the one from above. +h.readModel('check/instances/25fv47.mps') + +# Print +lp = h.getLp() +num_nz = h.getNumNz() +print('LP has ', lp.num_col_, ' columns', + lp.num_row_, ' rows and ', num_nz, ' nonzeros') + +# Solve the problem +h.run() + +# Print solution information +solution = h.getSolution() +basis = h.getBasis() +info = h.getInfo() +model_status = h.getModelStatus() +print('Model status = ', h.modelStatusToString(model_status)) +print() +print('Optimal objective = ', info.objective_function_value) +print('Iteration count = ', info.simplex_iteration_count) +print('Primal solution status = ', + h.solutionStatusToString(info.primal_solution_status)) +print('Dual solution status = ', + h.solutionStatusToString(info.dual_solution_status)) +print('Basis validity = ', h.basisValidityToString(info.basis_validity)) From 53b8670180297745bdb428281f257a29f3d6a754 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 23:48:09 +0000 Subject: [PATCH 36/45] macos m1 macos-14 runner --- .github/workflows/build-wheels.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 7c7dbc8c65..825b21ec8c 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -27,8 +27,9 @@ jobs: - [ubuntu-20.04, manylinux_x86_64] - [ubuntu-20.04, musllinux_x86_64] # No OpenBlas, no test - [macos-12, macosx_x86_64] - - [macos-12, macosx_arm64] - - [windows-2019, win_amd64, win_arm64] + - [macos-14, macosx_arm64] + - [windows-2019, win_amd64] + - [windows-2019, win_arm64] python: ["cp38", "cp39","cp310", "cp311","cp312"] steps: From 89c96b7e079ff37f53d60d908cfb83642b2aa938 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Mon, 4 Mar 2024 23:50:26 +0000 Subject: [PATCH 37/45] win arm does not seem to be supported --- .github/workflows/build-wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 825b21ec8c..387e24b530 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -29,7 +29,6 @@ jobs: - [macos-12, macosx_x86_64] - [macos-14, macosx_arm64] - [windows-2019, win_amd64] - - [windows-2019, win_arm64] python: ["cp38", "cp39","cp310", "cp311","cp312"] steps: From 1bbecf6db57a9752a0b543450eb758dbe565f394 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Tue, 5 Mar 2024 00:08:01 +0000 Subject: [PATCH 38/45] readme and examples --- README.md | 26 ++++----- examples/call_highs_from_python.py | 61 ++++++++++++++-------- examples/call_highs_from_python_highspy.py | 15 ++++-- 3 files changed, 64 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 99fbb663a7..fd75a440ea 100644 --- a/README.md +++ b/README.md @@ -142,19 +142,19 @@ The HiGHS C++ library no longer needs to be separately installed. The python pac #### Testing -The installation can be tested using the example [minimal.py](https://github.com/ERGO-Code/HiGHS/blob/master/examples/minimal.py), yielding the output - - Running HiGHS 1.5.0 [date: 2023-02-22, git hash: d041b3da0] - Copyright (c) 2023 HiGHS under MIT licence terms - Presolving model - 2 rows, 2 cols, 4 nonzeros - 0 rows, 0 cols, 0 nonzeros - 0 rows, 0 cols, 0 nonzeros - Presolve : Reductions: rows 0(-2); columns 0(-2); elements 0(-4) - Reduced to empty - Solving the original LP from the solution after postsolve - Model status : Optimal - Objective value : 1.0000000000e+00 - HiGHS run time : 0.00 +The installation can be tested using the small example [call_highs_from_python_highspy.py](https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python_highspy.py), yielding the output + + Running HiGHS 1.7.0 (git hash: n/a): Copyright (c) 2024 HiGHS under MIT licence terms + LP has 2 columns 2 rows and 4 nonzeros + Solving... + Problem solved. + + Model status = Optimal + Optimal objective = 1.0 + Iteration count = 0 + Primal solution status = Feasible + Dual solution status = Feasible + Basis validity = Valid or the more didactic [call_highs_from_python.py](https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python.py). diff --git a/examples/call_highs_from_python.py b/examples/call_highs_from_python.py index 0f8a327195..d1b2e3a5ec 100644 --- a/examples/call_highs_from_python.py +++ b/examples/call_highs_from_python.py @@ -12,30 +12,37 @@ h = highspy.Highs() inf = highspy.kHighsInf alt_inf = h.getInfinity() -print('highspy.kHighsInf = ', inf, '; h.getInfinity() = ', alt_inf) +print('highspy.kHighsInf = ', inf) +print('h.getInfinity() = ', alt_inf) + +# Define a callback + -# NB The callbacks are not available in -# https://pypi.org/project/highspy/ (HiGHS v1.5.3). To use them, -# highspy must be installed locally using (at least) HiGHS v1.6.0 def user_interrupt_callback( - callback_type, message, data_out, data_in, user_callback_data + callback_type, + message, + data_out, + data_in, + user_callback_data ): dev_run = True # or any other condition - # Constants for iteration limits or objective targets, adjust as per requirement + # Constants for iteration limits or objective targets, adjust as required ADLITTLE_SIMPLEX_ITERATION_LIMIT = 100 ADLITTLE_IPM_ITERATION_LIMIT = 100 EGOUT_OBJECTIVE_TARGET = 1.0 # Callback for MIP Improving Solution if callback_type == hscb.HighsCallbackType.kCallbackMipImprovingSolution: + # Assuming it is a list or array assert user_callback_data is not None, "User callback data is None!" - local_callback_data = user_callback_data[0] # Assuming it is a list or array + local_callback_data = user_callback_data[0] if dev_run: - print( - f"userCallback(type {callback_type}; data {local_callback_data:.4g}): {message} with objective {data_out.objective_function_value} and solution[0] = {data_out.mip_solution[0]}" - ) + print(f"userCallback(type {callback_type};") + print(f"data {local_callback_data:.4g}): {message}") + print(f"with objective {data_out.objective_function_value}") + print(f"and solution[0] = {data_out.mip_solution[0]}") # Check and update the objective function value assert ( @@ -47,12 +54,15 @@ def user_interrupt_callback( # Various other callback types if callback_type == hscb.HighsCallbackType.kCallbackLogging: if dev_run: - print(f"userInterruptCallback(type {callback_type}): {message}") + print(f"userInterruptCallback(type { + callback_type}): {message}") elif callback_type == hscb.HighsCallbackType.kCallbackSimplexInterrupt: if dev_run: print( - f"userInterruptCallback(type {callback_type}): {message} with iteration count = {data_out.simplex_iteration_count}" + f"userInterruptCallback(type {callback_type}): {message}") + print(f"with iteration count = { + data_out.simplex_iteration_count}" ) data_in.user_interrupt = ( data_out.simplex_iteration_count > ADLITTLE_SIMPLEX_ITERATION_LIMIT @@ -61,7 +71,8 @@ def user_interrupt_callback( elif callback_type == hscb.HighsCallbackType.kCallbackIpmInterrupt: if dev_run: print( - f"userInterruptCallback(type {callback_type}): {message} with iteration count = {data_out.ipm_iteration_count}" + f"userInterruptCallback(type {callback_type}): {message} with iteration count = { + data_out.ipm_iteration_count}" ) data_in.user_interrupt = ( data_out.ipm_iteration_count > ADLITTLE_IPM_ITERATION_LIMIT @@ -70,7 +81,8 @@ def user_interrupt_callback( elif callback_type == hscb.HighsCallbackType.kCallbackMipInterrupt: if dev_run: print( - f"userInterruptCallback(type {callback_type}): {message} with Bounds ({data_out.mip_dual_bound:.4g}, {data_out.mip_primal_bound:.4g}); Gap = {data_out.mip_gap:.4g}; Objective = {data_out.objective_function_value:.4g}" + f"userInterruptCallback(type {callback_type}): {message} with Bounds ({data_out.mip_dual_bound:.4g}, { + data_out.mip_primal_bound:.4g}); Gap = {data_out.mip_gap:.4g}; Objective = {data_out.objective_function_value:.4g}" ) data_in.user_interrupt = ( data_out.objective_function_value < EGOUT_OBJECTIVE_TARGET @@ -102,12 +114,15 @@ def user_interrupt_callback( print("Optimal objective = ", info.objective_function_value) print("Iteration count = ", info.simplex_iteration_count) print( - "Primal solution status = ", h.solutionStatusToString(info.primal_solution_status) + "Primal solution status = ", h.solutionStatusToString( + info.primal_solution_status) ) -print("Dual solution status = ", h.solutionStatusToString(info.dual_solution_status)) +print("Dual solution status = ", + h.solutionStatusToString(info.dual_solution_status)) print("Basis validity = ", h.basisValidityToString(info.basis_validity)) for icol in range(num_var): - print(icol, solution.col_value[icol], h.basisStatusToString(basis.col_status[icol])) + print(icol, solution.col_value[icol], + h.basisStatusToString(basis.col_status[icol])) # Read in and solve avgas h.readModel("check/instances/avgas.mps") @@ -146,18 +161,22 @@ def user_interrupt_callback( print("Optimal objective = ", info.objective_function_value) print("Iteration count = ", info.simplex_iteration_count) print( - "Primal solution status = ", h.solutionStatusToString(info.primal_solution_status) + "Primal solution status = ", h.solutionStatusToString( + info.primal_solution_status) ) -print("Dual solution status = ", h.solutionStatusToString(info.dual_solution_status)) +print("Dual solution status = ", + h.solutionStatusToString(info.dual_solution_status)) print("Basis validity = ", h.basisValidityToString(info.basis_validity)) num_var = h.getNumCol() num_row = h.getNumRow() print("Variables") for icol in range(num_var): - print(icol, solution.col_value[icol], h.basisStatusToString(basis.col_status[icol])) + print(icol, solution.col_value[icol], + h.basisStatusToString(basis.col_status[icol])) print("Constraints") for irow in range(num_row): - print(irow, solution.row_value[irow], h.basisStatusToString(basis.row_status[irow])) + print(irow, solution.row_value[irow], + h.basisStatusToString(basis.row_status[irow])) # Clear so that incumbent model is empty h.clear() diff --git a/examples/call_highs_from_python_highspy.py b/examples/call_highs_from_python_highspy.py index 30d18f1135..1cf6302a4a 100644 --- a/examples/call_highs_from_python_highspy.py +++ b/examples/call_highs_from_python_highspy.py @@ -8,7 +8,7 @@ # Set up problem inf = highspy.kHighsInf h.addVars(2, np.array([-inf, -inf]), np.array([inf, inf])) -h.changeColsCost(2, np.array([0, 1]), np.array([0, 1], dtype=np.double)) +h.changeColsCost(2, np.array([0, 1]), np.array([0, 1], dtype=np.double)); num_cons = 2 lower = np.array([2, 0], dtype=np.double) upper = np.array([inf, inf], dtype=np.double) @@ -24,16 +24,23 @@ print('LP has ', lp.num_col_, ' columns', lp.num_row_, ' rows and ', num_nz, ' nonzeros') +print('Solving...') +# Disable output from HiGHS for very small LP +h.setOptionValue("log_to_console", False) + # Solve problem h.run() +print('Problem solved.') +print() + # Print solution information -solution = h.getSolution() -basis = h.getBasis() +# solution = h.getSolution() +# basis = h.getBasis() info = h.getInfo() model_status = h.getModelStatus() + print('Model status = ', h.modelStatusToString(model_status)) -print() print('Optimal objective = ', info.objective_function_value) print('Iteration count = ', info.simplex_iteration_count) print('Primal solution status = ', From df4c5b61895458a34a0a5bc478f07b3696d948b2 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Tue, 5 Mar 2024 00:30:24 +0000 Subject: [PATCH 39/45] style --- examples/call_highs_from_python.py | 90 +++++++++++++++++++----------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/examples/call_highs_from_python.py b/examples/call_highs_from_python.py index d1b2e3a5ec..9a2c6dabdb 100644 --- a/examples/call_highs_from_python.py +++ b/examples/call_highs_from_python.py @@ -1,10 +1,6 @@ -# NB Must have installed highspy, either by using pip install highspy, -# or by following the instructions on -# https://github.com/ERGO-Code/HiGHS#python -# # The paths to MPS file instances assumes that this is run in the -# directory of this file (ie highs/examples) or any other subdirectory -# of HiGHS +# root directory of HiGHS + import numpy as np import highspy import highspy.cb as hscb @@ -12,8 +8,8 @@ h = highspy.Highs() inf = highspy.kHighsInf alt_inf = h.getInfinity() -print('highspy.kHighsInf = ', inf) -print('h.getInfinity() = ', alt_inf) +print('highspy.kHighsInf = ', inf, + 'h.getInfinity() = ', alt_inf) # Define a callback @@ -25,11 +21,12 @@ def user_interrupt_callback( data_in, user_callback_data ): - dev_run = True # or any other condition + dev_run = True + # dev_run = False # Constants for iteration limits or objective targets, adjust as required - ADLITTLE_SIMPLEX_ITERATION_LIMIT = 100 - ADLITTLE_IPM_ITERATION_LIMIT = 100 + SIMPLEX_ITERATION_LIMIT = 100 + IPM_ITERATION_LIMIT = 100 EGOUT_OBJECTIVE_TARGET = 1.0 # Callback for MIP Improving Solution @@ -59,36 +56,40 @@ def user_interrupt_callback( elif callback_type == hscb.HighsCallbackType.kCallbackSimplexInterrupt: if dev_run: - print( - f"userInterruptCallback(type {callback_type}): {message}") + print(f"userInterruptCallback(type { + callback_type}): {message}") print(f"with iteration count = { - data_out.simplex_iteration_count}" - ) + data_out.simplex_iteration_count}") + data_in.user_interrupt = ( - data_out.simplex_iteration_count > ADLITTLE_SIMPLEX_ITERATION_LIMIT + data_out.simplex_iteration_count > SIMPLEX_ITERATION_LIMIT ) elif callback_type == hscb.HighsCallbackType.kCallbackIpmInterrupt: if dev_run: - print( - f"userInterruptCallback(type {callback_type}): {message} with iteration count = { - data_out.ipm_iteration_count}" - ) + print(f"userInterruptCallback(type { + callback_type}): {message}") + print(f"with iteration count = {data_out.ipm_iteration_count}") + data_in.user_interrupt = ( - data_out.ipm_iteration_count > ADLITTLE_IPM_ITERATION_LIMIT + data_out.ipm_iteration_count > IPM_ITERATION_LIMIT ) elif callback_type == hscb.HighsCallbackType.kCallbackMipInterrupt: if dev_run: - print( - f"userInterruptCallback(type {callback_type}): {message} with Bounds ({data_out.mip_dual_bound:.4g}, { - data_out.mip_primal_bound:.4g}); Gap = {data_out.mip_gap:.4g}; Objective = {data_out.objective_function_value:.4g}" - ) + print(f"userInterruptCallback(type { + callback_type}): {message}") + print(f"Bounds ({data_out.mip_dual_bound:.4g}, { + data_out.mip_primal_bound:.4g});") + print(f"Gap = {data_out.mip_gap:.4g};") + print(f"Objective = {data_out.objective_function_value:.4g}") + data_in.user_interrupt = ( data_out.objective_function_value < EGOUT_OBJECTIVE_TARGET ) +# Define model h.addVar(-inf, inf) h.addVar(-inf, inf) h.changeColsCost(2, np.array([0, 1]), np.array([0, 1], dtype=np.double)) @@ -101,10 +102,14 @@ def user_interrupt_callback( values = np.array([-1, 1, 1, 1], dtype=np.double) h.addRows(num_cons, lower, upper, num_new_nz, starts, indices, values) h.setOptionValue("log_to_console", True) + +# Set callback and run h.setCallback(user_interrupt_callback, None) h.startCallback(hscb.HighsCallbackType.kCallbackLogging) h.run() h.stopCallback(hscb.HighsCallbackType.kCallbackLogging) + +# Get solution num_var = h.getNumCol() solution = h.getSolution() basis = h.getBasis() @@ -124,21 +129,25 @@ def user_interrupt_callback( print(icol, solution.col_value[icol], h.basisStatusToString(basis.col_status[icol])) + +# ~~~ # Read in and solve avgas h.readModel("check/instances/avgas.mps") + # h.writeModel("ml.mps") + h.run() lp = h.getLp() num_nz = h.getNumNz() -print( - "LP has ", lp.num_col_, " columns", lp.num_row_, " rows and ", num_nz, " nonzeros" -) +print("LP has ", lp.num_col_, + " columns", lp.num_row_, + " rows and ", num_nz, " nonzeros.") +# ~~~ # Clear so that incumbent model is empty h.clear() # Now define the blending model as a HighsLp instance -# lp = highspy.HighsLp() lp.num_col_ = 2 lp.num_row_ = 2 @@ -152,7 +161,11 @@ def user_interrupt_callback( lp.a_matrix_.index_ = np.array([0, 1, 0, 1]) lp.a_matrix_.value_ = np.array([0.3, 0.7, 0.5, 0.5], dtype=np.double) h.passModel(lp) + +# Solve h.run() + +# Print solution solution = h.getSolution() basis = h.getBasis() info = h.getInfo() @@ -178,10 +191,11 @@ def user_interrupt_callback( print(irow, solution.row_value[irow], h.basisStatusToString(basis.row_status[irow])) +# ~~~ # Clear so that incumbent model is empty h.clear() + # Now define the test-semi-definite0 model (from TestQpSolver.cpp) as a HighsModel instance -# model = highspy.HighsModel() model.lp_.model_name_ = "semi-definite" model.lp_.num_col_ = 3 @@ -204,6 +218,7 @@ def user_interrupt_callback( h.passModel(model) h.run() +# ~~~ # Clear so that incumbent model is empty h.clear() num_col = 3 @@ -253,29 +268,38 @@ def user_interrupt_callback( h.run() h.writeSolution("", 1) +# ~~~ # Clear so that incumbent model is empty h.clear() print("25fv47 as HighsModel") h.readModel("check/instances/25fv47.mps") + h.presolve() presolved_lp = h.getPresolvedLp() + # Create a HiGHS instance to solve the presolved LP print('\nCreate Highs instance to solve presolved LP') h1 = highspy.Highs() h1.passModel(presolved_lp) + +# Get and set options options = h1.getOptions() options.presolve = "off" options.solver = "ipm" + h1.passOptions(options) h1.writeOptions("") + h1.run() solution = h1.getSolution() basis = h1.getBasis() -print( - "\nCrossover then postsolve LP using solution and basis from other Highs instance" -) + +print("Crossover, then postsolve using solution and basis from another instance") + h.postsolve(solution, basis) + +# Get solution info = h.getInfo() model_status = h.getModelStatus() print("Model status = ", h.modelStatusToString(model_status)) From a9bfcd4e4db0f1fafaed6dac52d83ffae4c9de09 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Tue, 5 Mar 2024 00:33:36 +0000 Subject: [PATCH 40/45] wheel push on tagged release on --- .github/workflows/build-wheels.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 387e24b530..40ead1399b 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -1,11 +1,11 @@ # Python release WIP name: Build wheels -on: [push] +# on: [push] -# on: -# release: -# types: -# - published +on: + release: + types: + - published concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 8dd8b7286cbc309e92c837fbb8f519fde0ae2bda Mon Sep 17 00:00:00 2001 From: Ivet Galabova Date: Tue, 5 Mar 2024 02:43:18 +0200 Subject: [PATCH 41/45] print format --- examples/call_highs_from_python.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/call_highs_from_python.py b/examples/call_highs_from_python.py index 9a2c6dabdb..28a661e4fb 100644 --- a/examples/call_highs_from_python.py +++ b/examples/call_highs_from_python.py @@ -51,15 +51,13 @@ def user_interrupt_callback( # Various other callback types if callback_type == hscb.HighsCallbackType.kCallbackLogging: if dev_run: - print(f"userInterruptCallback(type { - callback_type}): {message}") + print(f"userInterruptCallback(type {callback_type}): {message}") elif callback_type == hscb.HighsCallbackType.kCallbackSimplexInterrupt: if dev_run: - print(f"userInterruptCallback(type { - callback_type}): {message}") - print(f"with iteration count = { - data_out.simplex_iteration_count}") + print(f"userInterruptCallback(type {callback_type}): {message}") + print("with iteration count = ", + data_out.simplex_iteration_count) data_in.user_interrupt = ( data_out.simplex_iteration_count > SIMPLEX_ITERATION_LIMIT From f503b600e067b6cdc5b6926a64c92d43d84764b5 Mon Sep 17 00:00:00 2001 From: Ivet Galabova Date: Tue, 5 Mar 2024 03:16:31 +0200 Subject: [PATCH 42/45] readme cleanup and python example fix --- README.md | 111 ++++++++--------------------- examples/call_highs_from_python.py | 15 ++-- 2 files changed, 36 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index fd75a440ea..f6d570da3e 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,17 @@ [![PyPi](https://img.shields.io/pypi/v/highspy.svg)](https://pypi.python.org/pypi/highspy) [![PyPi](https://img.shields.io/pypi/dm/highspy.svg)](https://pypi.python.org/pypi/highspy) -## Table of Contents - - [HiGHS - Linear optimization software](#highs---linear-optimization-software) - - [Table of Contents](#table-of-contents) - [About HiGHS](#about-highs) - [Documentation](#documentation) - [Installation](#installation) + - [Build from source using CMake](#build-from-source-using-cmake) - [Precompiled binaries](#precompiled-binaries) - - [Compilation](#compilation) - - [Meson](#meson) - - [Python](#python) - [Interfaces](#interfaces) - - [Python](#python-1) - - [From PyPi](#from-pypi) - - [Build directly from Git](#build-directly-from-git) - - [Testing](#testing) - - [Google Colab Example](#google-colab-example) + - [Python](#python) - [Reference](#reference) ## About HiGHS ------------ HiGHS is a high performance serial and parallel solver for large scale sparse linear optimization problems of the form @@ -46,126 +36,83 @@ Documentation is available at https://ergo-code.github.io/HiGHS/. ## Installation -There are various ways to install the HiGHS library. These are detailed below. - -### Precompiled binaries --------------------- - -Precompiled static executables are available for a variety of platforms at -https://github.com/JuliaBinaryWrappers/HiGHSstatic_jll.jl/releases - -_These binaries are provided by the Julia community and are not officially supported by the HiGHS development team. If you have trouble using these libraries, please open a GitHub issue and tag `@odow` in your question._ - -See https://ergo-code.github.io/HiGHS/stable/installation/#Precompiled-Binaries. - -### Compilation ---------------- - -HiGHS uses CMake as build system, and requires at least version 3.15. First setup a build folder and call CMake as follows - - mkdir build - cd build - cmake .. - -Then compile the code using - - cmake --build . +### Build from source using CMake -This installs the executable `bin/highs`. - -As an alternative it is also possible to let `cmake` create the build folder and thus build everything from the HiGHS directory, as follows +HiGHS uses CMake as build system, and requires at least version 3.15. To generate build files in a new subdirectory called 'build', run: +```sh cmake -S . -B build cmake --build build +``` +This installs the executable `bin/highs` and the library `lib/highs`. +To test whether the compilation was successful, change into the build directory and run -To test whether the compilation was successful, run - +```sh ctest +``` HiGHS can read MPS files and (CPLEX) LP files, and the following command solves the model in `ml.mps` +```sh highs ml.mps - +``` HiGHS is installed using the command - cmake --install . - -with the optional setting of `--prefix = The installation prefix CMAKE_INSTALL_PREFIX` if it is to be installed anywhere other than the default location. +```sh + cmake --install build +``` -### Meson ------ +with the optional setting of `--prefix `, or the cmake option `CMAKE_INSTALL_PREFIX` if it is to be installed anywhere other than the default location. -HiGHs can also use the `meson` build interface: +As an alternative, HiGHS can be installed using the `meson` build interface: ``` sh meson setup bbdir -Dwith_tests=True meson test -C bbdir ``` +_The meson build files are provided by the community and are not officially supported by the HiGHS development team._ +### Precompiled binaries -### Python ------ +Precompiled static executables are available for a variety of platforms at +https://github.com/JuliaBinaryWrappers/HiGHSstatic_jll.jl/releases -Installing from PyPI through your Python package manager of choice (e.g., `pip`) will also -install the HiGHS library if not already present. HiGHS is available as `highspy` on [PyPi](https://pypi.org/project/highspy/). +_These binaries are provided by the Julia community and are not officially supported by the HiGHS development team. If you have trouble using these libraries, please open a GitHub issue and tag `@odow` in your question._ -If `highspy` is not already installed, run: +See https://ergo-code.github.io/HiGHS/stable/installation/#Precompiled-Binaries. -```bash -$ pip install highspy -``` ## Interfaces + There are HiGHS interfaces for C, C#, FORTRAN, and Python in [HiGHS/src/interfaces](https://github.com/ERGO-Code/HiGHS/blob/master/src/interfaces), with example driver files in [HiGHS/examples](https://github.com/ERGO-Code/HiGHS/blob/master/examples). More on language and modelling interfaces can be found at https://ergo-code.github.io/HiGHS/stable/interfaces/other/. We are happy to give a reasonable level of support via email sent to highsopt@gmail.com. -### Python +#### Python The python package `highspy` is a thin wrapper around HiGHS and is available on [PyPi](https://pypi.org/project/highspy/). It can be easily installed via `pip` by running -```bash +```sh $ pip install highspy ``` Alternatively, `highspy` can be built from source. Download the HiGHS source code and run -```bash +```sh pip install . ``` - from the root directory. The HiGHS C++ library no longer needs to be separately installed. The python package `highspy` depends on the `numpy` package and `numpy` will be installed as well, if it is not already present. -#### Testing - -The installation can be tested using the small example [call_highs_from_python_highspy.py](https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python_highspy.py), yielding the output - - Running HiGHS 1.7.0 (git hash: n/a): Copyright (c) 2024 HiGHS under MIT licence terms - LP has 2 columns 2 rows and 4 nonzeros - Solving... - Problem solved. - - Model status = Optimal - Optimal objective = 1.0 - Iteration count = 0 - Primal solution status = Feasible - Dual solution status = Feasible - Basis validity = Valid - -or the more didactic [call_highs_from_python.py](https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python.py). - -#### Google Colab Example - -The [Google Colab Example Notebook](https://colab.research.google.com/drive/1JmHF53OYfU-0Sp9bzLw-D2TQyRABSjHb?usp=sharing) demonstrates how to call HiGHS via the Python interface `highspy`. +The installation can be tested using the small example [call_highs_from_python_highspy.py](https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python_highspy.py). +The [Google Colab Example Notebook](https://colab.research.google.com/drive/1JmHF53OYfU-0Sp9bzLw-D2TQyRABSjHb?usp=sharing) also demonstrates how to call `highspy`. ## Reference - If you use HiGHS in an academic context, please acknowledge this and cite the following article. Parallelizing the dual revised simplex method diff --git a/examples/call_highs_from_python.py b/examples/call_highs_from_python.py index 28a661e4fb..978094bdba 100644 --- a/examples/call_highs_from_python.py +++ b/examples/call_highs_from_python.py @@ -65,8 +65,7 @@ def user_interrupt_callback( elif callback_type == hscb.HighsCallbackType.kCallbackIpmInterrupt: if dev_run: - print(f"userInterruptCallback(type { - callback_type}): {message}") + print(f"userInterruptCallback(type {callback_type}): {message}") print(f"with iteration count = {data_out.ipm_iteration_count}") data_in.user_interrupt = ( @@ -75,11 +74,10 @@ def user_interrupt_callback( elif callback_type == hscb.HighsCallbackType.kCallbackMipInterrupt: if dev_run: - print(f"userInterruptCallback(type { - callback_type}): {message}") - print(f"Bounds ({data_out.mip_dual_bound:.4g}, { - data_out.mip_primal_bound:.4g});") - print(f"Gap = {data_out.mip_gap:.4g};") + print(f"userInterruptCallback(type {callback_type}): {message}") + print(f"Dual bound = {data_out.mip_dual_bound:.4g}") + print(f"Primal bound = {data_out.mip_primal_bound:.4g}") + print(f"Gap = {data_out.mip_gap:.4g}") print(f"Objective = {data_out.objective_function_value:.4g}") data_in.user_interrupt = ( @@ -193,7 +191,8 @@ def user_interrupt_callback( # Clear so that incumbent model is empty h.clear() -# Now define the test-semi-definite0 model (from TestQpSolver.cpp) as a HighsModel instance +# Now define the test-semi-definite0 model (from TestQpSolver.cpp) +# as a HighsModel instance model = highspy.HighsModel() model.lp_.model_name_ = "semi-definite" model.lp_.num_col_ = 3 From f78bc6fe831026b6070309c304d9c03156c85574 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Tue, 5 Mar 2024 01:39:20 +0000 Subject: [PATCH 43/45] pr clean up --- .github/workflows/build-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 40ead1399b..04051215a3 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -27,7 +27,7 @@ jobs: - [ubuntu-20.04, manylinux_x86_64] - [ubuntu-20.04, musllinux_x86_64] # No OpenBlas, no test - [macos-12, macosx_x86_64] - - [macos-14, macosx_arm64] + - [macos-12, macosx_arm64] - [windows-2019, win_amd64] python: ["cp38", "cp39","cp310", "cp311","cp312"] From 6652618020d7e1d22130202971fcbf5423597447 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Tue, 5 Mar 2024 02:00:53 +0000 Subject: [PATCH 44/45] versions --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3b6cf9c26f..35d4858f7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [build-system] # Minimum requirements for the build system to execute. requires = [ - "setuptools>=45", + "setuptools>=42", "pybind11>=2.4", "wheel", "cmake>=3.12", diff --git a/setup.py b/setup.py index 5a3d5ce40f..5243009a75 100644 --- a/setup.py +++ b/setup.py @@ -135,7 +135,7 @@ def build_extension(self, ext: CMakeExtension) -> None: # logic and declaration, and simpler if you include description/version in a file. setup( name="highspy", - version="1.6.6.dev2", + version="1.6.8", description = "A thin set of pybind11 wrappers to HiGHS", author="HiGHS developers", author_email="highsopt@gmail.com", From ee3ef6c1ca8a6924fb90274a99abe6977a864a59 Mon Sep 17 00:00:00 2001 From: galabovaa Date: Tue, 5 Mar 2024 02:20:22 +0000 Subject: [PATCH 45/45] version ready for tag --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5243009a75..7aeec8c296 100644 --- a/setup.py +++ b/setup.py @@ -135,7 +135,7 @@ def build_extension(self, ext: CMakeExtension) -> None: # logic and declaration, and simpler if you include description/version in a file. setup( name="highspy", - version="1.6.8", + version="1.7.0", description = "A thin set of pybind11 wrappers to HiGHS", author="HiGHS developers", author_email="highsopt@gmail.com",