Skip to content

Commit

Permalink
Merge branch 'main' into copt_pyomo
Browse files Browse the repository at this point in the history
  • Loading branch information
wujianjack committed Oct 11, 2023
2 parents 404adf8 + 4267cbd commit bee3177
Show file tree
Hide file tree
Showing 23 changed files with 519 additions and 243 deletions.
2 changes: 1 addition & 1 deletion .coin-or/projDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ Carl D. Laird, Chair, Pyomo Management Committee, claird at andrew dot cmu dot e

<platform>
<operatingSystem>Any</operatingSystem>
<compiler>Python 3.7, 3.8, 3.9, 3.10, 3.11</compiler>
<compiler>Python 3.8, 3.9, 3.10, 3.11</compiler>
</platform>

</testedPlatforms>
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_wheel_creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wheel-version: ['cp37-cp37m', 'cp38-cp38', 'cp39-cp39', 'cp310-cp310', 'cp311-cp311']
wheel-version: ['cp38-cp38', 'cp39-cp39', 'cp310-cp310', 'cp311-cp311']
os: [ubuntu-latest]
include:
- os: ubuntu-latest
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
include:
- os: macos-latest
TARGET: osx
python-version: [ 3.7, 3.8, 3.9, '3.10', '3.11' ]
python-version: [ 3.8, 3.9, '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
include:
- os: windows-latest
TARGET: win
python-version: [ 3.7, 3.8, 3.9, '3.10', '3.11' ]
python-version: [ 3.8, 3.9, '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
39 changes: 27 additions & 12 deletions .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,34 @@ jobs:
echo "*** Install Pyomo dependencies ***"
conda install --update-deps -q -y $CONDA_DEPENDENCIES
if test -z "${{matrix.slim}}"; then
echo "*** Install CPLEX ***"
conda install -q -y 'cplex>=12.10' docplex \
|| echo "WARNING: CPLEX Community Edition is not available"
echo "*** Install Gurobi ***"
conda install -q -y gurobi \
|| echo "WARNING: Gurobi is not available"
echo "*** Install Xpress ***"
conda install -q -y xpress \
|| echo "WARNING: Xpress Community Edition is not available"
for PKG in cyipopt pymumps scip; do
PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g')
echo "Installing for $PYVER"
for PKG in 'cplex>=12.10' docplex gurobi xpress cyipopt pymumps scip; do
echo ""
echo "*** Install $PKG ***"
conda install -q -y $PKG \
|| echo "WARNING: $PKG is not available"
# conda can literally take an hour to determine that a
# package is not available. Perform a quick search to see
# if the package is available for this interpreter before
# attempting an install.
# NOTE: conda search will attempt approximate matches.
_PKGLIST=$(conda search -f "$PKG") || echo "Package $PKG not found"
echo "$_PKGLIST"
_BASE=$(echo "$PKG" | sed 's/[=<>].*//')
_BUILDS=$(echo "$_PKGLIST" | grep "^$_BASE " \
| sed -r 's/\s+/ /g' | cut -d\ -f3) || echo ""x
if test -n "$_BUILDS"; then
_ISPY=$(echo "$_BUILDS" | grep "^py") \
|| echo "No python build detected"
_PYOK=$(echo "$_BUILDS" | grep "^$PYVER") \
|| echo "No python build matching $PYVER detected"
if test -z "$_ISPY" -o -n "$_PYOK"; then
echo "... INSTALLING $PKG"
conda install -y "$PKG" || _BUILDS=""
fi
fi
if test -z "$_BUILDS"; then
echo "WARNING: $PKG is not available"
fi
done
# TODO: This is a hack to stop test_qt.py from running until we
# can better troubleshoot why it fails on GHA
Expand Down
51 changes: 35 additions & 16 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
steps:
- name: Checkout Pyomo source
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Black Formatting Check
run: |
pip install black
Expand All @@ -56,7 +60,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [3.7, 3.8, 3.9, '3.10', '3.11']
python: [ 3.8, 3.9, '3.10', '3.11' ]
other: [""]
category: [""]

Expand All @@ -83,7 +87,7 @@ jobs:
PACKAGES:

- os: ubuntu-latest
python: 3.8
python: 3.9
other: /mpi
mpi: 3
skip_doctest: 1
Expand Down Expand Up @@ -116,15 +120,15 @@ jobs:
PYENV: pip

- os: ubuntu-latest
python: 3.7
python: 3.8
other: /slim
slim: 1
skip_doctest: 1
TARGET: linux
PYENV: pip

- os: ubuntu-latest
python: 3.8
python: 3.9
other: /pyutilib
TARGET: linux
PYENV: pip
Expand Down Expand Up @@ -346,19 +350,34 @@ jobs:
echo "*** Install Pyomo dependencies ***"
conda install --update-deps -q -y $CONDA_DEPENDENCIES
if test -z "${{matrix.slim}}"; then
echo "*** Install CPLEX ***"
conda install -q -y 'cplex>=12.10' docplex \
|| echo "WARNING: CPLEX Community Edition is not available"
echo "*** Install Gurobi ***"
conda install -q -y gurobi \
|| echo "WARNING: Gurobi is not available"
echo "*** Install Xpress ***"
conda install -q -y xpress \
|| echo "WARNING: Xpress Community Edition is not available"
for PKG in cyipopt pymumps scip; do
PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g')
echo "Installing for $PYVER"
for PKG in 'cplex>=12.10' docplex gurobi xpress cyipopt pymumps scip; do
echo ""
echo "*** Install $PKG ***"
conda install -q -y $PKG \
|| echo "WARNING: $PKG is not available"
# conda can literally take an hour to determine that a
# package is not available. Perform a quick search to see
# if the package is available for this interpreter before
# attempting an install.
# NOTE: conda search will attempt approximate matches.
_PKGLIST=$(conda search -f "$PKG") || echo "Package $PKG not found"
echo "$_PKGLIST"
_BASE=$(echo "$PKG" | sed 's/[=<>].*//')
_BUILDS=$(echo "$_PKGLIST" | grep "^$_BASE " \
| sed -r 's/\s+/ /g' | cut -d\ -f3) || echo ""
if test -n "$_BUILDS"; then
_ISPY=$(echo "$_BUILDS" | grep "^py") \
|| echo "No python build detected"
_PYOK=$(echo "$_BUILDS" | grep "^$PYVER") \
|| echo "No python build matching $PYVER detected"
if test -z "$_ISPY" -o -n "$_PYOK"; then
echo "... INSTALLING $PKG"
conda install -y "$PKG" || _BUILDS=""
fi
fi
if test -z "$_BUILDS"; then
echo "WARNING: $PKG is not available"
fi
done
# TODO: This is a hack to stop test_qt.py from running until we
# can better troubleshoot why it fails on GHA
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Pyomo is available under the BSD License - see the

Pyomo is currently tested with the following Python implementations:

* CPython: 3.7, 3.8, 3.9, 3.10, 3.11
* PyPy: 3.7, 3.8, 3.9
* CPython: 3.8, 3.9, 3.10, 3.11
* PyPy: 3.9

_Testing and support policy_:

Expand Down
2 changes: 1 addition & 1 deletion doc/OnlineDocs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Installation

Pyomo currently supports the following versions of Python:

* CPython: 3.7, 3.8, 3.9, 3.10, 3.11
* CPython: 3.8, 3.9, 3.10, 3.11
* PyPy: 3

At the time of the first Pyomo release after the end-of-life of a minor Python
Expand Down
14 changes: 4 additions & 10 deletions pyomo/common/backports.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

from pyomo.common.deprecation import relocated_module_attribute

# backport of contextlib.nullcontext for supporting Python < 3.7
class nullcontext(object):
def __init__(self, enter_result=None):
self.result = enter_result

def __enter__(self):
return self.result

def __exit__(self, et, ev, tb):
return
relocated_module_attribute(
'nullcontext', 'contextlib.nullcontext', version='6.7.0.dev0'
)
11 changes: 1 addition & 10 deletions pyomo/common/plugin_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,12 @@
# the U.S. Government retains certain rights in this software.
# ___________________________________________________________________________

import collections
import inspect
import sys
from weakref import ref as weakref_ref

from pyomo.common.errors import PyomoException
from pyomo.common.deprecation import deprecated, deprecation_warning

if sys.version_info[:2] >= (3, 7):
_deterministic_dict = dict
else:
from pyomo.common.collections import OrderedDict

_deterministic_dict = OrderedDict


class PluginGlobals(object):
@staticmethod
Expand Down Expand Up @@ -206,7 +197,7 @@ def __new__(cls, name, bases, classdict, *args, **kwargs):

# Register the new class with the interfaces
for interface, inherit, service in implements:
interface._plugins[new_class] = _deterministic_dict()
interface._plugins[new_class] = {}
interface._aliases.update({name: (new_class, doc) for name, doc in aliases})

if _singleton:
Expand Down
9 changes: 1 addition & 8 deletions pyomo/common/tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#
"""Testing for deprecated function."""
import sys
import types
import weakref

import pyomo.common.unittest as unittest

Expand Down Expand Up @@ -368,10 +366,6 @@ def test_relocated_class(self):

from pyomo.common.tests import relocated

if sys.version_info < (3, 5):
# Make sure that the module is only wrapped once
self.assertIs(type(relocated._wrapped_module), types.ModuleType)

self.assertNotIn('Foo', dir(relocated))
self.assertNotIn('Foo_2', dir(relocated))

Expand Down Expand Up @@ -414,8 +408,7 @@ def test_relocated_class(self):
"(?:'module' object) has no attribute 'Baz'",
):
relocated.Baz.data
if sys.version_info[:2] >= (3, 7):
self.assertEqual(relocated.Foo_3, '_3')
self.assertEqual(relocated.Foo_3, '_3')

with self.assertRaisesRegex(
AttributeError,
Expand Down
10 changes: 0 additions & 10 deletions pyomo/common/tests/test_fileutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,6 @@ def test_findfile(self):
os.path.join(subdir, subdir_name),
)

# TODO: Remove this when Python 3.7 is no longer supported
@unittest.skipIf(
sys.version_info[:2] < (3, 8)
and (
platform.mac_ver()[0].startswith('10.16')
or platform.mac_ver()[0].startswith('12.6')
or platform.mac_ver()[0].startswith('12.7')
),
"find_library has known bugs in Big Sur/Monterey for Python<3.8",
)
def test_find_library_system(self):
# Find a system library (before we muck with the PATH)
_args = {'cwd': False, 'include_PATH': False, 'pathlist': []}
Expand Down
5 changes: 3 additions & 2 deletions pyomo/contrib/incidence_analysis/incidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
# ___________________________________________________________________________
"""Functionality for identifying variables that participate in expressions
"""
import enum

from contextlib import nullcontext

from pyomo.core.expr.visitor import identify_variables
from pyomo.core.expr.numvalue import value as pyo_value
from pyomo.repn import generate_standard_repn
from pyomo.common.backports import nullcontext
from pyomo.util.subsystems import TemporarySubsystemManager
from pyomo.contrib.incidence_analysis.config import IncidenceMethod, IncidenceConfig

Expand Down
4 changes: 0 additions & 4 deletions pyomo/core/base/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@

logger = logging.getLogger('pyomo.core')

_prePython37 = sys.version_info[:2] < (3, 7)

_inf = float('inf')

FLATTEN_CROSS_PRODUCT = True
Expand Down Expand Up @@ -1950,8 +1948,6 @@ class SortedOrder(object):

_ValidOrderedAuguments = {True, False, InsertionOrder, SortedOrder}
_UnorderedInitializers = {set}
if _prePython37:
_UnorderedInitializers.add(dict)

def __new__(cls, *args, **kwds):
if cls is not Set:
Expand Down
2 changes: 1 addition & 1 deletion pyomo/core/expr/expr_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# ___________________________________________________________________________

import enum
from contextlib import nullcontext

from pyomo.common.backports import nullcontext
from pyomo.common.deprecation import deprecated

TO_STRING_VERBOSE = False
Expand Down
3 changes: 1 addition & 2 deletions pyomo/core/expr/template_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

import copy
import itertools
import logging
import sys
import builtins
from contextlib import nullcontext

from pyomo.common.backports import nullcontext
from pyomo.common.errors import TemplateExpressionError
from pyomo.core.expr.base import ExpressionBase, ExpressionArgs_Mixin, NPV_Mixin
from pyomo.core.expr.logical_expr import BooleanExpression
Expand Down
3 changes: 0 additions & 3 deletions pyomo/environ/tests/test_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ def test_not_auto_imported(self):
"pyomo.environ and it should not."
)

@unittest.skipIf(
sys.version_info[:2] < (3, 7), "Import timing introduced in python 3.7"
)
@unittest.skipIf(
'pypy_version_info' in dir(sys), "PyPy does not support '-X importtime"
)
Expand Down
Loading

0 comments on commit bee3177

Please sign in to comment.