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

Support a virtual environment #212

Open
SwooshyCueb opened this issue Jul 18, 2024 · 4 comments
Open

Support a virtual environment #212

SwooshyCueb opened this issue Jul 18, 2024 · 4 comments

Comments

@SwooshyCueb
Copy link
Member

Supporting a virtual environment would allow the python plugin to use a different set of modules than are installed in the system's site-packages. This would allow iRODS to make use of newer or different versions of modules that would otherwise be provided by the distro repositories, without causing problems for the distro's package manager. We should implement optional support for python virtual environments. This will require some new configuration options for the plugin.

Prerequisite: #211

Relevant documentation:

@trel
Copy link
Member

trel commented Jul 18, 2024

can we do this with a compiled boost.python? great if true.

@SwooshyCueb
Copy link
Member Author

From what I can tell, yes. We just have to tweak how we hold it

@trel
Copy link
Member

trel commented Jul 18, 2024

then that is extremely valuable / powerful.

@SwooshyCueb
Copy link
Member Author

We have a few curveballs to contend with.

First, PyConfig isn't a thing prior to Python 3.8. EL8 is the only distro we support that has a version of Python old enough for this to matter. I haven't really started looking into a solution for this beyond simply disabling the interpreter configuration functionality if the Python version being built against is too old.

Second, there doesn't seem to be a way to manipulate the module search path list in the way we need without replacing it outright. This means that we need to populate the list with the default system module search paths before we add our own. For Python 3.8, 3.9, and 3.10, this is fairly straightforward, as we can call PyConfig_Read(), which will populate the PyConfig object with the default paths, minus any paths added by site. However, starting in 3.11, this functionality was removed from PyConfig_Read().

The documentation for PyConfig.module_search_paths_set states that Py_InitializeFromConfig() will populate module_search_paths, which may have been a solution to explore for 3.11+, but as far as I can tell, this isn't actually true. In my testing, both module_search_paths and module_search_paths_set are the same before and after a call to Py_InitializeFromConfig(). I've opened an issue about that at python/cpython#122963.

One solution might be to initialize the interpreter with a mostly-default configuration, slurp sys.path, and then use that to re-initialize the interpreter. However, this seems icky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants