-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for namespace-qualified packages in repo_for_pkg #5787
Check for namespace-qualified packages in repo_for_pkg #5787
Conversation
Previously when RepoPath.repo_for_pkg was invoked with a string, it did not check if the string included a namespace. Any namespace-qualified package provided as a string would not be found (at which point the behavior was to return the highest-precedence repository).
I'll be able to add a unit test for this later today. (EDIT: didn't hit original target for 10/16 so I'll aim for tomorrow, 10/17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor change request. I also think we should definitely get some tests in for namespaced packages.
lib/spack/spack/repository.py
Outdated
else: | ||
# handle strings directly for speed instead of @_autospec'ing | ||
name = spec | ||
try: | ||
namespace, name = spec.split('.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespaces can be nested, so I think you want:
namespace, _, name = spec.rpartition('.')
to do this right. This is what Repo
uses. namespace
will be empty if there is no namespace.
@yee379 as far as I can tell I can't reply directly to your comment at 65b3876#commitcomment-25042386 but this PR should fix your issue (which is likely another case of #5754). |
lib/spack/spack/test/repo.py
Outdated
# given RepoPath | ||
@pytest.fixture() | ||
def test_repo(): | ||
return spack.repository.RepoPath(spack.mock_packages_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, pytest
looks for methods and functions that start with test_
and consider them as tests. Not sure if creating a fixture that matches this pattern is asking for troubles...
I have edited the name - thanks for pointing that out! |
Fixes #5754
Previously when RepoPath.repo_for_pkg was invoked with a string,
it did not check if the string included a namespace. Any
namespace-qualified package provided as a string would not be found
(at which point the behavior was to return the highest-precedence
repository).