forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify package data in setup.py installs all files (ansible#59537)
* Add sanity test to ensure all non-py files are installed * Fix mode and regex * Fix role skel inventory package_data * Add docs * Update package_data for inventory files * Address pylint concerns * Another tweak to package_data * Address review feedback * Change index to 1 * add to ansible-only.txt
- Loading branch information
Showing
6 changed files
with
61 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Sanity Tests » package-data | ||
=========================== | ||
|
||
Verifies that the combination of ``MANIFEST.in`` and ``package_data`` from ``setup.py`` | ||
properly installs data files from within ``lib/ansible`` |
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ deprecated-config.py | |
docs-build.py | ||
test-constraints.py | ||
update-bundled.py | ||
package-data.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,5 @@ | ||
{ | ||
"disabled": true, | ||
"always": true, | ||
"output": "path-message" | ||
} |
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 @@ | ||
#!/usr/bin/env python | ||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
import fnmatch | ||
import os | ||
import re | ||
import tempfile | ||
import subprocess | ||
|
||
|
||
def main(): | ||
ignore_files = frozenset(( | ||
'*/.git_keep', | ||
'*/galaxy/data/default/role/*/main.yml.j2', | ||
'*/galaxy/data/default/role/*/test.yml.j2', | ||
'*/galaxy/data/default/collection/plugins/README.md.j2', | ||
)) | ||
|
||
non_py_files = [] | ||
for root, _dummy, files in os.walk('lib/ansible/'): | ||
for filename in files: | ||
path = os.path.join(root, filename) | ||
if os.path.splitext(path)[1] not in ('.py', '.pyc', '.pyo'): | ||
add = True | ||
for ignore in ignore_files: | ||
if fnmatch.fnmatch(path, ignore): | ||
add = False | ||
if add: | ||
non_py_files.append(os.path.relpath(path, 'lib/ansible')) | ||
|
||
with tempfile.TemporaryDirectory() as tmp_dir: | ||
stdout, _dummy = subprocess.Popen( | ||
['python', 'setup.py', 'install', '--root=%s' % tmp_dir], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True, | ||
).communicate() | ||
match = re.search('^creating (%s/.*?/(?:site|dist)-packages/ansible)$' % tmp_dir, stdout, flags=re.M) | ||
|
||
for filename in non_py_files: | ||
path = os.path.join(match.group(1), filename) | ||
if not os.path.exists(path): | ||
print('%s: File not installed' % os.path.join('lib', 'ansible', filename)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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