Skip to content

Commit

Permalink
Enable Python 3.13 and make tests more resilient to lacking cplex/gur…
Browse files Browse the repository at this point in the history
…obi wheels (#276)

* switch to conditional additional solvers

* add RNs

* no idea how this syntax works

* no idea how this syntax works

* try this

* change the dir test

* Update src/optlang/tests/test_container.py

Co-authored-by: Moritz E. Beber <[email protected]>

* update swiglpk

* pin scipy to lower version to not break highs

* fix req

---------

Co-authored-by: Moritz E. Beber <[email protected]>
  • Loading branch information
cdiener and Midnighter authored Jan 7, 2025
1 parent 8e49484 commit 0097ef4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
python-version: ["3.13"]
runs-on: ${{ matrix.os }}
permissions:
# Write permissions are needed to create OIDC tokens.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
python-version: ["3.8", "3.11"]
python-version: ["3.9", "3.11", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Next Release
* enable compatibility with Gurobi 12.0
* fix an issue where the removal of more than 350 constraints
would lead to dangling references
* add support for Python 3.13

1.8.2
-----
Expand Down
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ classifiers =
License :: OSI Approved :: Apache Software License
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Topic :: Scientific/Engineering :: Mathematics
license = Apache-2.0
description = Formulate optimization problems using sympy expressions and solve them using interfaces to third-party optimization software (e.g. GLPK).
Expand All @@ -33,9 +34,9 @@ keywords =
[options]
zip_safe = True
install_requires =
swiglpk >=5.0.8
swiglpk >=5.0.12
sympy >=1.12.0
python_requires = >=3.8
python_requires = >=3.9
tests_require =
tox
packages = find:
Expand Down
10 changes: 4 additions & 6 deletions src/optlang/tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ def test_dir(self):
var = Variable('blub')
self.container.append(var)
print(dir(self.container))
self.assertEqual(dir(self.container),
['__contains__', '__delitem__', '__dict__', '__dir__', '__doc__', '__getattr__', '__getitem__',
'__getstate__', '__init__', '__iter__', '__len__', '__module__', '__setitem__',
'__setstate__', '__weakref__', '_check_for_name_attribute', '_reindex', 'append', 'blub',
'clear', 'extend', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys',
'itervalues', 'keys', 'update_key', 'values'])
self.assertTrue(
all(hasattr(self.container, attribute)
for attribute in ['__contains__', 'keys', 'values'])
)

def test_del_by_index(self):
variables_iterable = [Variable("v" + str(i), lb=10, ub=100) for i in range(1000)]
Expand Down
22 changes: 14 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
[tox]
envlist = isort, black, flake8, safety, docs, py3{8,9,10,11}, py3{8,9,10,11}-symengine
envlist =
isort
black
flake8
safety
docs
py3{9,11,13}
py3{9,11,13}-symengine

[gh-actions]
python =
3.8: safety, py38, py38-symengine
3.9: safety, py39, py39-symengine
3.10: safety, py310, py310-symengine
3.11: safety, py311, py311-symengine
3.13: safety, py313, py313-symengine

;[testenv]
;deps =
Expand All @@ -24,13 +30,13 @@ deps =
jsonschema
pytest
pytest-cov
scipy
numpy >=1.13,<1.24
scipy <1.15.0 # until https://github.com/scipy/scipy/issues/22257 is fixed
numpy >=1.13
osqp >=0.6.2
mip >=1.9.1
mip >=1.9.1; python_version < "3.13"
highspy >=1.5.3
cplex
gurobipy
cplex; python_version < "3.12"
gurobipy; python_version < "3.13"
symengine: symengine
passenv = CI
commands =
Expand Down

0 comments on commit 0097ef4

Please sign in to comment.