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

Disable import of pkg_resources for Python 3.3+ #11

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Disable import of pkg_resources for Python 3.3+ #11

wants to merge 6 commits into from

Conversation

fireph
Copy link

@fireph fireph commented Apr 23, 2018

I created a new pull request because of issues with my first fork.


__import__("pkg_resources").declare_namespace(__name__)

is deprecated in Python 3.3+ and causes issues with pyinstaller (mainly having to import the entire pkg_resources package, which is quite large). So checking the version number and not doing the import for these versions is likely the best solution to keep Python 2.x compatibility.

I have tested this in Python 3.6.5 and everything works as expected with this patch.

@@ -1 +1,3 @@
__import__("pkg_resources").declare_namespace(__name__)
import sys
if sys.hexversion < 0x30300f0:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use sys.version here? https://stackoverflow.com/questions/1093322/

My main concern here is that this doesn't look very good ;)

@fireph
Copy link
Author

fireph commented May 12, 2018

updated to use sys.version_info, which is quite a bit more readable :)

@wiggin15
Copy link
Contributor

wiggin15 commented Oct 5, 2020

Since Python <=3.3 isn't supported any more, I suggest removing the "declare_namespace" code altogether, then we can merge this ;)

Sailboat265 added a commit to Sailboat265/infi.systray that referenced this pull request Oct 20, 2023
@C0rn3j
Copy link

C0rn3j commented Dec 21, 2024

@wiggin15 do you have perms in this repo? I see it's been inactive for 5 years with lots of hanging PRs.

@wiggin15
Copy link
Contributor

Hi @C0rn3j . I'm afraid I don't have access any more as I no longer work for the company that manages this repo (Infinidat).
Unless someone from that company takes this up, consider this repo deprecated.

@C0rn3j
Copy link

C0rn3j commented Dec 22, 2024

Oh well.

https://github.com/C0rn3j/lynxtray

https://pypi.org/project/lynxtray/

There's also https://github.com/moses-palmer/pystray which is cross-platform, but similarly dead, and it was faster for me to port the one we were using.

@SuperZombi
Copy link

Why haven't you merged the changes and updated the package on Pypi yet? It's 2025 and I'm still having this problem. Python 3.3 is no longer relevant. Just remove this line

__import__("pkg_resources").declare_namespace(__name__)

@wiggin15
Copy link
Contributor

Hi. I used my priviledges on PyPI to upload a hotfix removing these 2 lines. I don't have a Windows machine to try it on, so please help me verify the fix.
I will not be maintaining this project further, as it is still under the ownership of Infinidat.

@SuperZombi
Copy link

SuperZombi commented Jan 11, 2025

import("pkg_resources").declare_namespace(name)

I remove this line in __init__.py and its works fine on my Windows 11 with Python 3.11.6. And also works with pyinstaller

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.

4 participants