Alongside with the license-related code the tests were significantly
refactored to run offline. The changes are intertwined and so shipped in
a single commit.
The licensing changes:
- updated Trove-Fedora mappings (removed Callaway expressions, added
SPDX)
- delegated the compliance check of Fedora licenses to a source
maintained by the Fedora Legal team
- the logic of license processing was moved to a dedicated module:
license_processor
The testing changes:
- moved betamax configuration to conftest.py to achieve a reliable global setting
- mocked fedora licensing data and PyPI package data to stop making
unnecessary requests - most of the betamax cassettes were deleted
- several tests rewritten, many added
- regenerated remaining betamax cassettes
This is a best-effort solution which can't (nor aims to) cover all edge-cases.
Unless Python adopts SPDX standard, this will always be an approximation.
pyp2conf and pyp2spec share a lot of the same arguments, but they are
currently duplicated. This creates a wrapper function to share
arguments between them, making the code DRYer.
- Replace underscores and dots with dashes in projects' names
Projects like sphinx_design result in python-sphinx-design.spec
and python3-sphinx-design built RPM name.
- Convert uppercase characters to lowercase
Projects like Pello result in python-pello.spec and python3-pello
built RPM name.
This conforms better with package naming guidelines:
https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_naming
At least when packaging for Fedora, the fact that the specfile is
generated by pyp2spec is irrelevant as far as the changelog is
concerned. Generally, the initial changelog
entry is "Initial package" or something similar.
Signed-off-by: Maxwell G <gotmax@e.email>
- If the RPM and PyPI version strings differ, they both need to be acquired to
generate a valid spec file: PyPI string is needed for autosetup in %prep and
%pypi_source macro.
- Improve generating %{pypi_source} macro to incorporate the different
version strings if they differ. It not, there's no need to include it.
Instead of error-prone splitting the strings on hyphens, strip the
archive filename from the suffixes and versions, which shall result in
getting the pure archive name.
Refactor obtaining archive filename to traverse the json data just once.
- Include converter based on pyreq2rpm to create valid RPM versions
- For non-compatible versions no transformation is done, such string may
or may not work with RPM
- Test two spec files as generated files (one default, one custom).
This means any change to a template will require just one or two changes
in the files.
- Test each custom field separately, before they're saved to file.
- Remove configs/spec files which only duplicate what was already
tested.
- Sometimes the License keyword contains the full license text instead of
a keyword (indicated by multiline string value).
In this case it's impossible to reliably derive the keyword,
hence such value is discarded.
- Added verbose docstring with License quirks' explanation
Summary can be gotten from upstream metadata or provided via CLI.
If upstream metadata is empty and no argument was provided,
generate an empty summary string to fill in the spec file.