Simple Python module to extract basic information directly from PKGBUILD files (not .SRCINFO)
Project description
pkgbuild_parser
Introduction
pkgbuild_parser is a module written in Python (compatible with Python 3.x) designed to extract information from a PKGBUILD. The main purpose of this module is to provide simple and direct access to the most important fields of a PKGBUILD without relying on external tools or additional libraries.
- Version: 2.0.0
- License: MPL-2.0 2026 KevinCrrl
- Dependencies: None
- Style: Simplicity, no external dependencies, easy to use
This module allows you to quickly and directly obtain data such as package name, version, description, license, URL, and source file.
Main functions for the user
Although the module internally has support functions (get_base), the user only needs to use the high-level functions, which are clear and direct:
| Function | That returns |
|---|---|
get_pkgname() |
Package name (pkgname) as a string. |
get_pkgver() |
Package version (pkgver) as a string. |
get_pkgrel() |
Release number (pkgrel) as a string. |
get_pkgdesc() |
Package description (pkgdesc) as a string. |
get_arch() |
Package architecture (arch) as a list of strings. |
get_url() |
Main project URL (url) as a string. |
get_license() |
Package license (license) as a list of strings. |
get_source() |
Package source(s) (source) as a list of strings. |
get_epoch() |
Package epoch. |
get_full_package_name() |
Full package name, including epoch, version, and pkgrel. |
get_depends() |
List of the package's dependencies. |
get_makedepends() |
List of the package's build dependencies. |
get_optdepends() |
Dictionary of the package's optional dependencies. |
get_options() |
List of the package's options. |
get_checkdepends() |
List of the package's check dependencies. |
get_sums(algorithm) |
List of the algorithm checksums. |
get_validpgpkeys() |
List of the valid PGP keys. |
get_conflicts() |
List of conflicting packages. |
get_provides() |
List of packages provided. |
get_replaces() |
List of packages it replaces. |
get_pkgbase() |
Base package (pkgbase) as a list. |
Note: The internal functions (get_base, multiline, replacevar, processvar and remove_quotes) are intended for module use and do not need to be used by the user, except when you want to create functions that are not in the parser.
Also, you can use the InfoDict class to create dictionariess from selected information, InfoDict has this methods:
| Function | That returns |
|---|---|
get_dict() |
dictionary that contains the information requested by the user. |
to_json() |
Converts the dictionary to a JSON format. |
write_json(json_name) |
Writes a file with the provided name that contains the dictionary information in JSON format. |
Installation and use
Option 1: AUR
The module is available on the AUR as python-pkgbuild-parser.
Option 2: PyPi
pip install pkgbuild-parser
Basic usage
GitHub example Codeberg example
Error handling
If the PKGBUILD file does not exist, a ParserFileError is raised, which must be caught to prevent the program from failing.
A ParserKeyError can also be raised if getting a value from the PKGBUILD fails, for example, if the license is not declared correctly, and get_license() is called, this exception will be raised.
Limitations and additional notes
- Starting with version 1.2.0, the parser can replace known variables in a Bash string. For example, if you try to fetch a source file and it is declared in the PKGBUILD as "${url}/package-$pkgver.tar.gz", pkgbuild-parser will be able to recognize these variables, retrieve them, and replace them with their values.
- The module's goal is to extract only basic information from standard PKGBUILDs, It cannot replace variables it does not recognize, such as "$my_personal_var", or variations of known variables, such as "$pkgname%suffix".
- It works best with PKGBUILDs that follow the Arch Wiki standards.
- Since version 0.4.0, the module can extract information from arrays or lists, such as
depends,makedepends,source,optdepends,license,options, andcheckdepends. - Since version 1.0.0, functions that return a string no longer include quotes by default.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pkgbuild_parser-2.0.0.tar.gz.
File metadata
- Download URL: pkgbuild_parser-2.0.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
813506a39d8652f639af7abf745609d1560298ef81b56bbd6510ebc634e3ef89
|
|
| MD5 |
e3e98c77857fda4fc8f4b17533384da2
|
|
| BLAKE2b-256 |
d23399d76e81cec772b3211f549f88ec69b37515a3189aca0cf50856ec61d996
|
File details
Details for the file pkgbuild_parser-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pkgbuild_parser-2.0.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df6512aad3e280b65201a3c3c4c5e28a1549b94cc9b5cb4094d4ec15d4d05b7e
|
|
| MD5 |
1b30e88f5a64cefdd368ca13fcdbb58e
|
|
| BLAKE2b-256 |
dac22d297c74c898b3e356e5396414567da261a00992278afe64419477110a8a
|