sudospawner
sudospawner copied to clipboard
Add env param to Subprocess call
I noticed an issue wherein the c.Spawner.environment setting in the JupyterHub config was not being used when spawning the new process. It seems to be so because we are not passing the env to the Subprocess function.
I hope this request can be merged soon and a new release could be created shortly thereafter.
Checking back in on this, cc @minrk
Hi, thanks for the PR! I think this is not the right fix. env in the subprocess command sets the environment for the mediator process, which is not the notebook server process that Spawner.environment should set. This is relayed via passing the args and env fields through the mediator. This is passed to the mediator here and from the mediator to the real process here. I opened #53 to enable some testing, which should include verification that Spawner.environment is indeed passed on to the notebook process.
How are you setting the environment and what are you seeing as a result?
I am setting up the PYTHONPATH in the JupyterHub config under c.Spawner.environment. I have listed the config items related to SudoSpawner below:
c.JupyterHub.spawner_class = 'sudospawner.SudoSpawner'
c.SudoSpawner.sudospawner_path = '/path/to/script'
c.Spawner.environment = {
'PYTHONPATH': '/some/path/'
}
However, I find that it is not set in the notebook env on the spawned server.
Checking back in on this, cc @minrk
@minrk are there any updates on the testing process?
6 years late is better than never :)
@ssatia the behavior you are seeing is because PYTHONPATH is intentionally not allowed to be set this way - see https://github.com/jupyterhub/sudospawner/blob/adc6298ddf2329bf50161178c91c87c54c637568/sudospawner/mediator.py#L90.
With that, I'm going to close this PR.