Skip to content

Commit 0097ef4

Browse files
cdienerMidnighter
andauthored
Enable Python 3.13 and make tests more resilient to lacking cplex/gurobi 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]>
1 parent 8e49484 commit 0097ef4

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest]
18-
python-version: ["3.11"]
18+
python-version: ["3.13"]
1919
runs-on: ${{ matrix.os }}
2020
permissions:
2121
# Write permissions are needed to create OIDC tokens.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [ubuntu-latest, macos-13, windows-latest]
14-
python-version: ["3.8", "3.11"]
14+
python-version: ["3.9", "3.11", "3.13"]
1515

1616
steps:
1717
- uses: actions/checkout@v4

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Next Release
99
* enable compatibility with Gurobi 12.0
1010
* fix an issue where the removal of more than 350 constraints
1111
would lead to dangling references
12+
* add support for Python 3.13
1213

1314
1.8.2
1415
-----

setup.cfg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ classifiers =
1515
License :: OSI Approved :: Apache Software License
1616
Natural Language :: English
1717
Operating System :: OS Independent
18-
Programming Language :: Python :: 3.8
1918
Programming Language :: Python :: 3.9
2019
Programming Language :: Python :: 3.10
2120
Programming Language :: Python :: 3.11
21+
Programming Language :: Python :: 3.12
22+
Programming Language :: Python :: 3.13
2223
Topic :: Scientific/Engineering :: Mathematics
2324
license = Apache-2.0
2425
description = Formulate optimization problems using sympy expressions and solve them using interfaces to third-party optimization software (e.g. GLPK).
@@ -33,9 +34,9 @@ keywords =
3334
[options]
3435
zip_safe = True
3536
install_requires =
36-
swiglpk >=5.0.8
37+
swiglpk >=5.0.12
3738
sympy >=1.12.0
38-
python_requires = >=3.8
39+
python_requires = >=3.9
3940
tests_require =
4041
tox
4142
packages = find:

src/optlang/tests/test_container.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ def test_dir(self):
4747
var = Variable('blub')
4848
self.container.append(var)
4949
print(dir(self.container))
50-
self.assertEqual(dir(self.container),
51-
['__contains__', '__delitem__', '__dict__', '__dir__', '__doc__', '__getattr__', '__getitem__',
52-
'__getstate__', '__init__', '__iter__', '__len__', '__module__', '__setitem__',
53-
'__setstate__', '__weakref__', '_check_for_name_attribute', '_reindex', 'append', 'blub',
54-
'clear', 'extend', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys',
55-
'itervalues', 'keys', 'update_key', 'values'])
50+
self.assertTrue(
51+
all(hasattr(self.container, attribute)
52+
for attribute in ['__contains__', 'keys', 'values'])
53+
)
5654

5755
def test_del_by_index(self):
5856
variables_iterable = [Variable("v" + str(i), lb=10, ub=100) for i in range(1000)]

tox.ini

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
[tox]
2-
envlist = isort, black, flake8, safety, docs, py3{8,9,10,11}, py3{8,9,10,11}-symengine
2+
envlist =
3+
isort
4+
black
5+
flake8
6+
safety
7+
docs
8+
py3{9,11,13}
9+
py3{9,11,13}-symengine
310

411
[gh-actions]
512
python =
6-
3.8: safety, py38, py38-symengine
713
3.9: safety, py39, py39-symengine
8-
3.10: safety, py310, py310-symengine
914
3.11: safety, py311, py311-symengine
15+
3.13: safety, py313, py313-symengine
1016

1117
;[testenv]
1218
;deps =
@@ -24,13 +30,13 @@ deps =
2430
jsonschema
2531
pytest
2632
pytest-cov
27-
scipy
28-
numpy >=1.13,<1.24
33+
scipy <1.15.0 # until https://github.com/scipy/scipy/issues/22257 is fixed
34+
numpy >=1.13
2935
osqp >=0.6.2
30-
mip >=1.9.1
36+
mip >=1.9.1; python_version < "3.13"
3137
highspy >=1.5.3
32-
cplex
33-
gurobipy
38+
cplex; python_version < "3.12"
39+
gurobipy; python_version < "3.13"
3440
symengine: symengine
3541
passenv = CI
3642
commands =

0 commit comments

Comments
 (0)