-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve backend loading from
backend-path
(#165)
* Test backend is loaded from backend-path * Actively import from backend-path instead of checking Previously `_in_process` would only modify `sys.path`, use `importlib.import_module` and hope the backend is loaded from the right path. This would lead to misleading error messages in some cases when the environment isolation is not perfect. This change modifies the behavior by using `importlib.machinery.PathFinder.find_spec` to locate the backend module within a set of path entries. * Unify usages of BackedInvalid with BackendUnavailable … when error regards import problems. * Fix path sep error when testing on windows * Improve explanation in code comment * Ensure backend info is available in exception * Replace custom import sequence with MetaPathFinder This should address review comments and increase the robustness of the solution. * Improve test docstring for intree backend * Replace comment with a more appropriate description * Mark BackendInvalid as no longer used/deprecated * Remove unused BackendInvalid * Test nested intree backend * Add negative tests for nested intree backends * Avoid passing nested modules to PathFinder
- Loading branch information
1 parent
a3456dd
commit 084b02e
Showing
10 changed files
with
113 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from ..buildsys import * # noqa: F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# PathFinder.find_spec only take into consideration the last segment | ||
# of the module name (not the full name). | ||
raise Exception("This isn't the backend you are looking for") |
2 changes: 2 additions & 0 deletions
2
tests/samples/pkg_nested_intree/backend/nested/intree_backend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def get_requires_for_build_sdist(config_settings): | ||
return ["intree_backend_called"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
build-backend = 'nested.intree_backend' | ||
backend-path = ['backend'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters