Skip to content

Fix tgcf-web command compatibility with Python 3.12 #636

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ghostnetrn
Copy link

Before Creating a pull request, please read the contributing guidelines thoroughly.

Below is a suggested pull request description in English:


Title:
Fix tgcf-web command compatibility with Python 3.12

Description:
This patch addresses an issue with the tgcf-web command when running on Python 3.12.

Problem:
The tgcf-web command previously used importlib.resources.path() with an empty string to obtain the package directory, which caused a StopIteration error in Python 3.12. Subsequent attempts to convert the returned object with os.fspath() or to use wu.__file__ failed because wu.__file__ returned None.

Implemented Solution:

  • The code has been modified to obtain the package directory based on the run.py file itself using the __file__ attribute.
  • The problematic line has been replaced with:
    package_dir = os.path.dirname(os.path.abspath(__file__))
    This ensures that the correct path is obtained without relying on APIs that behave differently in Python 3.12.

Testing:
After the change, the tgcf-web command executed successfully, launching the Streamlit server without any errors.


I have fully read and understood the terms and conditions laid down in the general Contributor License Agreement

  • I agree to distribute my code contributions under MIT License, and will not change it in the future.
  • I agree that any contribution once merged, cannot be taken back by me.
  • I will abide by the Code of Conduct
  • I understand that the decision of the maintainer is final and abiding. And the maintainer reserves all rights to modify my code. I also understand that the maintainer can remove my code in future, if he thinks so.
  • Once my contribution is merged, my name will permanently appear in the Contribtor's List of this repository.

@ghostnetrn ghostnetrn requested a review from aahnik as a code owner March 4, 2025 23:03
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.

1 participant