Skip to main content

Converts a Fedora RPM spec file from %py3_build etc. to %pyproject macros

Project description

pyprojectize

This helps you convert a Fedora RPM spec file from %py3_build etc. to %pyproject macros. This program only operates on the spec file itself, and hence has limited knowledge. The resulting spec file is not guaranteed to be buildable and manual verification and completion of the transition is strongly advised.

$ python pyprojectize.py --help
usage: pyprojectize [-h] [-l] [-i MODIFIER] [-x MODIFIER [MODIFIER ...] | -o MODIFIER] [-s SOURCEDIR]
                    [SPECFILE]

positional arguments:
  SPECFILE              path to the spec file to convert

options:
  -h, --help            show this help message and exit
  -l, --list-modifiers  list all available modifiers and exit
  -i MODIFIER, --info MODIFIER
                        display documentation for given modifier
  -x MODIFIER [MODIFIER ...], --exclude MODIFIER [MODIFIER ...]
                        exclude given modifier
  -o MODIFIER, --only MODIFIER
                        run only one given modifier
  -s SOURCEDIR, --sourcedir SOURCEDIR
                        path to the source directory, relevant for %include etc. (default: spec's parent)

If you wish to process multiple specfiles at a time, run this tool via parallel, etc. If you wish to
inspect/commit result of each modififer separatelly, you can loop over pyprojectize -l calling pyprojectize -o
$modifer each time.

$ python pyprojectize.py ampy.spec  # 16a7deeb
✅ add_pyproject_buildrequires: %generate_buildrequires with %pyproject_buildrequires added
✅ remove_setuptools_br: removed BuildRequires for setuptools
✅ py3_build_to_pyproject_wheel: replaced %py3_build with %pyproject_wheel in %build
✅ py3_install_to_pyproject_install: replaced %py3_install with %pyproject_install in %install
✅ egginfo_to_distinfo: replaced .egg-info with .dist-info in %files
✅ add_pyproject_files: %{python3_sitelib}/%{python3_sitearch} lines replaced with %{pyproject_files}
👌 update_extras_subpkg: %{?python_extras_subpkg:%python_extras_subpkg ...} not found
✅ remove_python_provide: %python_provide removed or replaced with %py_provides
✅ remove_python_enable_dependency_generator: %python_enable_dependency_generator removed

Demo

https://github.com/hroncok/pyprojectize/compare/originals..specfiles

Installation

This is a pip-installable package.

pip install pyprojectize

Or use uv, pipx etc.

Available modifiers

add_pyproject_buildrequires

If there is no %generate_buildrequires section, add it after %prep.

Insert %pyproject_buildrequires to the end of %generate_buildrequires.

remove_setuptools_br

Remove BuildRequires for setuptools, they should be generated.

py3_build_to_pyproject_wheel

In the %build section, replace %py3_build with %pyproject_wheel. Arguments (if any) are passed to -C--global-option.

py3_install_to_pyproject_install

In the %install section, replace %py3_install with %pyproject_install. Any arguments are discarded. Installing a wheel does not need arguments.

egginfo_to_distinfo

In all the %files sections, replace .egg-info with .dist-info. The .dist-info filename is updated if possible (e.g. to use canonical name and version). Works reasonably well even with macronized filenames.

add_pyproject_files

If there is only one %files section with %{python3_sitelib} or %{python3_sitearch}, replace the manually listed files with %pyproject_save_files and -f %{pyproject_files}.

In case the %license files match patterns recognized by setuptools' defaults, uses %pyproject_save_files with -l and removes them.

update_extras_subpkg

Replace %python_extras_subpkg -i ... with %pyproject_extras_subpkg, preserve other arguments.

remove_python_provide

Remove %python_provide or replace it with %py_provides if the package name isn't the same.

This does not detect packages without files yet. Packages without files need %py_provides even when the package name is the same.

remove_python_enable_dependency_generator

Remove %python_enable_dependency_generator, as the generator is enabled by default.

License

MIT-0, see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyprojectize-1.dev2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

pyprojectize-1.dev2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pyprojectize-1.dev2.tar.gz.

File metadata

  • Download URL: pyprojectize-1.dev2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyprojectize-1.dev2.tar.gz
Algorithm Hash digest
SHA256 e5e7a461b12513597810322fe502fa5801fced4b7d6f7f1cc174607f3e979614
MD5 67daf080dfe9aaf49850566448c0130c
BLAKE2b-256 0391822dca1fe6ad52eecf1aebb501075ff48dd0541baa3e46d71e30eb84af44

See more details on using hashes here.

File details

Details for the file pyprojectize-1.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyprojectize-1.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 f19834e7b2bcf16814ac30204b9e22d48bd399058b4a994a158681755dc41c1a
MD5 cb00ba2f953c0a54a81c1abd4c963386
BLAKE2b-256 d375197b48271c4232426381e1b109094facfc0214bf4d18afcb7e6aa13c3c7d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page