-
Notifications
You must be signed in to change notification settings - Fork 73
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
handle failures to find a user home directory #278
Conversation
In certain environments (notably, the [bazel sandbox](https://bazel.build/docs/sandboxing) on windows), it is possible for `pathlib.Path('~').expanduser()` to fail to find the user home directory and [raise a `RuntimeError`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.expanduser). This causes `distutils` (and ultimately, `setuptools`) to fail. With this patch, we catch and handle the exception by logging a warning and continuing without a user's config file. motivated by bazelbuild/rules_python#1067
In other scenarios, I've taken measures to explicitly set the home dir to a known location. That approach has the benefit of allowing downstream packages (like distutils) to continue to operate normally and only alters the behavior in the environments that are relevant (e.g. bazel sandbox). Wouldn't it be better for bazel sandbox to provide a suitable (empty) home directory and thus address this concern for any project running in the sandbox? |
Co-authored-by: Anderson Bravalheri <andersonbravalheri+github@gmail.com>
That's pretty much the workaround I implemented in https://github.com/bazelbuild/rules_python/pull/1067/files#diff-a92cc6468f47191b8e22d4bbe2564d3968d3dd4bbc383b9f3df3c4c520e1583eR157-R165.
Personally, I can't think of a reason for For what it's worth, other Python build backends (eg: flit, hatchling) do not fail in the event that you attempt to build without a valid home directory. |
I think I agree with you here. However, there's another factor to consider. Do you want That said, you make a compelling argument. There's not a very good reason for distutils not to be resilient under such conditions. |
Personally, no. My understanding is that bazel's sandbox restricts I/O outside of the sandbox, but not in a way that'd prevent reading a user's config file1. bazel builds that are performed remotely shouldn't be impacted though (since the home directory of the user invoking Footnotes
|
In certain environments (notably, the bazel sandbox on windows), it is possible for
pathlib.Path('~').expanduser()
to fail to find the user home directory and raise aRuntimeError
. This causesdistutils
(and ultimately,setuptools
) to fail.With this patch, we catch and handle the exception by logging a warning and continuing without a user's config file.
motivated by bazelbuild/rules_python#1067