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](https://github.com/dabeaz/ply) (for expression parsing).
How to Use It
-------------
```bash
$ norpm-expand-specfile --specfile SPEC --expand-string '%{?epoch}%{!?epoch:(none)}:%version'
(none):1.1.1
```
Directly from Python, you can use:
```python
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][rfes] to be implemented. Your contributions
are welcome and greatly encouraged!
[rfes]: https://github.com/praiskup/norpm/issues?q=is%3Aissue%20state%3Aopen%20label%3Aenhancement
Raw data
{
"_id": null,
"home_page": null,
"name": "norpm",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Pavel Raiskup <pavel@raiskup.cz>",
"download_url": "https://files.pythonhosted.org/packages/6c/3f/c869bdfb4167bea45b879379cde495b0b1cfe0f6233823b20a57af7812ac/norpm-1.5.tar.gz",
"platform": null,
"description": "RPM Macro Expansion in Python\n=============================\n\nParse RPM macro files and spec files, and expand macros safely\u2014without the\npotential Turing-Complete side effects.\n\nThis is a standalone library that depends only on the standard Python library\nand [PLY](https://github.com/dabeaz/ply) (for expression parsing).\n\nHow to Use It\n-------------\n\n```bash\n$ norpm-expand-specfile --specfile SPEC --expand-string '%{?epoch}%{!?epoch:(none)}:%version'\n(none):1.1.1\n```\n\nDirectly from Python, you can use:\n\n```python\nfrom norpm.macrofile import system_macro_registry\nfrom norpm.specfile import specfile_expand\nregistry = system_macro_registry()\nwith open(\"SPEC\", \"r\", encoding=\"utf8\") as fd:\n expanded_specfile = specfile_expand(fd.read(), registry)\n print(\"Name:\", registry[\"name\"].value)\n print(\"Version:\", registry[\"version\"].value)\n```\n\nState of the implementation\n-----\n\nThere still are a [few features][rfes] to be implemented. Your contributions\nare welcome and greatly encouraged!\n\n[rfes]: https://github.com/praiskup/norpm/issues?q=is%3Aissue%20state%3Aopen%20label%3Aenhancement\n",
"bugtrack_url": null,
"license": "LGPL-2.1-or-later",
"summary": "RPM Macro Expansion in Python",
"version": "1.5",
"project_urls": {
"Homepage": "https://github.com/praiskup/norpm",
"Issues": "https://github.com/praiskup/norpm/issues",
"Repository": "https://github.com/praiskup/norpm.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6c3fc869bdfb4167bea45b879379cde495b0b1cfe0f6233823b20a57af7812ac",
"md5": "f385fb2245f5574c7e3f9f1a786ca0dd",
"sha256": "11f202dfd1ba43b1093c36e3447df9e8d8a24b51b252082ef9cf402b73d6c223"
},
"downloads": -1,
"filename": "norpm-1.5.tar.gz",
"has_sig": false,
"md5_digest": "f385fb2245f5574c7e3f9f1a786ca0dd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 48608,
"upload_time": "2025-09-07T16:32:55",
"upload_time_iso_8601": "2025-09-07T16:32:55.772833Z",
"url": "https://files.pythonhosted.org/packages/6c/3f/c869bdfb4167bea45b879379cde495b0b1cfe0f6233823b20a57af7812ac/norpm-1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-07 16:32:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "praiskup",
"github_project": "norpm",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "ply",
"specs": []
},
{
"name": "pytest",
"specs": []
},
{
"name": "pytest-cov",
"specs": []
}
],
"lcname": "norpm"
}