Commit Graph
100 Commits
Author SHA1 Message Date
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
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
Karolina Surma 83a3568192 Bump version 0.6.0 -> 0.6.1 2022-08-01 14:14:57 +02:00
Karolina Surma dd292eb93c Include LICENSE-MIT-0 in the sdist and fix license metadata 2022-08-01 14:14:44 +02:00
Karolina Surma d9705f8536 Bump version 0.5.0 -> 0.6.0 2022-08-01 13:20:42 +02:00
Karolina Surma e580d544ae Add instructions how to record cassettes when needed 2022-08-01 12:59:24 +02:00
Karolina Surma 1ace5ce889 Normalize PyPI projects' name
- 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
2022-08-01 12:59:24 +02:00
Karolina Surma a28d3a218e Update license in package metadata 2022-08-01 12:59:24 +02:00
Karolina Surma 7b6b657f77 Relicense template.spec and derived files as MIT-0 (No attribution)
Fedora Legal plans to classify CC0 as content-only license, the
recommended equivalent for code being MIT-0:
https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/thread/RRYM3CLYJYW64VSQIXY6IF3TCDZGS6LM/
With the agreement of all contributors to the template.spec (#25), this file and
any files produced by pyp2spec are now licensed as MIT-0.
Fixes: #25
2022-07-26 16:06:10 +02:00
Karolina Surma ea39b14723 Clearly state the project's maturity as alpha 2022-06-20 13:00:13 +02:00
Karolina Surma d574544cfc Bump version 0.3.3 -> 0.4.0 2022-05-23 14:14:08 +02:00
Karolina Surma 76667d0f53 There's no URL in source anymore 2022-03-30 15:18:41 +02:00
Karolina Surma dda1c5873b Improve working with RPM/PyPI versions
- 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.
2022-03-30 15:18:41 +02:00
Karolina Surma 57c5799587 archive_name is now obtained in a better fashion
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.
2022-03-30 15:18:41 +02:00
Karolina Surma 38638cc2a0 Update documentation to reflect latest changes 2022-02-11 15:47:36 +01:00
Karolina Surma 7d7af97946 Convert PEP 440 package version to RPM scheme (Fixes #20)
- 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
2022-02-11 15:47:36 +01:00
Karolina Surma c78ed80705 It's possible to declare --archful package via CLI (#10) 2022-02-11 14:15:33 +01:00
Karolina Surma 818b04fba9 Remove CLI duplicate short option 2022-02-10 10:31:49 +01:00
Karolina Surma bf54f2bd9d Rename CI job to 'test' - it doesn't build anything 2022-02-09 10:51:38 +01:00
Karolina Surma a441b9ab66 Set betamax recording to 'none' - only reply existing cassettes 2022-02-09 10:51:38 +01:00
Karolina Surma 8d473ab526 Refactor tests significantly (#14)
- 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.
2022-02-09 10:51:38 +01:00
Karolina Surma 53900db265 Fix some pylint suggestions 2022-02-09 10:51:38 +01:00
Karolina Surma df32fc8113 Quit the scripts with sys.exit(), not exit() 2022-02-09 10:51:38 +01:00
Karolina Surma 4ecfc8af80 Remove generating the runtime requirements from spec file
pyproject-rpm-macros 0.53 made `-r` the default option.
2022-02-09 10:51:38 +01:00
Karolina Surma 7c215b1f0f Get those quotation marks right 2022-02-04 13:15:09 +01:00
Karolina Surma 4544400ee5 Fix: actually assert the expression in tests 2022-01-12 09:41:56 +01:00
Karolina Surma 8c2e7d3909 Bump version 0.3.2 -> 0.3.3 2022-01-12 09:19:16 +01:00
Karolina Surma 897dba3961 Update changelog 2022-01-12 09:17:36 +01:00
Karolina Surma 707cb079fb Refactor obtaining License (#19)
- 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
2022-01-10 11:18:50 +01:00
Karolina Surma f79496ca20 Discard multiline Summary, use generated string instead (#19) 2022-01-10 11:18:50 +01:00
Karolina Surma 51c9b2d165 Generate Summary if not provided (Fixes: #18)
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.
2022-01-10 11:18:50 +01:00
Karolina Surma 74ec6c0b49 Make it visible that description must be updated by the packager 2022-01-10 11:08:28 +01:00
Karolina Surma ffdf3f8dd6 Fix: spec files should end with a newline 2022-01-10 10:53:57 +01:00
Karolina Surma 11cbe83cd1 Bump version 0.3.1 -> 0.3.2 2021-12-10 11:48:10 +01:00
Karolina Surma 67266a4679 Use package_url if no project_urls are listed (Fixes: #17) 2021-12-10 10:26:53 +01:00
Karolina Surma e09cf1b5ae Bump release 0.3.0 -> 0.3.1 2021-12-09 08:24:55 +01:00
Karolina Surma 653450748d Fix %pypi_source macro when sdist is zipped 2021-12-09 08:23:33 +01:00
Karolina Surma 862dfe892d Bump version 0.2.0 -> 0.3.0 2021-12-08 17:35:49 +01:00
Karolina Surma 1296900be1 Add MANIFEST.in so that tests make it to sdist 2021-12-08 17:34:37 +01:00
Karolina Surma a45a3e0cf7 Add changelog entries 2021-12-08 17:04:46 +01:00
Karolina Surma c28b7c7b18 Recognize and declare zip sdist in Source macro (fixes: #12) 2021-12-08 17:04:46 +01:00
Karolina Surma bebafff5d8 Ignore 'OSI Approved' in License classifiers (Fixes: #13) 2021-12-08 17:04:46 +01:00
Karolina Surma 164f97c871 Wrap description line on 79 characters (Fixes: #11) 2021-12-08 17:04:46 +01:00
Karolina Surma 2515603a18 Update cassettes so tests don't send real requests 2021-12-08 17:04:46 +01:00
Karolina Surma 429632d8ff Bump version -> 0.2.0 2021-11-29 16:27:16 +01:00
Karolina Surma fd2872be49 Start Changelog.md + update for 0.2.0 2021-11-29 16:24:45 +01:00
Karolina Surma 2e57d67542 Add the possibility to test only top-level modules in %%check 2021-11-26 17:45:50 +01:00
Karolina Surma 35f40c0ec4 Minor README corrections 2021-11-26 17:45:43 +01:00
Karolina Surma 36dc3676fc Handle the exception when package name doesn't exist on PyPI
Instead of juicy traceback, print out a user-friendly message and exit.
Closes: #7
2021-11-24 13:53:11 +01:00
Karolina Surma 403e33e116 Update README - package goes to PyPI 2021-11-19 13:47:47 +01:00
Karolina Surma 62c5ba83b5 Use dummy filler for changelog if not set 2021-11-19 13:28:33 +01:00
Karolina Surma 81557fcb5a Use trove classifiers for getting license 2021-11-19 13:28:33 +01:00
Karolina SurmaandPatrik Kopkan 85dbdc833b Create Python distribution
- closes #3
- closes #6

Co-authored-by: Patrik Kopkan <kopkanpatrik@gmail.com>
2021-11-11 12:13:11 +01:00
Karolina Surma 648cda5cae Use importlib.resources to locate template file 2021-11-11 12:13:11 +01:00
Karolina Surma f6775c83da Move source code to its separate folder 2021-11-11 12:13:11 +01:00
Karolina Surma 3eebab4937 Move ConfigFile to conf2spec 2021-11-10 13:41:10 +01:00
Karolina Surma 4e0017c350 Pass command-line options as kwargs dict
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.
2021-11-03 13:32:17 +01:00
Karolina Surma c34451c560 Add tests for the default program run
Test a few packages from PyPI to the final specfile.
Store them in different location so that it's clear which one are
default.
2021-11-03 13:32:17 +01:00
Karolina Surma a332496b25 Distinguish tests with custom config modifications
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.
2021-11-03 10:15:37 +01:00
Karolina Surma 4241adcb27 Support the new %pyproject_check_import macro
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).
2021-11-03 09:38:06 +01:00
Karolina Surma 2350790b81 Fix template path construction 2021-11-03 09:33:11 +01:00
Karolina Surma 857c8d71ff Extend information on how to run scripts 2021-09-29 10:05:18 +02:00
Karolina Surma 7559688b9d Add config file specification 2021-09-29 10:05:18 +02:00
Karolina Surma a42e9352ef Make command-line options nicer 2021-09-22 17:21:23 +02:00
Karolina Surma 004d2ce9f7 Update docstrings 2021-09-21 15:43:06 +02:00
Karolina Surma bfae7d67b5 Log important events with click 2021-09-21 15:43:06 +02:00