launchdarkly / python-server-sdk

LaunchDarkly Server-side SDK for Python
https://docs.launchdarkly.com/sdk/server-side/python
Other
38 stars 45 forks source link

ImportError: cannot import name 'VersionInfo' #173

Closed anirudhdpai closed 2 years ago

anirudhdpai commented 2 years ago

Is this a support request? This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here or by emailing support@launchdarkly.com.

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Describe the bug Importing VersionInfo in the operators.py file gives out an import error since semver has deprecated VersionInfo and replaced it by Version

To reproduce Run operators.py file from launchdarkly repo.

Expected behavior Importing VersionInfo must be successful from launchdarkly

Logs

    from .client import *
  File "/usr/local/lib/python3.6/dist-packages/ldclient/client.py", line 18, in <module>
    from ldclient.flag import EvaluationDetail, evaluate, error_reason
  File "/usr/local/lib/python3.6/dist-packages/ldclient/flag.py", line 12, in <module>
    from ldclient import operators
  File "/usr/local/lib/python3.6/dist-packages/ldclient/operators.py", line 8, in <module>
    from semver import VersionInfo
ImportError: cannot import name 'VersionInfo'

SDK version Latest version

Language version, developer tools Python 3.6.9 and 3.6.15

OS/platform Ubuntu 18.04 and 20.04

Additional context https://readthedocs.org/projects/python-semver/downloads/pdf/latest/

eli-darkly commented 2 years ago

It's unclear to me how this could be happening. It looks like perhaps you have installed the prerelease 3.0.0-dev.2 or 3.0.0-dev.3 version of semver— the docs you linked to are for 3.0.0-dev.3. But the SDK's dependency on semver specifically requires that the version be less than 3.0.0. You'll see in our requirements.txt:

semver>=2.10.2,<3.0.0
eli-darkly commented 2 years ago

I'll add that "Run operators.py file from launchdarkly repo" is not really a usable instruction for reproducing the issue. Any given source file like operators.py does not get run by itself in isolation; import errors like you're seeing are dependent on the state of the overall Python environment, i.e. what packages have been installed. We do have unit tests in the repository that exercise all of the code in the SDK, including operators.py, and they are working fine; but they rely on having correctly installed the dependencies that are configured in our requirements.txt. That should happen for you automatically if you're using the LaunchDarkly SDK in an application, but I don't know anything about what your project may be or how you have set up your dependencies or development environment.

anirudhdpai commented 2 years ago

Looks like this is happening due to the packages we've got in our requirements.txt.

Thanks a lot for the input, anirudhdpai