This feature is useful when creating packages for Centos Stream and RHEL
which contain multiple Python stacks and make it possible to build packages for
them.
Packages on PyPI publish wheels which contain an abi tag informing
whether a package contains extensions compiled for a specific
architecture or not.
pyp2conf reads this information and saves it in the config file.
conf2spec automatically adds `gcc` to the generated specfile in case
package is archful.
They were partially defunct, made no actual sense and need to be
forgotten without mercy.
Generating extras for %pyproject_buildrequires (-x foo) will be improved.
For tox dependencies (-t), the users can manually add it to the resulting
spec file.
Create extra subpackages for all of the detected upstream extras.
Due to PyPI API limitations, if an extra is defined as empty
(i.e. without any requirements), it won't be detected.
It is an inherent package property rather than an external factor.
It is the key differentiator for obtaining the package metadata (they
must match the given version release).
Instead of raising multiple sys.exit's throughout the code,
each function either returns a proper value or raises a meaningful
custom error.
The custom errors are caught in each script's main(),
the error message is printed for user and the script exits.
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.
- 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
- 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.
Increase readability of the functions by removing listing of many
arguments.
Instead, the command-line options are passed as a dictionary until
the particular items are needed.
The tests should cover both fully automated way of pyp2spec as well as
the custom modifications of conf2pyp (it can do more than we can
currently read from the upstream).
Mark custom tests clearly with conf2spec prefix.
This allows to nuke the naive and error-prone generating of module names.
Support for %py3_check_import is dropped (its functionality is covered
by %pyproject_check_import).