File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 78
78
79
79
- name : Install dependencies CPython
80
80
if : ${{ matrix.python-version != 'pypy3' }}
81
- run : python -m pip install cffi pytest networkx numpy matplotlib
81
+ run : python -m pip install cffi pytest networkx numpy matplotlib gurobipy
82
82
83
83
- name : Install dependencies PyPy
84
84
if : ${{ matrix.python-version == 'pypy3' && matrix.os != 'macos-latest' }}
94
94
- name : list installed packages
95
95
run : python -m pip list
96
96
97
- - name : run tests
97
+ - name : Run tests PyPy
98
+ if : ${{ matrix.python-version == 'pypy3'}}
99
+ run : |
100
+ python -m pytest test --verbose --color=yes --doctest-modules --ignore="test/test_gurobi.py"
101
+ python -m pytest mip --verbose --color=yes --doctest-modules --ignore="mip/gurobi.py"
102
+
103
+ - name : Run tests
104
+ if : ${{ matrix.python-version != 'pypy3'}}
98
105
run : |
99
106
python -m pytest test --verbose --color=yes --doctest-modules
100
107
python -m pytest mip --verbose --color=yes --doctest-modules --ignore="mip/gurobi.py"
Original file line number Diff line number Diff line change 8
8
from os import environ
9
9
import numbers
10
10
from cffi import FFI
11
+ import importlib .util
12
+ import pathlib
11
13
from mip .exceptions import (
12
14
ParameterNotAvailable ,
13
15
SolutionNotAvailable ,
84
86
if lib_path is not None :
85
87
break
86
88
89
+ # Check for gurobi 9.5 through pip installation
90
+ if lib_path is None :
91
+ gurobipy_spec = importlib .util .find_spec ("gurobipy" )
92
+ if gurobipy_spec :
93
+ parent_path = pathlib .Path (gurobipy_spec .origin ).parent
94
+ if platform .lower ().startswith ("win" ):
95
+ extension = ".dll"
96
+ else :
97
+ extension = ".so"
98
+ lib_path = str (next (parent_path .glob (f"*{ extension } " )))
99
+
100
+
87
101
if lib_path is None :
88
102
found = False
89
103
else :
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ import mip
4
+
5
+
6
+ def test_gurobi_pip_installation ():
7
+ # Even though we have no valid license yet, we could check that the binaries are found.
8
+ # If no valid license is found, an InterfacingError is thrown
9
+
10
+ with pytest .raises (mip .InterfacingError ):
11
+ mip .Model (solver_name = "GRB" )
12
+
You can’t perform that action at this time.
0 commit comments