Skip to main content

RPM Macro Expansion in Python

Project description

RPM Macro Expansion in Python

Parse RPM macro files and spec files, and expand macros safely—without the potential Turing-Complete side effects.

This is a standalone library that depends only on the standard Python library and PLY (for expression parsing).

How to Use It

$ norpm-expand-specfile --specfile SPEC --expand-string '%{?epoch}%{!?epoch:(none)}:%version'
(none):1.1.1

Directly from Python, you can use:

from norpm.macrofile import system_macro_registry
from norpm.specfile import specfile_expand
registry = system_macro_registry()
with open("SPEC", "r", encoding="utf8") as fd:
    expanded_specfile = specfile_expand(fd.read(), registry)
    print("Name:", registry["name"].value)
    print("Version:", registry["version"].value)

State of the implementation

There still are a few features to be implemented. Your contributions are welcome and greatly encouraged!

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

norpm-1.8.tar.gz (54.9 kB view details)

Uploaded Source

File details

Details for the file norpm-1.8.tar.gz.

File metadata

  • Download URL: norpm-1.8.tar.gz
  • Upload date:
  • Size: 54.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for norpm-1.8.tar.gz
Algorithm Hash digest
SHA256 9c32c8e41c1937a79c67735e19d3969be28b308d63bc31b1cfb790b1f556ab0c
MD5 b2893f24e76f469611e40a75bb0fbddb
BLAKE2b-256 c86c6a5dcceca7b57d2d6415b9b003f915cc9f0ecfce8ef67cc72eee91dcfaed

See more details on using hashes here.

Supported by

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