Skip to content

Commit a561892

Browse files
committed
fix: update all os.path.realpath-using call-sites to use real_path instead.
Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
1 parent bb69916 commit a561892

7 files changed

Lines changed: 19 additions & 15 deletions

File tree

src/rez/resolved_context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from rez.utils.formatting import columnise, PackageRequest, ENV_VAR_REGEX, \
1818
header_comment, minor_header_comment
1919
from rez.utils.data_utils import deep_del
20-
from rez.utils.filesystem import TempDirs, is_subdirectory, canonical_path
20+
from rez.utils.filesystem import TempDirs, is_subdirectory, canonical_path, real_path
2121
from rez.utils.memcached import pool_memcached_connections
2222
from rez.utils.logging_ import print_debug, print_error, print_warning
2323
from rez.utils.which import which
@@ -1896,8 +1896,8 @@ def _adjust_variant_for_bundling(cls, handle: dict, out: bool) -> None:
18961896

18971897
if is_subdirectory(repo_path, bundle_path):
18981898
vars_["location"] = os.path.relpath(
1899-
os.path.realpath(repo_path),
1900-
os.path.realpath(bundle_path)
1899+
real_path(repo_path),
1900+
real_path(bundle_path)
19011901
)
19021902

19031903
# serializing in, make repo absolute

src/rez/serialise.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from rez.package_resources import package_rex_keys
2121
from rez.utils.scope import ScopeContext
2222
from rez.utils.sourcecode import SourceCode, early, late, include
23-
from rez.utils.filesystem import TempDirs
23+
from rez.utils.filesystem import TempDirs, real_path
2424
from rez.utils.data_utils import ModifyList
2525
from rez.exceptions import ResourceError, InvalidPackageError
2626
from rez.utils.memcached import memcached
@@ -66,7 +66,7 @@ def open_file_for_write(filepath, mode=None):
6666
yield stream
6767
content = stream.getvalue()
6868

69-
filepath = os.path.realpath(filepath)
69+
filepath = real_path(filepath)
7070
tmpdir = tmpdir_manager.mkdtemp()
7171
cache_filepath = os.path.join(tmpdir, os.path.basename(filepath))
7272

@@ -123,7 +123,7 @@ def load_from_file(filepath: str, format_=FileFormat.py, update_data_callback=No
123123
Returns:
124124
dict:
125125
"""
126-
filepath = os.path.realpath(filepath)
126+
filepath = real_path(filepath)
127127
cache_filepath = file_cache.get(filepath)
128128

129129
if cache_filepath:

src/rez/suite.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import annotations
66

77
from rez.utils.execution import create_forwarding_script
8+
from rez.utils.filesystem import real_path
89
from rez.exceptions import SuiteError, ResolvedContextError
910
from rez.resolved_context import ResolvedContext
1011
from rez.utils.data_utils import cached_property
@@ -458,7 +459,7 @@ def save(self, path, verbose: bool = False):
458459
at `path`, then it will be overwritten. Otherwise, if `path`
459460
exists, an error is raised.
460461
"""
461-
path = os.path.realpath(path)
462+
path = real_path(path)
462463
if os.path.exists(path):
463464
if self.load_path and self.load_path == path:
464465
if verbose:
@@ -528,7 +529,7 @@ def load(cls, path: str) -> Suite:
528529
raise SuiteError("Failed loading suite: %s" % str(e))
529530

530531
s = cls.from_dict(data)
531-
s.load_path = os.path.realpath(path)
532+
s.load_path = real_path(path)
532533
return s
533534

534535
@classmethod

src/rez/system.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from rez.utils.platform_ import platform_
1414
from rez.exceptions import RezSystemError
1515
from rez.utils.data_utils import cached_property
16+
from rez.utils.filesystem import real_path
1617

1718

1819
class System(object):
@@ -242,7 +243,7 @@ def rez_bin_path(self):
242243

243244
validation_file = os.path.join(binpath, ".rez_production_install")
244245
if os.path.exists(validation_file):
245-
return os.path.realpath(binpath)
246+
return real_path(binpath)
246247

247248
return None
248249

src/rez/utils/filesystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ def make_tmp_name(name):
329329

330330
def is_subdirectory(path_a, path_b) -> bool:
331331
"""Returns True if `path_a` is a subdirectory of `path_b`."""
332-
path_a = os.path.realpath(path_a)
333-
path_b = os.path.realpath(path_b)
332+
path_a = real_path(path_a)
333+
path_b = real_path(path_b)
334334
try:
335335
relative = os.path.relpath(path_a, path_b)
336336
except ValueError:

src/rez/utils/py_dist.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Functions for converting python distributions to rez packages.
77
"""
88
from rez.exceptions import RezSystemError
9+
from rez.utils.filesystem import real_path
910
import importlib.metadata as importlib_metadata
1011
import shutil
1112
import sys
@@ -194,7 +195,7 @@ def convert_dist(name, dest_path, make_variant: bool = True, ignore_dirs=None,
194195
files = set()
195196
for file in installed_files:
196197
path = os.path.join(eggpath, file)
197-
path = os.path.realpath(path)
198+
path = real_path(path)
198199

199200
if os.path.isfile(path) and path.startswith(dist.location + os.sep):
200201
dir_ = os.path.dirname(path)
@@ -209,7 +210,7 @@ def convert_dist(name, dest_path, make_variant: bool = True, ignore_dirs=None,
209210
def _dst(p):
210211
dst = os.path.relpath(p, dist.location)
211212
dst = os.path.join(root_path, dst)
212-
return os.path.realpath(dst)
213+
return real_path(dst)
213214

214215
for dir_ in dirs:
215216
dst_dir = _dst(dir_)

src/rezplugins/build_system/cmake.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from rez.utils.platform_ import platform_
1717
from rez.config import config
1818
from rez.utils.which import which
19+
from rez.utils.filesystem import real_path
1920
from rez.vendor.schema.schema import Or
2021
from rez.shells import create_shell
2122
import argparse
@@ -150,9 +151,9 @@ def _pr(s) -> None:
150151

151152
# execute cmake within the build env
152153
_pr("Executing: %s" % ' '.join(cmd))
153-
if not os.path.abspath(build_path):
154+
if not os.path.isabs(build_path):
154155
build_path = os.path.join(self.working_dir, build_path)
155-
build_path = os.path.realpath(build_path)
156+
build_path = real_path(build_path)
156157

157158
actions_callback = functools.partial(
158159
self._add_build_actions,

0 commit comments

Comments
 (0)