Skip to content

Commit

Permalink
Allow to write python_requires into deps and build files. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Oct 3, 2022
1 parent 2fa71bc commit 7b42072
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/10-python_requires.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "Allow to write Python dependencies as ``_python`` key into build and dependency files (https://github.com/ansible-community/antsibull-core/pull/10)."
12 changes: 10 additions & 2 deletions src/antsibull_core/dependency_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ def parse(self) -> DependencyFileData:

def write(self, ansible_version: Union[str, 'PypiVer'],
ansible_core_version: Union[str, 'PypiVer'],
included_versions: Union[Mapping[str, str], Mapping[str, 'SemVer']]) -> None:
included_versions: Union[Mapping[str, str], Mapping[str, 'SemVer']],
python_requires: Optional[str] = None) -> None:
"""
Write a list of all the dependent collections included in this Ansible release.
:arg ansible_version: The version of Ansible that is being recorded.
:arg ansible_core_version: The version of Ansible-core that will be depended on.
:arg included_versions: Dictionary mapping collection names to the version range in this
version of Ansible.
:arg python_requires: A python_requires string. Will be stored as ``_python``.
WARNING: This function will no longer accept version objects in the ansible_core_version
and included_versions parameters, and will require a PypiVer object in the
Expand All @@ -142,6 +144,8 @@ def write(self, ansible_version: Union[str, 'PypiVer'],
f.write(f'_ansible_core_version: {ansible_core_version}\n')
else:
f.write(f'_ansible_base_version: {ansible_core_version}\n')
if python_requires is not None:
f.write(f'_python: {python_requires}\n')
f.write('\n'.join(records))
f.write('\n')

Expand All @@ -155,7 +159,8 @@ def parse(self) -> DependencyFileData:
return _parse_name_version_spec_file(self.filename)

def write(self, ansible_version: 'PypiVer', ansible_core_version: str,
dependencies: Mapping[str, 'SemVer']) -> None:
dependencies: Mapping[str, 'SemVer'],
python_requires: Optional[str] = None) -> None:
"""
Write a build dependency file.
Expand All @@ -168,6 +173,7 @@ def write(self, ansible_version: 'PypiVer', ansible_core_version: str,
:arg ansible_core_version: The version of Ansible-core that will be depended on.
:arg dependencies: Dictionary with keys of collection names and values of the latest
versions of those collections.
:arg python_requires: A python_requires string. Will be stored as ``_python``.
"""
records = []
for dep, version in dependencies.items():
Expand All @@ -190,5 +196,7 @@ def write(self, ansible_version: 'PypiVer', ansible_core_version: str,
f.write(f'_ansible_core_version: {ansible_core_version}\n')
else:
f.write(f'_ansible_base_version: {ansible_core_version}\n')
if python_requires is not None:
f.write(f'_python: {python_requires}\n')
f.write('\n'.join(records))
f.write('\n')

0 comments on commit 7b42072

Please sign in to comment.