scripts/python subdirectory of the current GTlab project is now automatically added to sys.path by marvinoe21 · Pull Request #619 · dlr-gtlab/python-module · GitHub
Skip to content

scripts/python subdirectory of the current GTlab project is now automatically added to sys.path#619

Merged
marvinoe21 merged 4 commits into
masterfrom
618-automatically-add-the-python_modules-subdirectory-of-the-current-project-to-syspath
Jul 11, 2025
Merged

scripts/python subdirectory of the current GTlab project is now automatically added to sys.path#619
marvinoe21 merged 4 commits into
masterfrom
618-automatically-add-the-python_modules-subdirectory-of-the-current-project-to-syspath

Conversation

@marvinoe21

@marvinoe21 marvinoe21 commented Jul 10, 2025

Copy link
Copy Markdown
Collaborator

This change automatically adds the scripts/python directory (relative to the GTlab project directory) to sys.path.
Python modules placed in this directory can be imported via the embedded Python interpreter in GTlab.

What has been changed:

  • Connected GtCoreApplication::currentProjectChanged() with GtpyContextManager::onProjectChanged().
    When the GTlab project changes, GtpyContextManager::onProjectChanged() removes the previous scripts/python path from sys.path and adds the new one.
  • Moved the functionality for adding paths to sys.path from GtpyContextManager to the gtpy::utils namespace.
    This helps to reduce the responsibilities of GtpyContextManager.

@marvinoe21 marvinoe21 changed the title automatically add python_modules subdir to sys.path python_modules subdirectory of the current GTlab project is now automatically added to sys.path Jul 10, 2025
@rainman110

Copy link
Copy Markdown
Contributor

@marvinoe21

Copy link
Copy Markdown
Collaborator Author

The core idea is to provide a project-specific location where Python modules (*.py files) can be stored. It acts like a project-specific script collection. From user perspective, this simplifies sharing Python modules as part of a project and avoids the need to manually modify sys.path. If the python_modules subdirectory does not exist in the project directory, it has no side effects.

@marvinoe21 marvinoe21 changed the title python_modules subdirectory of the current GTlab project is now automatically added to sys.path scripts/python subdirectory of the current GTlab project is now automatically added to sys.path Jul 11, 2025
@marvinoe21 marvinoe21 requested a review from rainman110 July 11, 2025 08:50
@marvinoe21

Copy link
Copy Markdown
Collaborator Author

@marvinoe21 marvinoe21 merged commit e5c5525 into master Jul 11, 2025
1 check passed
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.

Automatically add the python_modules subdirectory of the current project to sys.path

2 participants