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

Fix #684 #702

Closed
wants to merge 6 commits into from
Closed

Fix #684 #702

wants to merge 6 commits into from

Conversation

Caellion
Copy link

@Caellion Caellion commented Apr 25, 2023

Fixes #684

Attempts to fix using @nielsuit227's code

Note: This creates a dependency on importlib-metadata for Python 3.7

Also note: I am not sure how to update setup to conditionally depend on importlib-metadata, please advise

@Andrew-Chen-Wang
Copy link
Member

If possible, to avoid the dependency, can you use the old code when Python < 3.8 in your if else statement? Thank you

@Caellion
Copy link
Author

If possible, to avoid the dependency, can you use the old code when Python < 3.8 in your if else statement? Thank you

On python 3.7.11 it breaks with NameError: name 'DistributionNotFound' is not defined

I think I will have to keep dependency on importlib-metadata on python 3.7

Caellion and others added 2 commits July 10, 2023 11:11
else it breaks with `NameError: name 'DistributionNotFound' is not defined` on 3.7.11
@aqeelat
Copy link
Member

aqeelat commented Jul 24, 2023

why not hardcode the version in __init__.py and then change setup.py to read the version from it?

@grizmio
Copy link

grizmio commented Jul 27, 2023

what do you think about something like this ugly example:

import sys

if sys.version_info >= (3, 8):
    from importlib import metadata
    try:
        __version__ = metadata.version("djangorestframework_simplejwt")
    except metadata.PackageNotFoundError:
        # package is not installed
        __version__ = None
else:
    from pkg_resources import DistributionNotFound, get_distribution

    try:
        __version__ = get_distribution("djangorestframework_simplejwt").version
    except DistributionNotFound:
        # package is not installed
        __version__ = None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reference to pkg_resources
4 participants