Skip to content

Commit

Permalink
Merge pull request #6042 from johnhaddon/pythonNoUserSite
Browse files Browse the repository at this point in the history
Wrapper : Set `PYTHONNOUSERSITE=1`
  • Loading branch information
johnhaddon authored Sep 18, 2024
2 parents ede31f9 + 510fd65 commit aacb11c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Fixes
- usdview : Added Windows support (#5599).
- ContextTracker : Removed unnecessary reference increment/decrement from `isTracked()`, `context()` and `isEnabled()`.
- Menu : Fixed bug causing a menu item's tooltip to not hide when moving the cursor to another menu item without a tooltip.
- Python : Fixed startup failures caused by conflicting Python modules in the user `site-packages` directory.

API
---
Expand Down Expand Up @@ -117,6 +118,7 @@ Breaking Changes
- FreezeTransform : Constant primitive variables with point/vector interpretations are now also transformed (this is more correct, but it is a change in behaviour).
- ImageGadget : Remove non-const variant of `getContext()`.
- LazyMethod : `deferUntilPlaybackStops` now requires that the Widget has a `scriptNode()` method rather than a `context()` method.
- Python : Gaffer now disables the user site-packages directory by setting `PYTHONNOUSERSITE=1`. To revert to the previous behaviour, set `PYTHONNOUSERSITE=0` before launching Gaffer.

Build
-----
Expand Down
9 changes: 9 additions & 0 deletions bin/gaffer
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ fi

prependToPath "$GAFFER_ROOT/python" PYTHONPATH

if [[ -z $PYTHONNOUSERSITE ]] ; then
# Prevent Python automatically adding a user-level `site-packages`
# directory to the `sys.path`. These frequently contain modules which
# conflict with our own. Users who know what they are doing can set
# `PYTHONNOUSERSITE=0` before running Gaffer if they want to use
# the user directory.
export PYTHONNOUSERSITE=1
fi

# Stop Cortex from making all Python modules load with RTLD_GLOBAL.
export IECORE_RTLD_GLOBAL=0

Expand Down
9 changes: 9 additions & 0 deletions bin/gaffer.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ set PYTHONHOME=%GAFFER_ROOT%

call :prependToPath "%GAFFER_ROOT%\python" PYTHONPATH

if "%PYTHONNOUSERSITE%" EQU "" (
REM Prevent Python automatically adding a user-level `site-packages`
REM directory to the `sys.path`. These frequently contain modules which
REM conflict with our own. Users who know what they are doing can set
REM `PYTHONNOUSERSITE=0` before running Gaffer if they want to use
REM the user directory.
set PYTHONNOUSERSITE=1
)

call :prependToPath "%GAFFER_ROOT%\lib" PATH

set QT_OPENGL=desktop
Expand Down

0 comments on commit aacb11c

Please sign in to comment.