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

Update __init__.py #806

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions pandas_ta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@
"""
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
Comment on lines 5 to +27
Copy link

Choose a reason for hiding this comment

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

Suggested change
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)


Imports = {
"alphaVantage-api": find_spec("alphaVantageAPI") is not None,
Expand Down