[go: nahoru, domu]

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

Circular import when importing cylp.cy and submodule(s) #189

Closed
brandon-avantus opened this issue Oct 31, 2023 · 6 comments
Closed

Circular import when importing cylp.cy and submodule(s) #189

brandon-avantus opened this issue Oct 31, 2023 · 6 comments

Comments

@brandon-avantus
Copy link

Description:
Importing cylp.cy or cylp.cy.CyClpSimplex produces an ImportError due to what appears to be a circular import.

Steps to reproduce:

Python 3.11.5 (main, Sep 2 2023, 14:16:33) [GCC 13.2.1 20230801] on linux
>>> import cylp.cy.CyClpSimplex  # or `import cylp.cy`
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "devel/test-cvxpy/venv/lib/python3.11/site-packages/cylp/cy/__init__.py", line 2, in <module>
    from .CyClpSimplex import CyClpSimplex
  File "cylp/cy/CyClpSimplex.pyx", line 1, in init cylp.cy.CyClpSimplex
  File "cylp/cy/CyClpPrimalColumnPivotBase.pyx", line 1, in init cylp.cy.CyClpPrimalColumnPivotBase
  File "cylp/cy/CyClpDualRowPivotBase.pyx", line 1, in init cylp.cy.CyClpDualRowPivotBase
  File "cylp/cy/CyOsiSolverInterface.pyx", line 1, in init cylp.cy.CyOsiSolverInterface
  File "cylp/cy/CyCbcModel.pyx", line 1, in init cylp.cy.CyCbcModel
  File "cylp/cy/CyOsiCuts.pyx", line 3, in init cylp.cy.CyOsiCuts
  File "devel/test-cvxpy/venv/lib/python3.11/site-packages/cylp/py/__init__.py", line 1, in <module>
    from . import pivots
  File "devel/test-cvxpy/venv/lib/python3.11/site-packages/cylp/py/pivots/__init__.py", line 3, in <module>
    from .PositiveEdgePivot import PositiveEdgePivot
  File "devel/test-cvxpy/venv/lib/python3.11/site-packages/cylp/py/pivots/PositiveEdgePivot.py", line 10, in <module>
    from cylp.cy.CyClpSimplex import cydot
ImportError: cannot import name 'cydot' from partially initialized module 'cylp.cy.CyClpSimplex' (most likely due to a circular import) (devel/test-cvxpy/venv/lib/python3.11/site-packages/cylp/cy/CyClpSimplex.cpython-311-x86_64-linux-gnu.so)

Environment:
OS: Manjaro Linux (rolling distribution)
Python: Python 3.11.5 (main, Sep 2 2023, 14:16:33) [GCC 13.2.1 20230801] on linux
cylp: 0.92.1 (binary install from wheel via pip)

@tkralphs
Copy link
Member
tkralphs commented Nov 1, 2023

I can replicate this on both Linux and Windows. I'm a bit mystified, since there wasn't much of a change from 0.91 to 0.92 and I did some testing before making the release. I can replicate this failure now with 615a193, which is just the first commit after the release 0.91.6 (#179). Will need to investigate further. Cc'ing @mkoeppe.

tkralphs added a commit that referenced this issue Nov 1, 2023
@tkralphs tkralphs mentioned this issue Nov 1, 2023
@tkralphs
Copy link
Member
tkralphs commented Nov 1, 2023

The fix for this was apparently rather simple, but the part that I don't understand is why this was never an issue before. That circular import has been there for a long time, but the error only surfaced when switching to Cython 3. I also don't know why it didn't come up in any testing. If tests pass in #190, I should be able to push out a new release that will hopefully fix the issue shortly.

@tkralphs
Copy link
Member
tkralphs commented Nov 1, 2023

@brandon-avantus Can you test? You should be able to download wheels here.

@brandon-avantus
Copy link
Author

@tkralphs I can confirm that the new wheels solve the problem. I am able to import without the errors and all my tests are passing on my app. Thank you for the quick turnaround!

tkralphs added a commit that referenced this issue Nov 1, 2023
@brandon-avantus
Copy link
Author

@tkralphs One more request would be to have Windows wheels on PyPI for version 0.92.2. Thanks!

@tkralphs
Copy link
Member
tkralphs commented Nov 2, 2023

Yes, they'll be coming shortly.

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

No branches or pull requests

2 participants