This is an automated email from the ASF dual-hosted git repository.
nicknezis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
The following commit(s) were added to refs/heads/master by this push:
new c32c09a Fix `get_heron_dir` which is causing Python processes to fail
(#3731)
c32c09a is described below
commit c32c09a0f09caca74dbf5715aa0632f0a50356c9
Author: choi se <[email protected]>
AuthorDate: Sat Nov 13 04:45:50 2021 +0900
Fix `get_heron_dir` which is causing Python processes to fail (#3731)
---
heron/tools/common/src/python/utils/config.py | 7 +++----
tools/rules/pex/BUILD | 4 ++--
tools/rules/pex/pex_rules.bzl | 2 ++
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/heron/tools/common/src/python/utils/config.py
b/heron/tools/common/src/python/utils/config.py
index 9747021..dee4add 100644
--- a/heron/tools/common/src/python/utils/config.py
+++ b/heron/tools/common/src/python/utils/config.py
@@ -143,6 +143,9 @@ def get_classpath(jars):
return ':'.join(map(normalized_class_path, jars))
def _get_heron_dir():
+ pex_file = os.environ.get('PEX', None)
+ if pex_file is not None:
+ return
normalized_class_path(str(Path(pex_file).resolve(strict=True).parent.parent))
# assuming the tool runs from $HERON_ROOT/bin/<binary>
return
normalized_class_path(str(Path(sys.argv[0]).resolve(strict=True).parent.parent))
@@ -155,8 +158,6 @@ def get_heron_dir():
its real path is
'/Users/heron-user/.heron/bin/heron/tools/common/src/python/utils/config.pyc',
the internal variable ``path`` would be '/Users/heron-user/.heron', which is
the heron directory
- This means the variable `go_above_dirs` below is 9.
-
:return: root location of the .pex file
"""
return _get_heron_dir()
@@ -172,8 +173,6 @@ def get_zipped_heron_dir():
the internal variable ``path`` would be
'/Users/heron-user/.pex/code/xxxyyy/',
which is the root PEX directory
- This means the variable `go_above_dirs` below is 7.
-
:return: root location of the .pex file.
"""
return _get_heron_dir()
diff --git a/tools/rules/pex/BUILD b/tools/rules/pex/BUILD
index c5e5c02..58d3d3e 100644
--- a/tools/rules/pex/BUILD
+++ b/tools/rules/pex/BUILD
@@ -28,9 +28,9 @@ POST_EXECUTE = [
# Create the virtual environment
'python3 -m venv $$VENV --clear',
'VIRTUAL_ENV_DISABLE_PROMPT=1 source "$$VENV/bin/activate"',
-
+ 'TEMP="$(@D)/pexbuild"',
'pip install pex \
- --quiet --no-cache-dir --no-index --build $(@D)/pexbuild \
+ --quiet --no-cache-dir --no-index \
--find-links $$(dirname $(location @pex_src//file)) \
--find-links $$(dirname $(location @wheel_src//file)) \
--find-links $$(dirname $(location @setuptools_wheel//file))',
diff --git a/tools/rules/pex/pex_rules.bzl b/tools/rules/pex/pex_rules.bzl
index 5353b0f..d93fb60 100644
--- a/tools/rules/pex/pex_rules.bzl
+++ b/tools/rules/pex/pex_rules.bzl
@@ -197,6 +197,8 @@ def _pex_binary_impl(ctx):
"--disable-cache",
"--python-shebang", "#!/usr/bin/env python3",
"--no-compile",
+ "--include-tools",
+ "--layout", "zipapp",
"--resolver-version", "pip-2020-resolver",
"--manifest-file", manifest_file.path,
]