-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Update __init__.py #806
base: main
Are you sure you want to change the base?
Update __init__.py #806
Conversation
Updated init to remove reference to pkg_resources, which is now deprecated.
Hello @Rydo111, I am aware of this. Good to see an alternative fix 😎 other than just installing Also all fixes etc are being done the development branch. If you could do that, that would be great. Otherwise I will make the appropriate changes when I get a chance. Kind Regards, |
from importlib.util import find_spec | ||
from pathlib import Path | ||
from pkg_resources import get_distribution, DistributionNotFound | ||
# from pkg_resources import get_distribution, DistributionNotFound | ||
from importlib.metadata import version, distribution, metadata, PackageNotFoundError | ||
|
||
|
||
_dist = get_distribution("pandas_ta") | ||
# _dist = get_distribution("pandas_ta") | ||
try: | ||
# Normalize case for Windows systems | ||
here = Path(_dist.location) / __file__ | ||
__version__ = version("pandas_ta") | ||
dist = distribution('pandas_ta') | ||
package_location = Path(dist.locate_file('pandas_ta')) | ||
package_metadata = metadata('pandas_ta') | ||
|
||
here = package_location / Path(__file__).name | ||
if not here.exists(): | ||
# not installed, but there is another version that *is* | ||
raise DistributionNotFound | ||
except DistributionNotFound: | ||
raise PackageNotFoundError("File not found in package location") | ||
# except DistributionNotFound: | ||
# __version__ = "Please install this project with setup.py" | ||
except PackageNotFoundError: | ||
__version__ = "Please install this project with setup.py" | ||
|
||
version = __version__ = _dist.version | ||
version = __version__ # = _dist.version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from importlib.util import find_spec | |
from pathlib import Path | |
from pkg_resources import get_distribution, DistributionNotFound | |
# from pkg_resources import get_distribution, DistributionNotFound | |
from importlib.metadata import version, distribution, metadata, PackageNotFoundError | |
_dist = get_distribution("pandas_ta") | |
# _dist = get_distribution("pandas_ta") | |
try: | |
# Normalize case for Windows systems | |
here = Path(_dist.location) / __file__ | |
__version__ = version("pandas_ta") | |
dist = distribution('pandas_ta') | |
package_location = Path(dist.locate_file('pandas_ta')) | |
package_metadata = metadata('pandas_ta') | |
here = package_location / Path(__file__).name | |
if not here.exists(): | |
# not installed, but there is another version that *is* | |
raise DistributionNotFound | |
except DistributionNotFound: | |
raise PackageNotFoundError("File not found in package location") | |
# except DistributionNotFound: | |
# __version__ = "Please install this project with setup.py" | |
except PackageNotFoundError: | |
__version__ = "Please install this project with setup.py" | |
version = __version__ = _dist.version | |
version = __version__ # = _dist.version | |
import importlib.metadata | |
from importlib.util import find_spec | |
from pathlib import Path | |
version = __version__ = importlib.metadata.version(name) |
I see this is fixed in the development branch. Cheers. |
Updated init to remove reference to pkg_resources, which is now deprecated.