Skip to content

Commit

Permalink
chore: cleanup symlink noxfile code (#865)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii authored Oct 18, 2024
1 parent e58a470 commit 771c1c7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions nox/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ def load_nox_module(global_config: Namespace) -> types.ModuleType | int:
Returns:
module: The module designated by the Noxfile path.
"""
try:
# Save the absolute path to the Noxfile.
# This will inoculate it if Nox changes paths because of an implicit
# or explicit chdir (like the one below).
global_config.noxfile = os.path.realpath(
# Be sure to expand variables
os.path.expandvars(global_config.noxfile)
)
noxfile_parent_dir = os.path.realpath(os.path.dirname(global_config.noxfile))
# Be sure to expand variables
global_config_noxfile = os.path.expandvars(global_config.noxfile)

# Save the absolute path to the Noxfile.
# This will inoculate it if Nox changes paths because of an implicit
# or explicit chdir (like the one below).
global_config.noxfile = os.path.realpath(global_config_noxfile)

# Make sure we only expand the parent dir just in case the noxfile is a symlink
noxfile_parent_dir = os.path.realpath(os.path.dirname(global_config.noxfile))

try:
# Check ``nox.needs_version`` by parsing the AST.
check_nox_version(global_config.noxfile)

Expand All @@ -110,8 +112,8 @@ def load_nox_module(global_config: Namespace) -> types.ModuleType | int:
except OSError:
logger.exception(f"Failed to load Noxfile {global_config.noxfile}")
return 2
else:
return _load_and_exec_nox_module(global_config)

return _load_and_exec_nox_module(global_config)


def merge_noxfile_options(
Expand Down

0 comments on commit 771c1c7

Please sign in to comment.