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

datadog 0.37.0 wheel import error for Python < 3.5 #571

Closed
jairideout opened this issue Jun 22, 2020 · 2 comments · Fixed by #572
Closed

datadog 0.37.0 wheel import error for Python < 3.5 #571

jairideout opened this issue Jun 22, 2020 · 2 comments · Fixed by #572
Labels
kind/bug Bug related issue

Comments

@jairideout
Copy link
Contributor

Describe the bug
After installing the latest datadog 0.37.0 wheel release using a Python version < 3.5, a typing package import error is raised when importing datadog.

To Reproduce
Steps to reproduce the behavior:

  1. Install a version of Python < 3.5 (for example, Python 3.4 or Python 2.7).
  2. Install the wheel release of datadog 0.37.0 by running pip install datadog.
  3. Try importing datadog in an interactive interpreter to see the import error:
>>> import datadog
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "datadog/__init__.py", line 17, in <module>
    from typing import Any, List, Optional
ImportError: No module named typing

Expected behavior
The typing package should be included in the wheel's install requirements if Python < 3.5 is being used.

In setup.py, the typing package is added to install_requires if running a Python version < 3.5 (otherwise, the package is already included in the standard library for newer Python versions). This optional typing dependency is correctly installed when running python setup.py install or pip-installing from source. The wheel release that is installed via pip install datadog doesn't include the typing dependency (probably because the wheel release isn't Python version specific).

A couple of solutions come to mind:

  • (Probably easiest) Always include the typing package in install_requires, regardless of Python version. According to the typing package docs, if typing is already part of the standard library, installing the package has no effect.
  • Create separate wheel releases for Python < 3.5 and Python >= 3.5.

Environment and Versions:
Version: datadog 0.37.0
Tested with Python 2.7.15 on macOS 10.15.5.

Additional context
The typing package import was added in PR #565. Thanks @justinsousa for pointing out this issue!

@jairideout
Copy link
Contributor Author

After installing the typing package on Python 2.7, I'm now seeing an import error from configparser in datadog.util.compat. The unit and integration tests install tox before running, which was implicitly installing configparser as one of its dependencies. I'll submit a PR shortly to explicitly include typing and configparser as dependencies (regardless of Python version).

For users running into typing or configparser import errors with datadog 0.37.0, installing the packages should fix the issue:

pip install typing configparser

jairideout added a commit to jairideout/datadogpy that referenced this issue Jun 22, 2020
…ython version.

Fixes import errors when using `datadog` wheel build with Python versions older than 3.5.

Fixes DataDog#571
@sfdye
Copy link

sfdye commented Jun 23, 2020

Our projects started failing due to configparser.

What about using the future library:
https://python-future.org/compatible_idioms.html#configparser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bug related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants