Skip to content

make resolve_path robust against None path being provided#2282

Merged
wpoely86 merged 4 commits intoeasybuilders:developfrom
boegel:resolve_path_None
Aug 9, 2017
Merged

make resolve_path robust against None path being provided#2282
wpoely86 merged 4 commits intoeasybuilders:developfrom
boegel:resolve_path_None

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel boegel commented Aug 8, 2017

companion fix for #2279 (alongside updated bootstrap script in #2281)

If this had been part of #2248, bootstrapping EasyBuild v3.3.1 would not have been broken as reported in #2279

@boegel boegel added this to the 3.4.0 milestone Aug 8, 2017
Comment thread easybuild/tools/filetools.py Outdated
resolved_path = os.path.realpath(path)
except OSError as err:
raise EasyBuildError("Resolving path %s failed: %s", path, err)
if path is None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just avoid calling this with None?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wpoely86 Well, sure, that's another option, but then we're bound to make the same mistake again later?

It would boil down to doing this in get_paths_for:

    # figure out installation prefix, e.g. distutils install path for easyconfigs
    eb_path = which('eb')
    if eb_path is None:
        _log.warning("'eb' not found in $PATH, failed to determine installation prefix")
    else:
        # real location of eb should reside in <install_prefix>/bin/eb
        eb_path = resolve_path(eb_path)
        install_prefix = os.path.dirname(os.path.dirname(eb_path))

whereas now we have:

    # figure out installation prefix, e.g. distutils install path for easyconfigs
    eb_path = resolve_path(which('eb'))
    if eb_path is None:
        ...

I'm not sure which one is better, I'm happy to change it as you suggest if you feel strongly about it.

@easybuilders easybuilders deleted a comment from boegelbot Aug 9, 2017
@boegel
Copy link
Copy Markdown
Member Author

boegel commented Aug 9, 2017

@wpoely86 Updated, this is indeed a bit cleaner, I don't think we want to go towards making every possible function robust against passing in None...

@wpoely86 wpoely86 merged commit b1d2453 into easybuilders:develop Aug 9, 2017
@boegel boegel deleted the resolve_path_None branch August 9, 2017 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants