File tree 2 files changed +13
-13
lines changed
2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change
1
+ Only warn about running pip as root on BSD systems if it is actually being run as root
Original file line number Diff line number Diff line change @@ -169,19 +169,18 @@ def warn_if_run_as_root() -> None:
169
169
# On Windows, there are no "system managed" Python packages. Installing as
170
170
# Administrator via pip is the correct way of updating system environments.
171
171
#
172
- # We choose sys.platform over utils.compat.WINDOWS here to enable Mypy platform
173
- # checks: https://mypy.readthedocs.io/en/stable/common_issues.html
174
- if sys .platform == "win32" or sys .platform == "cygwin" :
175
- return
176
- if sys .platform == "darwin" or sys .platform == "linux" :
177
- if os .getuid () != 0 :
178
- return
179
- logger .warning (
180
- "Running pip as the 'root' user can result in broken permissions and "
181
- "conflicting behaviour with the system package manager. "
182
- "It is recommended to use a virtual environment instead: "
183
- "https://pip.pypa.io/warnings/venv"
184
- )
172
+ # Due to this, checking for execution as root is performed only on *nix
173
+ # style platforms.
174
+ if (sys .platform == "darwin" or sys .platform == "linux" or
175
+ sys .platform .startswith ("openbsd" ) or sys .platform .startswith ("freebsd" ) or
176
+ sys .platform .startswith ("netbsd" )):
177
+ if os .getuid () == 0 :
178
+ logger .warning (
179
+ "Running pip as the 'root' user can result in broken permissions and "
180
+ "conflicting behaviour with the system package manager. "
181
+ "It is recommended to use a virtual environment instead: "
182
+ "https://pip.pypa.io/warnings/venv"
183
+ )
185
184
186
185
187
186
def with_cleanup (func : Any ) -> Any :
You can’t perform that action at this time.
0 commit comments