-
Notifications
You must be signed in to change notification settings - Fork 66
setuptools removed from python 3.12 #664
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
Comments
Merged
Update: I tried in Linux with a fresh python 3.12 environment, same error
|
This was referenced Jan 21, 2025
Merged
BishopWolf
added a commit
to BishopWolf/GateTools
that referenced
this issue
Jan 22, 2025
solving OpenGATE/opengate#664 from discussion in OpenGATE/opengate#672
This issue is solved |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The package setuptools is deprecated and removed from python 3.12. Some distribution may still add it for compatibility, but in general it is gone for good. The user is expected to use importlib instead.
This causes errors in the current CI for MacOS with python 3.12. Mac users with python 3.12 should be reporting this issue too.
Solution, switch to importlib
Switching from pkg_resources to importlib.resources in Python can help streamline your code and improve performance. Here’s how you can make the transition:
Using pkg_resources
import pkg_resources
Example of reading a resource file
resource_content = pkg_resources.resource_string('your_package', 'data/resource.txt')
print(resource_content.decode('utf-8'))
Switching to importlib.resources
For Python 3.7 and later, you can use importlib.resources:
import importlib.resources
Example of reading a resource file
Explanation
Importing the Module:
pkg_resources is replaced by importlib.resources.
Accessing the Resource:
pkg_resources.resource_string is replaced by importlib.resources.open_text.
Reading the Resource:
Use a context manager (with statement) to open and read the resource file.
Benefits of importlib.resources
Performance: importlib.resources is generally faster and more efficient.
Simplicity: The API is simpler and more intuitive.
Standard Library: It’s part of the standard library, so no additional dependencies are required.
By making this switch, your code will be more modern and maintainable. If you have any specific questions or need further assistance, feel free to ask!
Generated with GitHub Copilot
The text was updated successfully, but these errors were encountered: