Skip to content

TST/DOC: Test for and document incompatibility with openpyxl 2.0.0 and later #7214

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

Merged
merged 1 commit into from
May 24, 2014
Merged

TST/DOC: Test for and document incompatibility with openpyxl 2.0.0 and later #7214

merged 1 commit into from
May 24, 2014

Conversation

neirbowj
Copy link
Contributor

Let users down easy if v0.14.0 remains incompatible with openpyxl 2.0.0 and later

closes #7169 .

ver = _versiontuple(openpyxl.__version__)
if ver < _versiontuple(start_ver) or _versiontuple(stop_ver) <= ver:
return False

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use LooseVersion for this much easier

look in pandas/init for how to use it

@neirbowj
Copy link
Contributor Author

I read that LooseVersion was to be deprecated by PEP-386, but I guess that hasn't happened yet.

@jreback jreback added this to the 0.14.0 milestone May 23, 2014
@jreback
Copy link
Contributor

jreback commented May 23, 2014

@jorisvandenbossche @cpcloud ?

@jreback
Copy link
Contributor

jreback commented May 23, 2014

@neirbowj pls squash down to 1 commit

@jreback
Copy link
Contributor

jreback commented May 23, 2014

@neirbowj

this is failing the 3.4 build (which has 2.03 of openpyxl).

https://travis-ci.org/pydata/pandas/jobs/25839724

I think you might need to leave openpyxl in the engine map by just have its value of None

then you can skip tests when the writer is None

something like that

@neirbowj
Copy link
Contributor Author

@jreback So "Allowed Failures" aren't really? ;-)

The problem is not the writer registration, it looks like it's the version detection. I suspect that the too-old lxml is interfering. For some reason, pandas.compat.openpyxl_compat.is_compat() thinks that '2.0.3' is an incompatible version. I'll investigate.

@jreback
Copy link
Contributor

jreback commented May 23, 2014

they are just so the testing doesn't take too long

they r testing 3.4 and numpy 1.9

the 3.4 tests current versions of a lot of the deps (all the other deps are fixed)

so shouldn't fail

@neirbowj
Copy link
Contributor Author

So... lxml has nothing to do with it. I proposed I would write a test that fails when an incompatible version of openpyxl is installed and I succeeded in doing so. If the tests as configured need to pass under 3.4, then that was the wrong spec. I should back out that test, and update pandas.io.tests.test_excel._skip_if_no_openpyxl to treat an incompatible version as "no openpyxl."

@jreback
Copy link
Contributor

jreback commented May 24, 2014

ok this all looks fine

should the warning be a UserWaarning?

pls squash to a single commit and can merge this

also pls open an issue for the actual modifications needed to support > 2.0
which can be worked on for 0.14.1

@jreback
Copy link
Contributor

jreback commented May 24, 2014

maybe an ImportWarning ?

@neirbowj
Copy link
Contributor Author

openpyxl.xml itself uses the default (UserWarning) when it encounters the too-old lxml. I'm thinking we should follow that example.

def lxml_available():
    try:
        from lxml.etree import LXML_VERSION
        LXML = LXML_VERSION >= (3, 3, 1, 0)
        if not LXML:
            import warnings
            warnings.warn("The installed version of lxml is too old to be used with openpyxl")
            return False  # we have it, but too old
        else:
            return True  # we have it, and recent enough
    except ImportError:
        return False  # we don't even have it

@jreback
Copy link
Contributor

jreback commented May 24, 2014

ahh ok that's fine then

*   Detect whether a compatible version is installed
*   Skip openpyxl unit tests instead of failing
*   Inhibit registration of `openpyxl` engine in `ExcelWriter`
*   Raise `UserWarning`
*   Document limitation as a known issue
*   Resolve issue #7169
@jorisvandenbossche
Copy link
Member

looking good

jreback added a commit that referenced this pull request May 24, 2014
TST/DOC: Test for and document incompatibility with openpyxl 2.0.0 and later
@jreback jreback merged commit 418669d into pandas-dev:master May 24, 2014
@jreback
Copy link
Contributor

jreback commented May 24, 2014

@neirbowj thanks!

@jreback
Copy link
Contributor

jreback commented May 27, 2014

@neirbowj

This just failed, seems odd, right? https://travis-ci.org/jreback/pandas/jobs/25910838

@neirbowj
Copy link
Contributor Author

Yes, that does seem odd. I'm looking into it now.

@jreback
Copy link
Contributor

jreback commented May 27, 2014

I restarted the test and it DID recur

though it is NOT present in master atm; maybe had trouble installing the library....weird

@neirbowj
Copy link
Contributor Author

The commit in this PR is not an ancestor of your categorical branch. Those two branches diverged just before I committed the workaround. Rebase and you'll be in good shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions IO Excel read_excel, to_excel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

COMPAT: Break in openpyxl
4 participants