Skip to content

Commit

Permalink
Merge pull request #2089 from ERGO-Code/sdist
Browse files Browse the repository at this point in the history
Add sdist to python package and update bazel build and test
  • Loading branch information
galabovaa authored Dec 20, 2024
2 parents ee702d3 + d1aced3 commit efa50c5
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 35 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/build-bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel cache # Optional
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: bazel
- uses: bazelbuild/setup-bazelisk@v3

- name: bazel clean
run: bazel clean

- name: build bazel
run: |
bazel build //...
run: bazel build --enable_bzlmod //...

- name: test
- name: test all
run: bazel test --enable_bzlmod //...

- name: test example
run: ./bazel-bin/call-highs-example
3 changes: 2 additions & 1 deletion .github/workflows/build-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: seanmiddleditch/gha-setup-ninja@master

- name: Build sdist
run: |
Expand Down Expand Up @@ -194,7 +195,7 @@ jobs:
python -m pip install pytest
python -m pytest
build_wheel_windows:
build_wheel_windows_313:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/build-python-sdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: build-python-sdist

on: [push, pull_request]

jobs:
build_sdist_ubuntu:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- uses: seanmiddleditch/gha-setup-ninja@master

- name: Build sdist
shell: bash
run: pipx run build --sdist

- name: check metadata
run: pipx run twine check dist/*

- name: install highspy
run: |
python3 -m pip install dist/*.tar.gz --user
- 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
python3 ./examples/minimal.py
build_sdist_mac:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]

steps:
- uses: actions/checkout@v4
- uses: seanmiddleditch/gha-setup-ninja@master

- name: Build sdist
shell: bash
run: pipx run build --sdist

- name: check metadata
run: pipx run twine check dist/*

- name: install highspy
run: |
python3 -m venv path/to/venv
source path/to/venv/bin/activate
python3 -m pip install dist/*.tar.gz
- name: Test Python Examples
run: |
source path/to/venv/bin/activate
python3 ./examples/call_highs_from_python_highspy.py
python3 ./examples/call_highs_from_python_mps.py
python3 ./examples/call_highs_from_python.py
python3 ./examples/minimal.py
build_sdist_win:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Build sdist
shell: bash
run: pipx run build --sdist

- name: check metadata
run: pipx run twine check dist/*

- name: install highspy
run: |
$item = Get-ChildItem dist
python -m pip install "$item"
- 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
python ./examples/minimal.py
10 changes: 6 additions & 4 deletions .github/workflows/build-wheels-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
shell: bash
run: pipx run build --sdist

# - name: check metadata
# run: pipx run twine check python/dist/*
- name: check metadata
run: pipx run twine check dist/*

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: python/dist/*.tar.gz
path: dist/*.tar.gz

build_wheels:
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
Expand Down Expand Up @@ -86,13 +86,14 @@ jobs:
# Publish highspy to TestPyPI
# runs-on: ubuntu-latest
# needs: [build_wheels, build_sdist]
# # needs: [build_sdist]

# # upload to PyPI on every tag starting with 'v'
# # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

# environment:
# name: testpypi
# url: https://testpypi.org/p/highspy
# url: https://test.pypi.org/p/highspy

# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing
Expand All @@ -107,6 +108,7 @@ jobs:
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# verbose: true

upload_pypi:
name: >-
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
shell: bash
run: pipx run build --sdist

- name: check metadata
run: pipx run twine check dist/*

build_wheels:
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
runs-on: ${{ matrix.buildplat[0] }}
Expand Down
2 changes: 0 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ cc_library(
name = "highs",
srcs = glob([
"extern/filereaderlp/*.cpp",
"extern/zlib/*.cpp",
"src/interfaces/highs_c_api.cpp",
"src/io/*.cpp",
"src/ipm/*.cpp",
Expand All @@ -37,7 +36,6 @@ cc_library(
"src/util/*.cpp",
]),
hdrs = glob([
"HConfig.h",
"**/*.h",
"src/qpsolver/*.hpp",
"src/Highs.h",
Expand Down
10 changes: 7 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
"""highs module
"""
module(
name = "highs",
version = "1.8.1",
)

bazel_dep(
name = "bazel_skylib",
version = "1.6.1",
version = "1.7.1",
)

bazel_dep(
name = "rules_cc",
version = "0.0.9",
version = "0.0.16",
)

bazel_dep(
name = "zlib",
version = "1.3.1.bcr.1",
version = "1.3.1.bcr.3",
)
14 changes: 4 additions & 10 deletions check/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,10 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
TestThrow.cpp
TestTspSolver.cpp
TestUserScale.cpp
Avgas.cpp)

# todo: IG
if (NOT APPLE)
# Bug with updated IPX code and gas11. Maybe somehow related to the rpath on
# macOS (Lukas). Only triggered by gas11 with no presolve which is strange.
# may be an interface related issue which will pop up soon.
# works OK on linux. The test was added to doctest for macOS but still hanging.
set(TEST_SOURCES ${TEST_SOURCES} TestSpecialLps.cpp TestLpSolvers.cpp TestMipSolver.cpp)
endif()
Avgas.cpp
TestSpecialLps.cpp
TestLpSolvers.cpp
TestMipSolver.cpp)

if (BUILD_EXTRA_UNIT_TESTS)
list(APPEND CMAKE_MODULE_PATH "${HIGHS_SOURCE_DIR}/check/highs-unit-tests")
Expand Down
4 changes: 2 additions & 2 deletions check/TestLpSolvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ TEST_CASE("LP-solver", "[highs_lp_solver]") {
const HighsInfo& info = highs.getInfo();
REQUIRE(info.num_dual_infeasibilities == 0);

REQUIRE(info.simplex_iteration_count == 472);
// REQUIRE(info.simplex_iteration_count == 472); // differs on macOS

HighsModelStatus model_status = highs.getModelStatus();
REQUIRE(model_status == HighsModelStatus::kOptimal);
Expand All @@ -316,7 +316,7 @@ TEST_CASE("LP-solver", "[highs_lp_solver]") {
return_status = highs.run();
REQUIRE(return_status == HighsStatus::kOk);

REQUIRE(info.simplex_iteration_count == 592);
// REQUIRE(info.simplex_iteration_count == 592); // differs on macOS
}

TEST_CASE("mip-with-lp-solver", "[highs_lp_solver]") {
Expand Down
14 changes: 11 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,17 @@ sdist.exclude = [
".clang-format",
"__setup.py",
"BUILD.bazel",
"meson*",
"**meson**",
"MODS.md",
"WORKSPACE",
"nuget/",
"nuget/README.md",
"src/*.bazel*",
"src/*.meson*",
"interfaces/*csharp*",
"interfaces/*fortran*",
"flake.*",
"highs.pc.in"
]


Expand All @@ -90,9 +98,9 @@ sdist.exclude = [
# # The versions of Ninja to allow. If Ninja is not present on the system or does
# # not pass this specifier, it will be downloaded via PyPI if possible. An empty
# # string will disable this check.
# ninja.version = ">=1.5"
# ninja.version = ">=1.5"

# # If CMake is not present on the system or is older required, it will be
# # If Ninja is not present on the system or is older required, it will be
# # downloaded via PyPI if possible. An empty string will disable this check.
# ninja.make-fallback = true

Expand Down

0 comments on commit efa50c5

Please sign in to comment.