217 Commits
Author SHA1 Message Date
Karolina SurmaandKarolina Surma 2ab284a2f4 Name attributes storing data from PyPI with 'pypi' prefix
Disambiguate the source of the used/read data, so that it's clear
what comes from PyPI API.
With the Core Metadata parser added, this is necessary.
2024-10-22 15:28:04 +02:00
Karolina SurmaandKarolina Surma 76b32aef49 Add the license presence assertion (closes: #49)
If "License-File" is present in Metadata file, we can safely add the
`-l` flag to %pyproject_save_files. The flag asserts that at least
one license file is marked as %license in the %files section
when there are none specified manually.
Not all build backends expose the field yet, which was oficially added
to Core Metadata 2.4 with PEP 639.
2024-10-22 15:28:04 +02:00
Karolina Surma bf70f16f6c Bump version 0.9.0 -> 0.10.0 2024-10-10 11:05:50 +02:00
Karolina Surma 41cdaf2a55 Decolorize some of the info statements coming from the application
Yellow - operating on the discovered information
Magenta - requires attention, not bad per se
Red - something bad has happened

Also, done cosmetic changes to the printed sentences, ain't noboody got
time to read novels.
2024-10-10 09:49:42 +02:00
Karolina Surma e828452064 Display the detected SPDX identifiers and their validity in Fedora 2024-10-10 09:49:42 +02:00
Karolina Surma 3163be3ab8 Don't error, just print a warning if the found license is invalid
Also, remove -l CLI option to provide the license manually.
Whoever needs that, can edit the resulting specfile.

Fixes: #47
2024-10-10 09:49:42 +02:00
Karolina Surma 45d5029a39 Remove unnecessary test configs
The differentiating bits were removed from the production code.
Annotate the remaining files and fields relevant for tests
(why do we test those)
2024-10-10 09:49:42 +02:00
Karolina Surma 0f744ae3ba Document automode 2024-10-10 09:49:42 +02:00
Karolina Surma 32fc2f1f07 Differentiate %pyproject_save_files based on the automode setting
For automated environments, we want to ensure buildability of the
created specfile, hence adding `"*" +auto` to %pyproject_save_files.
In the real Fedora packages, the valid argument to %pyproject_save_files
is a list of module names.
For now there's no automatic way to discover what modules the package
contains, so when a human user invokes pyp2spec, we want to generate a
file with placeholder (...) for them to fill in after the package
inspection.
2024-10-10 09:49:42 +02:00
Karolina Surma 0c516749a7 Differentiate the %check depending on the automode setting
- Utilize the new macro %_pyproject_check_import_allow_no_modules to allow
passing check in automated environments, even when the package doesn't
contain any Python modules (fixes #31).
2024-10-10 09:49:42 +02:00
Karolina Surma 098b1e05ab Introduce automode, remove the standalone top-level CLI option
First step to gather the defaults useful for automated build
environments but not so great to the human packagers, under one
umbrella.
2024-10-10 09:49:42 +02:00
Karolina Surma f68bd81433 Test on Python 3.13 2024-10-01 12:30:27 +02:00
Karolina Surma 423d49c1de Remove the binary files-related config options
Until they're autodetectable, we don't want them.
2024-10-01 12:29:53 +02:00
Karolina Surma 279ffe66b9 Remove doc-related config options
There's no automatic way to detect them.
Packagers are encouraged to inspect the package and add them as needed.
2024-10-01 12:29:52 +02:00
Karolina Surma c751c8895a Remove the license-related config options
The main Python build backends can discover the license files
automatically.
We don't need bits to manually add them.
2024-10-01 12:29:52 +02:00
Karolina Surma b5959eaeac Remove the test-related config options
This can't be detected automatically yet.
2024-10-01 12:29:52 +02:00
Karolina Surma ae075944f9 Remove remaining parts concerning the manual build requirements 2024-10-01 12:29:52 +02:00
Karolina Surma 19c1aab1a7 Remove the option to add custom Summary and Description
They're either detected from the package metadata
or filled in with a sane default for automated use.
The actual users can edit the resulting files.
2024-10-01 12:29:52 +02:00
Karolina Surma 540738c257 Migrate to pyproject.toml
No need to define the package in two config files.
2024-10-01 09:34:10 +02:00
Karolina Surma 661fb9b770 Bump version 0.8.0 -> 0.9.0 2024-04-11 15:56:08 +02:00
Karolina SurmaandKarolina Surma ce099be238 Create spec files for alternative Python versions (closes #16)
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.
2024-04-11 12:40:05 +02:00
Martin JuhlandKarolina Surma b52e5da264 Implement support for specific python versions #16 2024-04-11 12:40:05 +02:00
Karolina Surma 39c562f019 Bump version 0.7.0 -> 0.8.0 2023-10-11 11:11:01 +02:00
Karolina SurmaandKarolina Surma a3be9eb968 Add the changelog entry 2023-10-11 10:47:49 +02:00
Karolina SurmaandKarolina Surma 55ef64fa8f Remove the CLI option to set archful packages
It's discovered automatically now.
If the users need to change more in the resulting files, they can edit them.
2023-10-11 10:47:49 +02:00
Karolina SurmaandKarolina Surma f6e4b0b4ba Determine if package is archful by parsing the wheel name
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.
2023-10-11 10:47:49 +02:00
Karolina SurmaandKarolina Surma ba868ae3ce Remove obsolete bits allowing to add manual build requirements
We only want to add what's detectable from the package metadata.
2023-10-11 10:47:49 +02:00
Karolina SurmaandKarolina Surma b7c1cdb63f Add extras to %pyproject_buildrequires
Use the newly added `extras` config key, containing a list of all
detected package extras.
2023-10-10 15:55:20 +02:00
Karolina SurmaandKarolina Surma 4244c2a3ae Remove obsolete bits allowing to manually define extras
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.
2023-10-10 15:55:20 +02:00
Karolina SurmaandKarolina Surma 641195404c Automatically detect extras from the PyPI metadata
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.
2023-10-10 15:55:20 +02:00
Karolina SurmaandKarolina Surma ce93424dce Save session as an attribute of a PypiPackage object
Don't send session as a method parameter through multiple layers.
Increase readability of methods' signatures.
2023-10-10 10:36:20 +02:00
Karolina SurmaandKarolina Surma d07ce850d9 Use versioned package JSON API from PyPI
This ensures fetching the metadata belonging to the correct package
version (fixes #41).
Reference:
https://warehouse.pypa.io/api-reference/json.html#get--pypi--project_name---version--json
2023-10-10 10:36:20 +02:00
Karolina SurmaandKarolina Surma d6fbd6f595 Save version as an attribute of a PypiPackage object
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).
2023-10-10 10:36:20 +02:00
Karolina Surma 954ccd974b Remove the unused import from tests 2023-09-20 16:27:20 +02:00
Karolina Surma 5dd064b89c Pass the correct envnames to the GH action 2023-09-01 16:37:04 +02:00
Karolina SurmaandKarolina Surma 741a14aa9b Handle exceptions better throughout the app
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.
2023-09-01 11:27:51 +02:00
Karolina Surma f8a1c500d3 Remove the unnecessary -dev suffix in 312 tox env 2023-09-01 11:26:00 +02:00
Karolina Surma 900dfc1a6d Run tox on project's CI 2023-06-02 15:10:47 +02:00
Karolina Surma b0d5969da6 Add tox configuration 2023-06-02 15:10:47 +02:00
Karolina Surma 316a6818d9 Lowest supported Python version is 3.9
importlib.resources.files() API isn't available in the older Pythons.
2023-06-02 09:45:40 +02:00
Karolina SurmaandKarolina Surma d8bb58ad49 Use the recommended importlib.resources.files() API to open package resources 2023-05-31 11:23:45 +02:00
Karolina Surma 0f603d69c9 Bump version 0.6.1 -> 0.7.0 2023-05-03 15:58:24 +02:00
Karolina SurmaandKarolina Surma f7cc4af5d1 Display the license string which failed to be parsed 2023-05-03 10:14:08 +02:00
Karolina SurmaandKarolina Surma 3c631c1f86 Include all the test files in the sdist 2023-05-03 10:14:08 +02:00
Karolina SurmaandKarolina Surma 740c252083 Update examples README to reflect the new specfile outcome 2023-05-03 10:14:08 +02:00
Karolina SurmaandKarolina Surma ebd1b81075 Move to rpmautospec macros for changelog and release
rpmautospec has been present in Fedora since F35 and it's currently
a recommended way of handling the changelog and release specfile
entries: https://fedoraproject.org/wiki/Changes/rpmautospec
2023-04-25 16:24:37 +02:00
Karolina SurmaandKarolina Surma 238faa40d6 Exit script correctly on a non-existing package (fixes #30) 2023-04-25 16:24:37 +02:00
Karolina SurmaandKarolina Surma dce4344006 Convert Python license classifiers to SPDX expressions
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.
2023-04-25 10:17:47 +02:00
Miro HrončokandKarolina Surma 737036a322 Use tomllib from the standard library on Python 3.11+ 2022-10-20 14:06:37 +02:00
Maxwell GandKarolina Surma d7966cb29e Only define pyp2{spec,conf}'s shared arguments once
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.
2022-09-05 10:07:48 +02:00