-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change ease maintenance and downstream packaging of linter by reducing the dependency chain and avoiding surprises from untested library versions.
- Loading branch information
Showing
13 changed files
with
70 additions
and
7 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
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,3 @@ | ||
[submodule ".projects/ansible-compat"] | ||
path = .projects/ansible-compat | ||
url = https://github.com/ansible/ansible-compat |
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
Submodule ansible-compat
added at
fb52b7
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,48 @@ | ||
import os | ||
import pkgutil | ||
import sys | ||
import warnings | ||
|
||
# This package exists to host vendored top-level Python packages for downstream packaging. Any Python packages | ||
# installed beneath this one will be masked from the Ansible loader, and available from the front of sys.path. | ||
# It is expected that the vendored packages will be loaded very early, so a warning will be fired on import of | ||
# the top-level ansible package if any packages beneath this are already loaded at that point. | ||
# | ||
# Python packages may be installed here during downstream packaging using something like: | ||
# pip install --upgrade -t (path to this dir) cryptography pyyaml packaging jinja2 | ||
|
||
# mask vendored content below this package from being accessed as a subpackage | ||
__path__ = [] | ||
|
||
|
||
def _ensure_vendored_path_entry() -> None: | ||
""" | ||
Ensure that any downstream-bundled content beneath this package is available at the top of sys.path | ||
""" | ||
# patch our vendored dir onto sys.path | ||
vendored_path_entry = os.path.dirname(__file__) | ||
vendored_module_names = { | ||
m[1] for m in pkgutil.iter_modules([vendored_path_entry], "") | ||
} # m[1] == m.name | ||
|
||
if vendored_module_names: | ||
# patch us early to load vendored deps transparently | ||
if vendored_path_entry in sys.path: | ||
# handle reload case by removing the existing entry, wherever it might be | ||
sys.path.remove(vendored_path_entry) | ||
sys.path.insert(0, vendored_path_entry) | ||
|
||
already_loaded_vendored_modules = set(sys.modules.keys()).intersection( | ||
vendored_module_names | ||
) | ||
|
||
if already_loaded_vendored_modules: | ||
warnings.warn( | ||
"One or more Python packages bundled by this ansible-lint distribution were already " | ||
"loaded ({}). This may result in undefined behavior.".format( | ||
", ".join(sorted(already_loaded_vendored_modules)) | ||
) | ||
) | ||
|
||
|
||
_ensure_vendored_path_entry() |
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 @@ | ||
../../../.projects/ansible-compat/src/ansible_compat |