Skip to content

Commit

Permalink
Exclude certain unnecessary files from the bdist.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Dec 11, 2021
1 parent e3f9522 commit 44d6e18
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/antsibull/build_ansible_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def write_release_py(ansible_version: PypiVer, ansible_collections_dir: str) ->

def write_setup(ansible_version: PypiVer,
ansible_core_version: PypiVer,
collections: t.List[t.Tuple[str, str]],
collection_deps: str,
package_dir: str) -> None:
setup_filename = os.path.join(package_dir, 'setup.py')
Expand All @@ -136,6 +137,7 @@ def write_setup(ansible_version: PypiVer,
version=ansible_version,
ansible_core_package_name=get_ansible_core_package_name(ansible_core_version),
ansible_core_version=ansible_core_version,
collections=collections,
collection_deps=collection_deps)

with open(setup_filename, 'w') as f:
Expand All @@ -144,13 +146,14 @@ def write_setup(ansible_version: PypiVer,

def write_python_build_files(ansible_version: PypiVer,
ansible_core_version: PypiVer,
collections: t.List[t.Tuple[str, str]],
collection_deps: str,
package_dir: str,
release_notes: t.Optional[ReleaseNotes] = None,
debian: bool = False) -> None:
copy_boilerplate_files(package_dir)
write_manifest(package_dir, release_notes, debian)
write_setup(ansible_version, ansible_core_version, collection_deps, package_dir)
write_setup(ansible_version, ansible_core_version, collections, collection_deps, package_dir)


def write_debian_directory(ansible_version: PypiVer,
Expand Down Expand Up @@ -353,10 +356,13 @@ def rebuild_single_command() -> int:
release_notes.write_changelog_to(app_ctx.extra['dest_data_dir'])
release_notes.write_porting_guide_to(app_ctx.extra['dest_data_dir'])

collections = [name.split('.', 1) for name in sorted(dependency_data.deps)]

# Write build scripts and files
write_build_script(app_ctx.extra['ansible_version'], ansible_core_version, package_dir)
write_python_build_files(app_ctx.extra['ansible_version'], ansible_core_version, '',
package_dir, release_notes, app_ctx.extra['debian'])
write_python_build_files(app_ctx.extra['ansible_version'], ansible_core_version,
collections, '', package_dir, release_notes,
app_ctx.extra['debian'])
if app_ctx.extra['debian']:
write_debian_directory(app_ctx.extra['ansible_version'], ansible_core_version,
package_dir)
Expand Down Expand Up @@ -484,7 +490,7 @@ def build_multiple_command() -> int:
collection_deps = '\n' + ',\n'.join(collection_deps)
write_build_script(app_ctx.extra['ansible_version'], ansible_core_version, package_dir)
write_python_build_files(app_ctx.extra['ansible_version'], ansible_core_version,
collection_deps, package_dir)
[], collection_deps, package_dir)

make_dist(package_dir, app_ctx.extra['sdist_dir'])

Expand Down
14 changes: 14 additions & 0 deletions src/antsibull/data/ansible-setup_py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ setup(
python_requires='>=3.8',
{%- endif %}
packages=['ansible_collections'],
{% if version.major >= 6 %}
exclude_package_data={
'ansible_collections': [
{% for name, namespace in collections %}
'{{ name }}/{{ namespace }}/.gitignore',
'{{ name }}/{{ namespace }}/.github/*',
'{{ name }}/{{ namespace }}/.azure-pipelines/*',
'{{ name }}/{{ namespace }}/changelogs/*',
'{{ name }}/{{ namespace }}/docs/*',
'{{ name }}/{{ namespace }}/tests/*',
{% endfor %}
],
},
{% endif %}
include_package_data=True,
install_requires=[
'{{ ansible_core_package_name }} ~= {{ ansible_core_version }}',{{ collection_deps }}
Expand Down

0 comments on commit 44d6e18

Please sign in to comment.