Skip to content

BUG: import_optional_dependency doesn't check version for submodules #38888

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

Closed
arw2019 opened this issue Jan 1, 2021 · 1 comment · Fixed by #38925
Closed

BUG: import_optional_dependency doesn't check version for submodules #38888

arw2019 opened this issue Jan 1, 2021 · 1 comment · Fixed by #38925
Assignees
Labels
Bug Dependencies Required and optional dependencies
Milestone

Comments

@arw2019
Copy link
Member

arw2019 commented Jan 1, 2021

xref #38370 (comment)

We'd like import_optional_dependency to correctly handle submodule imports AND to be able to import a specified minimum version of the dependency (for when a particular feature requires higher than global minimum version).

cc @lithomas1

Expected Output

In [14]: import pandas as pd
    ...: from pandas.compat._optional import import_optional_dependency
    ...: import_optional_dependency("pyarrow.csv", min_version="3.0")
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-14-7cfc85634756> in <module>
      1 import pandas as pd
      2 from pandas.compat._optional import import_optional_dependency
----> 3 import_optional_dependency("pyarrow.csv", min_version="3.0")

~/repos/pandas/pandas/compat/_optional.py in import_optional_dependency(name, extra, raise_on_missing, on_version, min_version)

ImportError: Pandas requires version '3.0' or newer of 'pyarrow.csv' (version '2.0.0' currently installed).
In [16]: import_optional_dependency("pyarrow.csv", min_version="3.0", on_version="warn")
/Users/andrewwieteska/repos/pandas/pandas/compat/_optional.py:137: UserWarning: Pandas requires version '3.0' or newer of 'pyarrow.csv' (version '2.0.0' currently installed).
@arw2019 arw2019 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 1, 2021
@arw2019 arw2019 added the Dependencies Required and optional dependencies label Jan 1, 2021
@lithomas1
Copy link
Member

take

@arw2019 arw2019 removed the Needs Triage Issue that has not been reviewed by a pandas team member label Jan 2, 2021
@jreback jreback added this to the 1.3 milestone Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dependencies Required and optional dependencies
Projects
None yet
3 participants