Skip to content

Commit 6cf8604

Browse files
authored
Include HOME in build environment (kivy#2582)
Many of the tools run by p4a store intermediate files in the user's home directory. Passing the HOME environment variable to the build environment has 2 positive effects: 1. To completely encapsulate the build, HOME can be set to an alternate directory than the user's actual home directory. Many tools such as p4a have options to override these paths, but that must be done on a case by case basis and it would require that p4a pass through these options or environment variables. 2. In containerized environments the user may not be registered in the accounts database. If the user's home directory can't be found from the HOME environment variable or the accounts database, many tools will fail. An example of this is python2.7 when run by `ndk-build`.
1 parent b379a1c commit 6cf8604

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pythonforandroid/archs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ def get_clang_exe(self, with_target=False, plus_plus=False):
109109
def get_env(self, with_flags_in_cc=True):
110110
env = {}
111111

112+
# HOME: User's home directory
113+
#
114+
# Many tools including p4a store outputs in the user's home
115+
# directory. This is found from the HOME environment variable
116+
# and falls back to the system account database. Setting HOME
117+
# can be used to globally divert these tools to use a different
118+
# path. Furthermore, in containerized environments the user may
119+
# not exist in the account database, so if HOME isn't set than
120+
# these tools will fail.
121+
if 'HOME' in environ:
122+
env['HOME'] = environ['HOME']
123+
112124
# CFLAGS/CXXFLAGS: the processor flags
113125
env['CFLAGS'] = ' '.join(self.common_cflags).format(target=self.target)
114126
if self.arch_cflags:

0 commit comments

Comments
 (0)