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

Update __init__.py #806

wants to merge 1 commit into from

Conversation

Rydo111
Copy link

@Rydo111 Rydo111 commented Jun 29, 2024

Updated init to remove reference to pkg_resources, which is now deprecated.

Updated init to remove reference to pkg_resources, which is now deprecated.
@twopirllc
Copy link
Owner

Hello @Rydo111,

I am aware of this. Good to see an alternative fix 😎 other than just installing setuptools as a simple fix.

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,
KJ

Comment on lines 5 to +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
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)

@joaoe
Copy link

joaoe commented Dec 4, 2024

I see this is fixed in the development branch. Cheers.

@twopirllc
Copy link
Owner

@Rydo111

Interesting… 🤔 I haven’t modified the development version yet.

It’s been awhile since I looked at this. Jog my memory, will this take of the issue of needing to install setuptools?

KJ

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

Successfully merging this pull request may close these issues.

3 participants