Skip to content

Commit

Permalink
Hacky stab in the dark #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Nov 16, 2024
1 parent 6cbfc60 commit 47443d9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pex/pex_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from pex import layout, pex_warnings, variables
from pex.cache import root as cache_root
from pex.common import can_write_dir, open_zip, safe_mkdtemp
from pex.common import can_write_dir, open_zip, safe_mkdtemp, safe_rmtree
from pex.compatibility import PY2, WINDOWS
from pex.compatibility import string as compatibility_string
from pex.inherit_path import InheritPath
Expand Down Expand Up @@ -151,7 +151,9 @@ def __init__(self, info=None):

self._excluded = OrderedSet(self._pex_info.get("excluded", ())) # type: OrderedSet[str]
self._overridden = OrderedSet(self._pex_info.get("overridden", ())) # type: OrderedSet[str]
self._backup_pex_root = safe_mkdtemp()
os.environ["_PEX_BACKUP_ROOT"] = self._backup_pex_root = (
os.environ.get("_PEX_BACKUP_ROOT") or safe_mkdtemp()
)

def _get_safe(self, key):
if key not in self._pex_info:
Expand Down Expand Up @@ -510,7 +512,10 @@ def raw_pex_root(self):
def pex_root(self):
# type: () -> str
pex_root = os.path.realpath(os.path.expanduser(self.raw_pex_root))
if not can_write_dir(pex_root):
if can_write_dir(pex_root):
os.environ.pop("_PEX_BACKUP_ROOT", None)
safe_rmtree(self._backup_pex_root)
else:
tmp_root = os.path.realpath(self._backup_pex_root)
pex_warnings.warn(
"PEX_ROOT is configured as {pex_root} but that path is un-writeable, "
Expand Down

0 comments on commit 47443d9

Please sign in to comment.