Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass env vars through in ./pants run for python (#4606)
### Problem As explained in #4590, environment variables are not passed to the pex-invoked subprocess during `./pants run` in the python backend. That is a behaviour change from `python_old`. ### Solution Copy and propagate the environment into `pex.run`. ### Result Environment variables are passed through to the subprocess during `./pants run`. Fixes #4590.
- Loading branch information
Stu Hood
committed
May 18, 2017
1 parent
a49a1b2
commit 78be2f6
Showing
4 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
python_binary( | ||
entry_point = 'print_env.main', | ||
source = 'main.py', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# coding=utf-8 | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
import os | ||
import sys | ||
|
||
|
||
if __name__ == '__main__': | ||
# Print the content of the env var given on the command line. | ||
print(os.environ[sys.argv[1]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters