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

Include HOME in build environment #2582

Merged
merged 1 commit into from
Sep 20, 2022
Merged

Include HOME in build environment #2582

merged 1 commit into from
Sep 20, 2022

Conversation

dbnicholson
Copy link
Contributor

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.

I don't know if this is the best place to put this, but it seemed the most common location where the build environment is setup.

dbnicholson added a commit to dbnicholson/kolibri-installer-android that referenced this pull request Apr 20, 2022
The need to copy things in and out of the container so it can run as the
real kivy user is a burden. In fact, the only reason you need to do this
is because p4a and other tools store intermediate outputs in the user's
home directory instead of in the current directory.

Instead, we can fake that by running the container as the current user
and setting the HOME environment variable to a writable location in the
container. Furthermore, we can mount a volume at this path and cache all
of those outputs.

Once the container is running as the current user, usage is much simpler
as we don't need to worry about ownership of files. The source directory
can be mounted directly into the container and made the current working
directory. Then the container environment behaves almost exactly like
running the commands directly in the current directory. We don't need a
user inside the container or have to copy the source tree into the
image.

This depends on p4a passing through the HOME environment variable during
builds. See kivy/python-for-android#2582.
@dbnicholson
Copy link
Contributor Author

Anything I can do to help this along? Would a test help?

@misl6
Copy link
Member

misl6 commented Sep 19, 2022

Hi @dbnicholson !

  • It makes sense, and looks a great addition. ❤️
  • Maybe the comment can better clarify (as you did on the PR description) why is that needed? (Just to help anyone looking at this line in future)
  • A rebase so we can have a full ✅ CI run would be also nice.

Feel free to ping me as soon you're ready!

@dbnicholson
Copy link
Contributor Author

Ok, I'll beef up the comment.

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`.
@dbnicholson
Copy link
Contributor Author

Ready for review again. Thanks!

@misl6
Copy link
Member

misl6 commented Sep 19, 2022

Ready for review again. Thanks!

Oh yeah, showed up on my notifications 4 minutes ago! 😄
The comment looks good!

Let's wait for the CI to complete 🏁

Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@misl6 misl6 merged commit 6cf8604 into kivy:develop Sep 20, 2022
@dbnicholson dbnicholson deleted the home-env branch September 20, 2022 16:25
dbnicholson added a commit to dbnicholson/python-for-android that referenced this pull request Sep 23, 2022
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`.

(cherry picked from commit 6cf8604)
shyamnathp pushed a commit to shyamnathp/python-for-android that referenced this pull request Feb 17, 2023
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants