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

Embedded interpreters: No way to extend sys.path #128352

Open
smurfix opened this issue Dec 30, 2024 · 1 comment
Open

Embedded interpreters: No way to extend sys.path #128352

smurfix opened this issue Dec 30, 2024 · 1 comment
Labels
topic-subinterpreters type-feature A feature request or enhancement

Comments

@smurfix
Copy link

smurfix commented Dec 30, 2024

Feature or enhancement

Proposal:

Setting up an embedded Python interpreter often involves augmenting sys.path with some application-specific subdirectories, so as not to pollute the system's normal Python installation.

Unfortunately, PyConfig only affords either replacing the default path wholesale, or leaving it as-is (via module_search_paths_set). There appears to be no way to augment sys.path with application-specific directories and no documented way to retrieve the default contents of sys.path.

A workable solution might be to enhance cfg.module_search_paths_set so that when it's set to 2 or 3, the application's paths shall be prepended / appended to sys.path instead of replacing it.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/embedding-how-do-i-extend-sys-path/75734

@ZeroIntensity
Copy link
Member

This looks like a duplicate of gh-126977, but I think we can leave that one open for tracking and use this for the actual implementation. But we should discuss what the best way to do this is (e.g. should we just have a PyConfig field for sys.path, or something more broad?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-subinterpreters type-feature A feature request or enhancement
Projects
Status: Todo
Development

No branches or pull requests

2 participants