Skip to content

Fix tgcf-web command compatibility with Python 3.12#636

Open
ghostnetrn wants to merge 1 commit into
aahnik:mainfrom
ghostnetrn:main
Open

Fix tgcf-web command compatibility with Python 3.12#636
ghostnetrn wants to merge 1 commit into
aahnik:mainfrom
ghostnetrn:main

Conversation

@ghostnetrn

Copy link
Copy Markdown

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

1 participant