Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve testing in Python 3.12 (manage pyutilib, distutils dependencies) #3065

Merged
merged 9 commits into from
Dec 8, 2023

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Dec 7, 2023

Fixes # .

Summary/Motivation:

This resolves an error first observed in Python 3.12 where PyUtilib installs but no longer imports cleanly (due to an import imp). This was causing an issue in Pyomo where the TempfileManager logic thought that PyUtilib was not available, but the tests found it to be present. This PR updates all checks for PyUtilib to go through pyomo.common.dependencies, so that everyone uses the same "truth" value for PyUtilib's availability.

As part of this rework, the new structure removes the pyutilib import from the module scope. As a result, PyUtilib is no longer imported as part of pyomo.environ. This (slightly) speeds up import pyomo.environ (~5%), and the PR removes pyutilib from the expected list of TPLs in the environment after the pyomo.environ import.

Changes proposed in this PR:

  • Rework pyomo.common.tempfiles to use pyomo.common.dependencies to check for PyUtilib
  • Remove import of pyutilib from pyomo.common.tempfiles module scope
  • Remove pyutilib from the list of expected TPLs importedby pyomo.environ

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@jsiirola jsiirola requested a review from mrmundt December 7, 2023 16:59
@jsiirola jsiirola changed the title Improve management of PyUtilib dependency Resolve testing in Python 3.12 (manage pyutilib, distutils dependencies) Dec 7, 2023
Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (de96bef) 88.09% compared to head (e3df7bd) 88.10%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3065      +/-   ##
==========================================
+ Coverage   88.09%   88.10%   +0.01%     
==========================================
  Files         774      774              
  Lines       91536    91537       +1     
==========================================
+ Hits        80635    80648      +13     
+ Misses      10901    10889      -12     
Flag Coverage Δ
linux 85.45% <100.00%> (+<0.01%) ⬆️
osx 75.47% <78.26%> (+0.03%) ⬆️
other 85.63% <100.00%> (+<0.01%) ⬆️
win 82.81% <65.21%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jsiirola jsiirola merged commit 3449d04 into Pyomo:main Dec 8, 2023
30 checks passed
@jsiirola jsiirola deleted the manage-pyutilib-imports branch December 8, 2023 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants